Difference between pages "OpenVZ/pt-br" and "Funtoo Linux First Steps"

From Funtoo
< OpenVZ(Difference between pages)
Jump to navigation Jump to search
 
(Use the epro command for setting-up profiles)
 
Line 1: Line 1:
== Apresentação ==
If you are brand new to Gentoo Linux or Funtoo Linux, this page will help you to get familiar with your new system, and how it works.


OpenVZ (veja [http://wiki.openvz.org wiki.openvz.org]) é uma solução de virtualização de servidor a nível do sistema operacional (OS-level server virtualization solution),
== Intro to Emerge: Installing an Editor ==
construído no Linux. OpenVZ permite a criação de containers Linux virtuais isolados e seguros (chamados de "VE"s) em um único servidor físico. Cada container possui sua própria atualização local, power state, interfaces de rede, limites de recurso e porção limitada de filesystem hospede. OpenVZ é com frequência descrito como "chroot on steroids."


Funtoo possui suporte ao OpenVZ das seguintes maneiras:
By default, Funtoo Linux has the <tt>nano</tt> and <tt>vi</tt> editors installed. <tt>nano</tt> is the default editor.


* Construção dos templates do OpenVZ utilizando o [[Metro]], nossa ferramenta de construção da distribuição.
If you are new to Funtoo Linux, you have probably heard about <tt>[[emerge]]</tt>, the Funtoo and Gentoo Linux command for installing packages from the Portage tree. Funtoo Linux has a git-based Portage tree, which is located at <tt>/usr/portage</tt> by default. It contains scripts called ''ebuilds'' that describe how to build and install packages from source. <tt>emerge</tt> is used to run these scripts and install packages, as follows:
* Melhoria do <tt>vzctl</tt>, ao desenvolver uma versão melhorada/patched hospedada em [http://www.github.com/funtoo/vzctl GitHub].
* Integração de suporte [[Funtoo Linux Networking]]  ao vzctl (esses patches tem sido aceitos pelo projeto OpenVZ.)
* Melhoria dos scripts de startup vzctl para fazer coisas como inicializar corretamente o veth e o vzeventd.
* Integrar patches adicionais nos ebuilds do openvz-rhel6-stable e do openvz-rhel5-stable para assegurar funcionalidade em qualidade de produção (production-quality) do OpenVZ.
* Manter compatibilidade com os kernels de produção OpenVZ do RHEL5-based, tão bem quanto instruções em como obter instalação do Funtoo Linux para esses kernels em nosso [[RHEL5 Kernel HOWTO]]. (Note: kernel openvz-rhel6-kernel RHEL6-based é agora o recomendado para deploying OpenVZ.)


Em adição, Daniel está atualmente empregado na [http://www.zenoss.com Zenoss] e é o autor e mantenedor do [http://community.zenoss.org/blogs/zenossblog/2012/01/24/openvz-and-zenoss Zenoss OpenVZ ZenPack] ([https://github.com/zenoss/ZenPacks.zenoss.OpenVZ GitHub link])
<console>
# ##i##emerge vim
</console>


== Versões Recomendadas ==
You can also see what packages ''would'' be installed, but not actually install them, by using the <tt>-p</tt>, or <tt>--pretend</tt> option:


Para instalação do OpenVZ no Funtoo Linux de modo que você pode criar containers Linux-based, uma versão <tt>x86-64bit</tt> do Funtoo Linux é fortemente recomendada. O ebuild <tt>openvz-rhel6-stable</tt> é o kernel recomendado a utilizar. Se você emergir esse kernel com a flag USE <tt>binary</tt> habilitado, ele construirá um kernel binário e initrd utilizando a configuração padrão Red Hat que dever inicializar quase todo o hardware. Depois de emergir, você precisara editar o <tt>/etc/boot.conf</tt>, executar o [[boot-update]], e reiniciar no novo kernel OpenVZ.
<console>
# ##i##emerge -p vim
</console>


{{fancywarning|1=
Another equally handy option is the <tt>-a</tt>, or <tt>--ask</tt> option, which will display the packages to be merged, and then ask for confirmation from you before continuing:
Por favor, utilize o ext4 exclusivamente quando implantar um OpenVZ host. A equipe de desenvolvimentos paralelos testa extensivamente com o ext4, e versões modernas do <tt>openvz-rhel6-stable</tt> '''não'''são compatíveis com o XFS, e você pode ter experiencias com kernel bugs.
}}


Alternativamente, você poderia emergir <tt>openvz-rhel5-stable</tt> como a flag USE <tt>binary</tt> habilitada para utilizar o kernel OpenVZ RHEL5-based mais antigo. Isso querer passo adicionais que foram cobertos no [[RHEL5 Kernel HOWTO]].
<console>
# ##i##emerge -a emacs


Você precisará emergir <tt>vzctl</tt>, que são as ferramentas userspace do OpenVZ.
These are the packages that would be merged, in order:
== Configuração ==


Depois de inicializar (booting) em um kernel OpenVZ-enabled, o OpenVZ pode ser habilitado como a seguir:
Calculating dependencies... done!
[ebuild  N    ] app-admin/eselect-emacs-1.13
[ebuild  N    ] net-libs/liblockfile-1.09
[ebuild  N    ] app-emacs/emacs-common-gentoo-1.3-r1  USE="-X -emacs22icons"
[ebuild  N    ] app-editors/emacs-23.4-r1  USE="alsa gif gpm jpeg png tiff xpm -X -Xaw3d (-aqua) -athena -dbus -gconf -gtk -gzip-el -hesiod -kerberos -livecd -m17n-lib -motif -sound -source -svg -toolkit-scroll-bars -xft"
[ebuild  N    ] virtual/emacs-23


<console>
Would you like to merge these packages? [Yes/No]  ##i##y
# ##i##emerge vzctl
# ##i##rc-update add vz default
# ##i##rc
</console>
</console>


== Templates OpenVZ Funtoo Linux ==
In the above <tt>emerge</tt> output, you can see some text beginning with <tt>USE=</tt> on the <tt>app-editors/emacs</tt> line. This means that this package has a number of optional build-time features which can be controlled using Portage USE variables. These USE variables can be set globally by adding a line such as this to <tt>/etc/make.conf</tt>:
 
<pre>
USE="gif jpeg png tiff xpm"
</pre>
 
If you go ahead and make these changes, and then run <tt>emerge -a emacs</tt> again, you will notice that several more dependencies will be pulled into the list of packages to be merged. You can control the footprint of your Funtoo Linux system (and avoid bloat) by enabling only the USE variables you need.
 
Above, we enabled several USE variables globally in <tt>/etc/make.conf</tt>. It is also possible to enable USE variables on a per-package basis, and often times this is the best approach. If you wanted to enable <tt>gtk</tt> for emacs only, you would create the <tt>/etc/portage/package.use</tt> directory, and create an <tt>emacs</tt> file in it that contained the following:
 
<pre>
app-editors/emacs gtk
</pre>
 
Note that <tt>package.use</tt> can also be a file if you prefer. However, using an <tt>/etc/portage/package.use</tt> directory is recommended as it keeps things better organized. The filenames you use inside the <tt>package.use</tt> directory do not impact Portage behavior and can be named whatever is convenient for you. You might want to put the settings above in a file called <tt>/etc/portage/package.use/editors</tt> if you have several USE settings that you use for editors.


O diretório stage do Funtoo Linux também contem os templates OpenVZ Funtoo Linux  no diretório openvz/. Esse podem ser utilizados como a seguir:
See the [[emerge]] page for more information on various emerge command-line options and best practices.
 
==== Default editor ====
 
Funtoo Linux also has a special meta-command called <tt>eselect</tt>, which can be used to set many default system settings. One of the things it is used for is to set the default editor used by things like <tt>crontab -e</tt>, etc that will automatically start an editor when run. Here is how to use <tt>eselect</tt> to change the default system editor:


<console>
<console>
# ##i##cd /vz/template/cache
# ##i##eselect editor list
# ##i##wget http://ftp.osuosl.org/pub/funtoo/funtoo-current/openvz/x86-64bit/funtoo-openvz-core2_64-funtoo-current-2011-12-31.tar.xz
Available targets for the EDITOR variable:
# ##i##vzctl create 100 --ostemplate funtoo-openvz-core2_64-funtoo-current-2011-12-31
  [1]  /bin/nano
Creating container private area (funto-openvz-core2-2010.11.06)
  [2]  /bin/ed
Performing postcreate actions
  [3]  /usr/bin/ex
Container private area was created
  [4]  /usr/bin/vi
  [ ]  (free form)
# ##i##eselect editor set 4
Setting EDITOR to /usr/bin/vi ...
Run ". /etc/profile" to update the variable in your shell.
</console>
</console>


Se você não estiver utilizando o Funtoo Linux, você poderá precisar converter o template de  .xz para um template .gz para isso funcione.
After logging in again, or typing <tt>source /etc/profile</tt> in the current shell, the new system editor will be active.


== Limites de Recursos ==
Note that if you want to use vim instead of a vi through busybox you also need to run:
 
Se você não precisa ter quaisquer limites de recurso para o VE, então em um Funtoo Linux host, ele podem ser habilitados como a seguir:


<console>
<console>
ninja1 ~ # ##i##vzctl set 100 --applyconfig unlimited --save
# ##i##eselect vi set vim
</console>
</console>


== Starting the Container ==
=== Profiles ===


Here's how to start the container:
You may have heard that Funtoo Linux and Gentoo Linux are metadistributions, which means that rather than being a one-size-fits-all kind of Linux, they allow you to customize your system to your liking. We have already taken a look at <tt>USE</tt> variables, and there are also various other settings that can affect the features that are installed when you emerge a package.
 
In Funtoo Linux, we have a system of ''profiles'' which can be used to enable various useful settings at once. In fact, a number of profiles are already enabled on your system. For example, on my desktop system, typing <tt>epro show</tt> produces the following output:


<console>
<console>
ninja1 ~ # ##i##vzctl start 100
=== Enabled Profiles: ===
Starting container ...
 
Container is mounted
        arch: x86-64bit
Setting CPU units: 1000
      build: current
Container start in progress...
    subarch: generic_64
ninja1 ~ #
      flavor: desktop
</console>
    mix-ins: gnome
== Networking ==
    mix-ins: hardened
 


=== veth networking ===
=== All inherited flavors from desktop flavor: ===


OpenVZ has two types of networking. The first is called "veth", which provides the VE with a virtual ethernet interface. This allows the VE to do things like broadcasting and multicasting, which means that DHCP can be used. The best way to set up veth networking is to use a bridge on the physical host machine. For the purposes of this example, we'll assume your server has a wired eth0 interface that provides Internet connectivity - it does not need to have an IP address. To configure a bridge, we will create a network interface called "br0", a bridge device, and assign your static ip to br0 rather than eth0. Then, we will configure eth0 to come up, but without an IP, and add it as a "slave" of bridge br0. Once br0 is configured, we can add other network interfaces (each configured to use a unique static IP address) as slaves of bridge br0, and these devices will be able to communicate out over your Ethernet link.
                    workstation (from desktop flavor)
                            core (from workstation flavor)
                        minimal (from core flavor)


Let's see how this works.
=== All inherited mix-ins from desktop flavor: ===


==== Network - Before ====
                              X (from workstation flavor)
                          audio (from workstation flavor)
                            dvd (from workstation flavor)
                          media (from workstation flavor)
      mediadevice-audio-consumer (from media mix-in)
                mediadevice-base (from mediadevice-audio-consumer mix-in)
      mediadevice-video-consumer (from media mix-in)
                mediadevice-base (from mediadevice-video-consumer mix-in)
        mediaformat-audio-common (from media mix-in)
          mediaformat-gfx-common (from media mix-in)
        mediaformat-video-common (from media mix-in)
                  console-extras (from workstation flavor)
                          print (from desktop flavor)
</console>


Before the bridge is configured, we probably have an <tt>/etc/conf.d/netif.eth0</tt> that looks like this:
In case you're curious, these various profile settings live within <tt>/usr/portage/profiles/funtoo/1.0/linux-gnu</tt>. You can find the profile settings for (inherited) mix-in <tt>X</tt> by looking in <tt>/usr/portage/profiles/funtoo/1.0/linux-gnu/mix-ins/X</tt>, for example.


<pre>
Under the list of <tt>Enabled profiles</tt>, you'll see that I have an <tt>x86-64bit</tt> arch profile. In Funtoo Linux, ''all'' systems have a single arch profile defined, and this is where settings specific to your system architecture are defined. Besides the architecture, there is also a sub-architecture profile, which allows you to enable builds options which make the system even more optimised towards the specific set of CPU instructions you might have at your disposal. Like in case of architecture, only a single sub-architecture can be defined at any time for a single system. In addition, I have a build profile of ''current''. All Funtoo Linux systems have a single build profile defined, and this tells Portage what masks to apply to the Portage tree -- in other words, what selection of packages you will have available to emerge. If you are using funtoo-stable, your build profile will be ''stable'' and you will have a more limited set of packages that you can merge by default -- the stable set.
template="interface"
ipaddr="10.0.1.200/24"
gateway="10.0.1.1"
nameservers="10.0.1.1"
domain="funtoo.org"
</pre>


==== Network - After ====
You will also see that I have a ''flavor'' profile. Unlike the ''arch'', ''subarch'', and ''build'' profiles, which should not be changed, you can choose another flavor if you want. In fact, we encourage you to do so. The ''flavor'' is used to define the general type of system you are creating. You can only have one flavor profile enabled, and since this command was run on a desktop-type system, I have enabled the ''desktop'' flavor. This enables a variety of settings, primarily USE flags, suitable for desktop systems.


To get the bridge-based network configured, first connect to a physical terminal or management console, as eth0 will be going down
You'll also see that I have a couple of ''mix-ins'' (explicitly) enabled. In Funtoo Linux, you can have zero or more mix-ins enabled -- I have ''gnome'' enabled, which sets various settings that are optimal for the use of the [[GNOME First Steps|GNOME]] desktop environment, and then I am also using the ''hardened'' mix-in, since I have set up a so-called "hardened" system with various protections against malicious attacks.
for a bit as we make these changes.


We are now going to set up a bridge with eth0's IP address, and add eth0 to the bridge with no IP. Then we can throw container interfaces into the bridge and then can all communicate out using eth0.
{{Tip|1=Take advantage of Funtoo Linux's [[:News:New Media Mix-ins| enhanced Media mix-ins]] to help you easily get the level of media support you want for your system.}}


We will <tt>mv netif.eth0 netif.br0</tt>, and then edit the file so it looks like this (first line modified, new line added at end):
Followed by the general information about enabled profiles and mix-ins come two lists - one showing any number of flavors that are inherited by the flavor you picked within profile settings, and one showing a listing of all the different mix-ins that got pulled-in by the flavor you have selected. As you can see, the desktop flavor itself inherits (and  builds upon) flavors ''workstation'', ''core'', and ''minimal''. On the other hand, all of these different flavors pull in a number of mix-ins. Each mix-in shows which flavor has pulled it in. For example, the ''X'' mix-in comes with the ''workstation'' flavor, while the ''print'' mix-in comes from the ''desktop'' flavor. Some mix-ins are pulled-in by other mix-ins, as you can see for the mix-in ''mediaformat-audio-common'' - which is pulled-in by the media mix-in (which, in turn, is pulled in by the ''workstation'' flavor).


<pre>
For now, it is not necessary to get too deep into profiles, but if you are creating a desktop system, I suggest you set the ''desktop'' flavor. To do this, type the following command as the root user:
template="bridge"
ipaddr="10.0.1.200/24"
gateway="10.0.1.1"
nameservers="10.0.1.1"
domain="funtoo.org"
slaves="netif.eth0"
</pre>


If you want to bridge the wlan0 device, you'll need the additional wpa_supplicant flag '''''-b br0''.'''
In most cases for wlan0 it is much better to use a route:
<console>
<console>
# ##i##iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -o wlan0 -j SNAT your_host_ip_address
# ##i##epro profile desktop
</console>  
</console>


Now, time to create a new <tt>/etc/conf.d/netif.eth0</tt>, but this time we won't associate an IP address with it. Config file looks like this, a single line:
You will now have the ''desktop'' flavor set for your system. Type <tt>epro show</tt> to see your new settings.


<pre>
=== Updating your system ===
template="interface-noip"
</pre>


Now, we need to create a necessary symlink in /etc/init.d and get our bridge added to the default runlevel:
Sometimes, you may want to update the packages on your system. Often, this is done after you run <tt>emerge --sync</tt>, which will grab Portage tree updates from the main Funtoo Linux Portage tree:


<console>
<console>
# ##i##cd /etc/init.d
# ##i##emerge --sync
# ##i##ln -s netif.tmpl netif.br0
 
# ##i##rc-update add netif.br0 default
>>> Starting git pull...
remote: Counting objects: 1791, done.       
remote: Compressing objects: 100% (206/206), done.       
remote: Total 980 (delta 811), reused 931 (delta 764)       
Receiving objects: 100% (980/980), 185.04 KiB, done.
Resolving deltas: 100% (811/811), completed with 754 local objects.
From git://github.com/funtoo/experimental-mini-2011
  7a17140..b836bc8  funtoo.org -> origin/funtoo.org
Updating 7a17140..b836bc8
Fast-forward
>>> Git pull in /usr/portage successful
 
* IMPORTANT: 1 news items need reading for repository 'gentoo'.
* Use eselect news to read news items.
 
#
</console>
</console>


Now, let's enable our new network interfaces:
You may also want to update your system after you have changed USE flag settings. To take advantage of the USE flags you have just enabled, it's necessary to recompile everything that includes them.
 
Below, you'll find a recommended <tt>emerge</tt> command for updating your entire system. The <tt>-a</tt> option will cause <tt>emerge</tt> to prompt you for confirmation before starting the merge:


<console>
<console>
# ##i##/etc/init.d/netif.eth0 stop
# ##i##emerge -auDN world
# ##i##rc
</console>
</console>


The result of these changes is that you now have initscripts to create a "br0" interface (with static IP), with "eth0" as its slave (with no IP). Networking should still work as before, but now you are ready to provide bridged connectivity to your virtual containers since you can add their "veth" interfaces to "br0" and they will be bridged to your existing network.
<tt>-u</tt> tells <tt>emerge</tt> to update any already-installed but out-of-date packages that we specify on the command-line. The <tt>-D</tt> option tells <tt>emerge</tt> to perform a ''deep'' dependency tree graph, so it will include sub-dependencies of packages that we have specified on the command line as well. This allows <tt>emerge</tt> to perform as thorough an update of your system as possible.  


==== Using The Bridge ====
The <tt>-N</tt> (<tt>--newuse</tt>) option tells Portage to check for any new USE flags that have been enabled or disabled, and rebuild packages so that all USE flags are set as currently defined in <tt>/etc/make.conf</tt> and <tt>/etc/portage/package.use</tt>.


To add a veth "eth0" interface to your VE, type the following:
<tt>world</tt> is a "meta-package" or "package set" which includes every package that you have manually installed plus all packages in the system set. It's important to note that whenever you ask <tt>emerge</tt> to install anything, such as <tt>metalog</tt> or <tt>vim</tt>, those packages will be automatically added to the world package set. In this way, <tt>emerge</tt> learns what packages you care about and want to keep updated. If you want to see what's in your world package set, take a look at <tt>/var/lib/portage/world</tt>:


<console>
<console>
# ##i##vzctl stop 100
# ##i##cat /var/lib/portage/world
# ##i##vzctl set 100 --netif_add eth0,,,,br0 --save
app-editors/vim
# ##i##vzctl start 100
app-portage/eix
</console>
app-portage/gentoolkit
dev-vcs/git
net-misc/bridge-utils
net-misc/dhcpcd
net-misc/keychain
sys-apps/gptfdisk
sys-apps/pciutils
sys-devel/bc
sys-fs/reiserfsprogs
sys-kernel/vanilla-sources
</console>  
 
Also note that some packages may have been added to the world set by Metro when your stage3 tarball was built.
 
==== Updating a few packages ====


Once the VE is started, the network interface inside the VE will be called "eth0", and the network interface on the host system will be named "veth100.0". Because we specified "br0" after the 4 commas, vzctl will automatically add our new "veth100.0" interface to bridge br0 for us. We can see this by typing "brctl show" after we have started the VE by typing "vzctl start 100".
If we simply wanted to rebuild a few packages to reflect updated USE flag settings, we could specify it instead of <tt>world</tt>. Be sure to include the <tt>-N</tt> option:


<console>
<console>
# ##i##brctl show
# ##i##emerge -auDN vim emacs
bridge name    bridge id              STP enabled    interfaces
br0            8000.0026b92c72f5      no              eth0
                                                        veth100.0
</console>
</console>


==== VE Configuration ====
== Useful applications for daily usage ==


You will also need to manually configure the VE to acquire/use a valid IP address - DHCP or static assignment will both work; typically, this is done by starting the VE with "vzctl start 100" and then typing "vzctl enter 100", which will give you a root shell inside the VE. Then, once you have configured the network, you can ensure that the VE is accessible remotely via SSH. Note that once inside the VE (with "vzctl enter 100"), you configure the VE's network interface as you would on a regular Linux distribution - the VE will be bridged into your LAN, so it can talk to your DHCP server, and can use an IP address that it acquires via DHCP or it can use a static address.
Here are some other packages you may want to consider installing via <tt>emerge</tt>:


=== venet networking ===
;<tt>app-misc/screen</tt>: Allows you to have persistent login sessions.
 
;<tt>app-misc/tmux</tt>: Similar to <tt>screen</tt> -- some people prefer it.
"venet" is OpenVZ's other form of host networking. It can be easier to configure than veth, but does not allow the use of broadcast or multicast, so DHCP is not possible on the VE side. For this reason, an IP address must be statically assigned to the VE, as follows:
;<tt>app-admin/sudo</tt>: Grant root privileges to selected users and command combinations.
;<tt>sys-process/htop</tt>: Colorful and informative text-based process list.
;<tt>sys-process/glances</tt>: Similar to htop, includes disc I/O and network I/O in display.
;<tt>app-portage/eix</tt>: Quick portage package search
;<tt>app-portage/gentoolkit</tt>: Portage utils
;<tt>app-misc/mc</tt>: GNU Midnight Commander is a text based file manager --- some will recall <tt>MS-DOS XtreeGold</tt>
;<tt>app-text/wgetpaste</tt>: Command-line interface to various pastebins; very useful in providing info along with bugs reports
;<tt>net-irc/irssi</tt>: A modular textUI IRC client with IPv6 support; a powerful tool to get help from Funtoo Community on IRC channel. Nice companion to <tt>app-text/wgetpaste</tt>


<console>
<console>
# ##i##vzctl set 100 --ipadd 10.0.1.201 --save
# ##i##emerge --jobs app-misc/screen sudo htop eix gentoolkit app-misc/mc wgetpaste net-irc/irssi
# ##i##vzctl set 100 --nameserver 8.8.4.4 --save #google public DNS server
# ##i##vzctl set 100 --hostname foobar --save
</console>
</console>


With venet configuration, some additional steps are required in case of PPPoE Internet connection. We will use iptables to get network working in all VE's.
=== Creating a user account ===


<console># ##i##echo 1 > /proc/sys/net/ipv4/ip_forward</console>
It's a good idea to create a normal user account that you can use for general Linux tasks. Before rebooting, create a user account for everyday use. Adjust the groups in the example below to match your needs. Some of them may not exist yet on your system. Replace "<tt><user_name></tt>" with the name you're going to use for your everyday user. The "<tt>-m</tt>" option instructs <tt>useradd</tt> to create a home directory for your user. See <tt>man useradd</tt> for more info.


or, alternatively set it in /etc/sysctl.conf to have ip forward at boot
<console>
# ##i##useradd -m -g users -G audio,video,cdrom,wheel <user_name>
</console>
Don't forget to set a password for your new user:
<console>
# ##i##passwd <user_name>
</console>


<console># ##i##echo "net.ipv4.ip_forward = 1" >> /etc/sysctl.conf
== Installing a graphical environment ==
# ##i##sysctl -p</console>


Add an iptables rule, save and start the firewall:
If you intend on using your Funtoo Linux installation for more than system administration, chances are you're going to want to have a GUI (graphical user interface). In the past, setting one up involved wading through text files and man pages. Thanks to modern tools like udev this is no longer the case.
<console># ##i##iptables -t nat -A POSTROUTING -o ppp0 (or your desired interface) -j MASQUERADE
# ##i##/etc/init.d/iptables save
# ##i##rc-update add iptables default
# ##i##rc</console>
All VE's now have a network connection from HN.


When using venet, OpenVZ will handle the process of ensuring the VE has its network properly configured at boot. As of vzctl-3.0.24.2-r4 in Funtoo Linux, Funtoo Linux VEs should be properly auto-configured when using venet.
Unlike most operating systems, Funtoo does not ship with a GUI pre-installed. If you've used Windows or Mac OS, you'd also know that their interfaces cannot be replaced easily. With Linux, the opposite is true -- you are free to choose from a huge selection of GUIs. From window managers such as Blackbox, IceWM, and xmonad, to fully-featured desktop environments like GNOME and KDE, the possibilities are vast in number.


With venet, there is no need to add any interfaces to a bridge - OpenVZ treats venet interfaces as virtual point-to-point interfaces so that traffic is automatically routed properly from the VE to the host system, out the default route of the host system if necessary.
The first step in setting up a graphical environment is to set up the [[X Window System]]. Then, you will be able to install the graphical environment of your choice. [[GNOME First Steps|GNOME]] is a popular option for new users.


[[Category:Virtualization]]
[[Category:HOWTO]]
[[Category:Install]]
[[Category:Featured]]

Revision as of 09:39, May 4, 2015

If you are brand new to Gentoo Linux or Funtoo Linux, this page will help you to get familiar with your new system, and how it works.

Intro to Emerge: Installing an Editor

By default, Funtoo Linux has the nano and vi editors installed. nano is the default editor.

If you are new to Funtoo Linux, you have probably heard about emerge, the Funtoo and Gentoo Linux command for installing packages from the Portage tree. Funtoo Linux has a git-based Portage tree, which is located at /usr/portage by default. It contains scripts called ebuilds that describe how to build and install packages from source. emerge is used to run these scripts and install packages, as follows:

root # emerge vim

You can also see what packages would be installed, but not actually install them, by using the -p, or --pretend option:

root # emerge -p vim

Another equally handy option is the -a, or --ask option, which will display the packages to be merged, and then ask for confirmation from you before continuing:

root # emerge -a emacs

These are the packages that would be merged, in order:

Calculating dependencies... done!
[ebuild  N     ] app-admin/eselect-emacs-1.13 
[ebuild  N     ] net-libs/liblockfile-1.09 
[ebuild  N     ] app-emacs/emacs-common-gentoo-1.3-r1  USE="-X -emacs22icons" 
[ebuild  N     ] app-editors/emacs-23.4-r1  USE="alsa gif gpm jpeg png tiff xpm -X -Xaw3d (-aqua) -athena -dbus -gconf -gtk -gzip-el -hesiod -kerberos -livecd -m17n-lib -motif -sound -source -svg -toolkit-scroll-bars -xft" 
[ebuild  N     ] virtual/emacs-23 

Would you like to merge these packages? [Yes/No]  y

In the above emerge output, you can see some text beginning with USE= on the app-editors/emacs line. This means that this package has a number of optional build-time features which can be controlled using Portage USE variables. These USE variables can be set globally by adding a line such as this to /etc/make.conf:

USE="gif jpeg png tiff xpm"

If you go ahead and make these changes, and then run emerge -a emacs again, you will notice that several more dependencies will be pulled into the list of packages to be merged. You can control the footprint of your Funtoo Linux system (and avoid bloat) by enabling only the USE variables you need.

Above, we enabled several USE variables globally in /etc/make.conf. It is also possible to enable USE variables on a per-package basis, and often times this is the best approach. If you wanted to enable gtk for emacs only, you would create the /etc/portage/package.use directory, and create an emacs file in it that contained the following:

app-editors/emacs gtk

Note that package.use can also be a file if you prefer. However, using an /etc/portage/package.use directory is recommended as it keeps things better organized. The filenames you use inside the package.use directory do not impact Portage behavior and can be named whatever is convenient for you. You might want to put the settings above in a file called /etc/portage/package.use/editors if you have several USE settings that you use for editors.

See the emerge page for more information on various emerge command-line options and best practices.

Default editor

Funtoo Linux also has a special meta-command called eselect, which can be used to set many default system settings. One of the things it is used for is to set the default editor used by things like crontab -e, etc that will automatically start an editor when run. Here is how to use eselect to change the default system editor:

root # eselect editor list
Available targets for the EDITOR variable:
  [1]   /bin/nano
  [2]   /bin/ed
  [3]   /usr/bin/ex
  [4]   /usr/bin/vi
  [ ]   (free form)
root # eselect editor set 4
Setting EDITOR to /usr/bin/vi ...
Run ". /etc/profile" to update the variable in your shell.

After logging in again, or typing source /etc/profile in the current shell, the new system editor will be active.

Note that if you want to use vim instead of a vi through busybox you also need to run:

root # eselect vi set vim

Profiles

You may have heard that Funtoo Linux and Gentoo Linux are metadistributions, which means that rather than being a one-size-fits-all kind of Linux, they allow you to customize your system to your liking. We have already taken a look at USE variables, and there are also various other settings that can affect the features that are installed when you emerge a package.

In Funtoo Linux, we have a system of profiles which can be used to enable various useful settings at once. In fact, a number of profiles are already enabled on your system. For example, on my desktop system, typing epro show produces the following output:

=== Enabled Profiles: ===

        arch: x86-64bit
       build: current
     subarch: generic_64
      flavor: desktop
     mix-ins: gnome
     mix-ins: hardened


=== All inherited flavors from desktop flavor: ===

                     workstation (from desktop flavor)
                            core (from workstation flavor)
                         minimal (from core flavor)

=== All inherited mix-ins from desktop flavor: ===

                               X (from workstation flavor)
                           audio (from workstation flavor)
                             dvd (from workstation flavor)
                           media (from workstation flavor)
      mediadevice-audio-consumer (from media mix-in)
                mediadevice-base (from mediadevice-audio-consumer mix-in)
      mediadevice-video-consumer (from media mix-in)
                mediadevice-base (from mediadevice-video-consumer mix-in)
        mediaformat-audio-common (from media mix-in)
          mediaformat-gfx-common (from media mix-in)
        mediaformat-video-common (from media mix-in)
                  console-extras (from workstation flavor)
                           print (from desktop flavor)

In case you're curious, these various profile settings live within /usr/portage/profiles/funtoo/1.0/linux-gnu. You can find the profile settings for (inherited) mix-in X by looking in /usr/portage/profiles/funtoo/1.0/linux-gnu/mix-ins/X, for example.

Under the list of Enabled profiles, you'll see that I have an x86-64bit arch profile. In Funtoo Linux, all systems have a single arch profile defined, and this is where settings specific to your system architecture are defined. Besides the architecture, there is also a sub-architecture profile, which allows you to enable builds options which make the system even more optimised towards the specific set of CPU instructions you might have at your disposal. Like in case of architecture, only a single sub-architecture can be defined at any time for a single system. In addition, I have a build profile of current. All Funtoo Linux systems have a single build profile defined, and this tells Portage what masks to apply to the Portage tree -- in other words, what selection of packages you will have available to emerge. If you are using funtoo-stable, your build profile will be stable and you will have a more limited set of packages that you can merge by default -- the stable set.

You will also see that I have a flavor profile. Unlike the arch, subarch, and build profiles, which should not be changed, you can choose another flavor if you want. In fact, we encourage you to do so. The flavor is used to define the general type of system you are creating. You can only have one flavor profile enabled, and since this command was run on a desktop-type system, I have enabled the desktop flavor. This enables a variety of settings, primarily USE flags, suitable for desktop systems.

You'll also see that I have a couple of mix-ins (explicitly) enabled. In Funtoo Linux, you can have zero or more mix-ins enabled -- I have gnome enabled, which sets various settings that are optimal for the use of the GNOME desktop environment, and then I am also using the hardened mix-in, since I have set up a so-called "hardened" system with various protections against malicious attacks.

   Tip

Take advantage of Funtoo Linux's enhanced Media mix-ins to help you easily get the level of media support you want for your system.

Followed by the general information about enabled profiles and mix-ins come two lists - one showing any number of flavors that are inherited by the flavor you picked within profile settings, and one showing a listing of all the different mix-ins that got pulled-in by the flavor you have selected. As you can see, the desktop flavor itself inherits (and builds upon) flavors workstation, core, and minimal. On the other hand, all of these different flavors pull in a number of mix-ins. Each mix-in shows which flavor has pulled it in. For example, the X mix-in comes with the workstation flavor, while the print mix-in comes from the desktop flavor. Some mix-ins are pulled-in by other mix-ins, as you can see for the mix-in mediaformat-audio-common - which is pulled-in by the media mix-in (which, in turn, is pulled in by the workstation flavor).

For now, it is not necessary to get too deep into profiles, but if you are creating a desktop system, I suggest you set the desktop flavor. To do this, type the following command as the root user:

root # epro profile desktop

You will now have the desktop flavor set for your system. Type epro show to see your new settings.

Updating your system

Sometimes, you may want to update the packages on your system. Often, this is done after you run emerge --sync, which will grab Portage tree updates from the main Funtoo Linux Portage tree:

root # emerge --sync

>>> Starting git pull...
remote: Counting objects: 1791, done.        
remote: Compressing objects: 100% (206/206), done.        
remote: Total 980 (delta 811), reused 931 (delta 764)        
Receiving objects: 100% (980/980), 185.04 KiB, done.
Resolving deltas: 100% (811/811), completed with 754 local objects.
From git://github.com/funtoo/experimental-mini-2011
   7a17140..b836bc8  funtoo.org -> origin/funtoo.org
Updating 7a17140..b836bc8
Fast-forward
>>> Git pull in /usr/portage successful

 * IMPORTANT: 1 news items need reading for repository 'gentoo'.
 * Use eselect news to read news items.

root # 

You may also want to update your system after you have changed USE flag settings. To take advantage of the USE flags you have just enabled, it's necessary to recompile everything that includes them.

Below, you'll find a recommended emerge command for updating your entire system. The -a option will cause emerge to prompt you for confirmation before starting the merge:

root # emerge -auDN world

-u tells emerge to update any already-installed but out-of-date packages that we specify on the command-line. The -D option tells emerge to perform a deep dependency tree graph, so it will include sub-dependencies of packages that we have specified on the command line as well. This allows emerge to perform as thorough an update of your system as possible.

The -N (--newuse) option tells Portage to check for any new USE flags that have been enabled or disabled, and rebuild packages so that all USE flags are set as currently defined in /etc/make.conf and /etc/portage/package.use.

world is a "meta-package" or "package set" which includes every package that you have manually installed plus all packages in the system set. It's important to note that whenever you ask emerge to install anything, such as metalog or vim, those packages will be automatically added to the world package set. In this way, emerge learns what packages you care about and want to keep updated. If you want to see what's in your world package set, take a look at /var/lib/portage/world:

root # cat /var/lib/portage/world
app-editors/vim
app-portage/eix
app-portage/gentoolkit
dev-vcs/git
net-misc/bridge-utils
net-misc/dhcpcd
net-misc/keychain
sys-apps/gptfdisk
sys-apps/pciutils
sys-devel/bc
sys-fs/reiserfsprogs
sys-kernel/vanilla-sources

Also note that some packages may have been added to the world set by Metro when your stage3 tarball was built.

Updating a few packages

If we simply wanted to rebuild a few packages to reflect updated USE flag settings, we could specify it instead of world. Be sure to include the -N option:

root # emerge -auDN vim emacs

Useful applications for daily usage

Here are some other packages you may want to consider installing via emerge:

app-misc/screen
Allows you to have persistent login sessions.
app-misc/tmux
Similar to screen -- some people prefer it.
app-admin/sudo
Grant root privileges to selected users and command combinations.
sys-process/htop
Colorful and informative text-based process list.
sys-process/glances
Similar to htop, includes disc I/O and network I/O in display.
app-portage/eix
Quick portage package search
app-portage/gentoolkit
Portage utils
app-misc/mc
GNU Midnight Commander is a text based file manager --- some will recall MS-DOS XtreeGold
app-text/wgetpaste
Command-line interface to various pastebins; very useful in providing info along with bugs reports
net-irc/irssi
A modular textUI IRC client with IPv6 support; a powerful tool to get help from Funtoo Community on IRC channel. Nice companion to app-text/wgetpaste
root # emerge --jobs app-misc/screen sudo htop eix gentoolkit app-misc/mc wgetpaste net-irc/irssi

Creating a user account

It's a good idea to create a normal user account that you can use for general Linux tasks. Before rebooting, create a user account for everyday use. Adjust the groups in the example below to match your needs. Some of them may not exist yet on your system. Replace "<user_name>" with the name you're going to use for your everyday user. The "-m" option instructs useradd to create a home directory for your user. See man useradd for more info.

root # useradd -m -g users -G audio,video,cdrom,wheel <user_name>

Don't forget to set a password for your new user:

root # passwd <user_name>

Installing a graphical environment

If you intend on using your Funtoo Linux installation for more than system administration, chances are you're going to want to have a GUI (graphical user interface). In the past, setting one up involved wading through text files and man pages. Thanks to modern tools like udev this is no longer the case.

Unlike most operating systems, Funtoo does not ship with a GUI pre-installed. If you've used Windows or Mac OS, you'd also know that their interfaces cannot be replaced easily. With Linux, the opposite is true -- you are free to choose from a huge selection of GUIs. From window managers such as Blackbox, IceWM, and xmonad, to fully-featured desktop environments like GNOME and KDE, the possibilities are vast in number.

The first step in setting up a graphical environment is to set up the X Window System. Then, you will be able to install the graphical environment of your choice. GNOME is a popular option for new users.