Difference between pages "LXC Fun" and "Install/pt-br/Kernel"

From Funtoo
(Difference between pages)
Jump to navigation Jump to search
 
 
Line 1: Line 1:
Linux Containers, or LXC, is a Linux feature that allows Linux to run one or more isolated virtual systems (with their own network interfaces, process namespace, user namespace, and power state) using a single Linux kernel on a single server.  To learn more take a look at the [[LXC]] article.
=== Configurando e instalando o kernel Linux ===


In this Howto you will be shown how to create containers, how to start, stop, freeze and unfreeze them and also some more fun parts like snapshoting and clonig. To have all this working you will have to have your lxc store (/var/lib/lxc/ and /var/lib/lxcsnaps) to be on a '''btrfs filesystem'''.
Agora é hora de construir e instalar um kernel Linux, o qual é o coração de qualquer sistema Funtoo Linux. O kernel é carregado pelo boot loader, e interfaces diretamente com o hardware do seu sistema, e permite programas regulares (userspace) serem executador.


__TOC__
Um kernel deve ser configurado propriamente para o hardware do seu sistema, desse modo ele suporta seus hard drives, file systems, placas de rede, e assim por diante. Usuários de Linux mais experientes pode escolher instalar o kernel sources e configurar e instalar seu próprio kernel. Se você não sabe como fazer isso, nós fornecemos ebuilds que construirão automaticamente um kernel "universal", módulos e initramfs para a inicialização do seu sistema que suporte todo o hardware. Esse é um jeito extremamente simples de construção de um kernel que colocará seu sistema para inicializar.


== Creating containers ==
Qual é o nosso objetivo? Para construir um kernel que reconhecerá todo o hardware em seu sistema necessário para inicialização, você será cumprimentado por um prompt de login amigável depois que a instalação estiver completa. Esses instruções lhe guiarão através do processo de instalação de um kernel no modo "fácil" -- sem exigir configuração do usuário, ao utilizar um kernel "universal".
Creating containers is quite easy using lxc-templates. They are located in the /usr/share/lxc/templates directory. You can find there many distributions like archlinux, centos, debian, fedora, opensuse, ubuntu, gentoo and some more. There is also an inofficial funtoo template that can be found at https://github.com/golodhrim/lxc-funtoo/blob/master/lxc-funtoo. The script creates funtoo container, however I was not able to use it with lxc-create script from the lxc utils. You have to run it as a stand-alone script.


So how do you create other containers? I am going to use a debian container for this purpose. You will have to emerge debootstrap.
==== Package Sets ====


<console>
Antes que estalemos um kernel, vamos cobrir um recurso do Portage chamado package sets. Portage, o sistema gerenciador/ports de pacotes para o Funtoo Linux, manterá rastro de pacotes do sistema assim como pacotes que você tem instalado ao invocar <code>emerge</code> diretamente. Esses pacotes que são parte do sistema base são considerados parte do conjunto de pacote do "sistema", enquanto pacotes que você tem instalado ao digitá-los na linha de comando (tal qual "gnome" em <code>emerge gnome</code>) serão adicionados ao conjunto de pacote "world". Isso proporciona um jeito fácil de atualizar o sistema inteiro.
###i## emerge -av debootstrap


* IMPORTANT: 8 news items need reading for repository 'gentoo'.
No entanto, as vezes é bom ser capaz de atualizar o kernel todo por sim só, ou deixar uma atualização do kernel fora da sua regular atualização completa do sistema. Para fazer isso, criaremo uma nova configuração de pacote chamada "kernel".
* Use eselect news to read news items.


==== Configuração de Pacote do Kernel ====


These are the packages that would be merged, in order:
Para criar a configuração de pacote do kernel, realize os seguintes passos:


Calculating dependencies... done!
<console>
[ebuild  N    ] dev-perl/TimeDate-2.300.0  31 kB
(chroot) # ##i##mkdir /etc/portage/sets
[ebuild  N    ] app-arch/dpkg-1.17.10  USE="bzip2 lzma nls unicode update-alternatives zlib -dselect {-test}" 4,100 kB
(chroot) # ##i##echo sys-kernel/debian-sources > /etc/portage/sets/kernel
[ebuild  N    ] dev-util/debootstrap-1.0.59  96 kB
</console>


Total: 3 packages (3 new), Size of downloads: 4,226 kB
Agora, vamos querer definir uma variável USE para dizer ao <code>debian-sources</code> que construa um kernel "universal" e o initramfs para nós, para levar Funtoo Linux a funcionamento na inicialização. Para fazer isso, vamos configurar a variável <code>binary</code> USE para <code>debian-sources</code>, como a seguir:


Would you like to merge these packages? [Yes/No]
<console>
(chroot) # ##i##echo "sys-kernel/debian-sources binary" >> /etc/portage/package.use
</console>
</console>


After installing debootstrap, you can create your debian container using:
Se as varáveis USE forem novas para você, você estará se familiarizando com elas um pouco mais enquanto utiliza o Funtoo Linux. At their essence, ela são "switches" que você pode definir para configurar opções que podem ser construídas em vários pacotes. Elas são utilizadas para assim personalizar seu Funtoo Linux system para que conheça as suas exatas necessidades. We added support for a <code>binary</code> USE flag to the <code>debian-sources</code> ebuilds, as well as a few other of our kernel ebuilds, to make it easier for new users to get Funtoo Linux up and running.


<console>
Now, when we just want to update our system's packages, we'll type <code>emerge -auDN @world</code>, and it will update our world set, leaving out the kernel. Likewise, when we just want to update our kernel, we'll type <code>emerge -au @kernel</code>, and it will update our kernel, leaving out the world set.
###i## lxc-create -B btrfs -n vm1 -t debian
 
debootstrap is /usr/bin/debootstrap
==== Building the Kernel ====
Checking cache download in /var/cache/lxc/debian/rootfs-wheezy-armhf ...
Copying rootfs to /var/lib/lxc/vm1/rootfs...Generating locales (this might take a while)...
  en_US.UTF-8... done
Generation complete.
update-rc.d: using dependency based boot sequencing
update-rc.d: using dependency based boot sequencing
update-rc.d: using dependency based boot sequencing
update-rc.d: using dependency based boot sequencing
Creating SSH2 RSA key; this may take some time ...
Creating SSH2 DSA key; this may take some time ...
Creating SSH2 ECDSA key; this may take some time ...
invoke-rc.d: policy-rc.d denied execution of restart.
Timezone in container is not configured. Adjust it manually.
Root password is 'root', please change !
</console>


We will see that the lxc-create command created a subvolume on BTRFS backing file system.
{{Fancynote|1=
<console>
See [[Funtoo Linux Kernels]] for a full list of kernels supported in Funtoo Linux. We recommend <code>debian-sources</code> for new users.}}
###i## btrfs sub list /
---- snip ----
ID 1143 gen 437 top level 5 path /var/lib/lxc/vm1/rootfs
---- snip ----
</console>


Now you are ready to do all the fun stuff with your LXCs.
{{fancyimportant|1=
<code>debian-sources</code> with <code>binary</code> USE flag requires at least 14GB free in <code>/var/tmp</code> and takes around 1 hour to build on a Intel Core i7 Processor.}}


== Starting/stoping containers ==
Let's emerge our kernel:
To start a previously created container use the lxc utils:


<console>
<console>
###i## lxc-start -n vm1 -d
(chroot) # ##i##emerge -1 @kernel
###i## lxc-info -n vm1
Name:          vm1
State:          RUNNING
PID:            29742
IP:            172.16.65.234
CPU use:        2.92 seconds
BlkIO use:      260.00 KiB
Memory use:    2.99 MiB
KMem use:      0 bytes
Link:          vethTN4NGU
TX bytes:      2.33 KiB
RX bytes:      39.54 KiB
Total bytes:  41.87 KiB
###i## lxc-attach -n vm1
###r## root@vm1:~#
###r## root@vm1:~# exit
###i## lxc-stop -n vm1
Name:          vm1
State:          STOPPED
</console>
</console>


== Freezing/unfreezing containers ==
{{Important|Right now, the <code>-1</code> option is required to not add our <code>@kernel</code> set to <code>world-sets</code>. This allows you to emerge it independently from @world. If you forget to use this option, edit <code>/var/lib/portage/world-sets</code> and remove the <code>@kernel</code> line. This will prevent kernel updates from being included in @world updates.}}
The command lxc-freeze freezes all the processes running inside the container. The processes will be blocked until they are explicitly thawed by the lxc-unfreeze command. To freeze a previously started container use the lxc utils:
 
Note that while use of the <code>binary</code> USE flag makes installing a working kernel extremely simple, it is one part of Funtoo Linux that takes a ''very'' long time to build from source, because it is building a kernel that supports ''all'' hardware that Linux supports! So, get the build started, and then let your machine compile. Slower machines can take up to several hours to build the kernel, and you'll want to make sure that you've set <code>MAKEOPTS</code> in <code>/etc/portage/make.conf</code> to the number of processing cores/threads (plus one) in your system before starting to build it as quickly as possible -- see the [[#/etc/portage/make.conf|/etc/portage/make.conf section]] if you forgot to do this.


<console>
{{fancynote|NVIDIA card users: the <code>binary</code> USE flag installs the Nouveau drivers which cannot be loaded at the same time as the proprietary drivers, and cannot be unloaded at runtime because of KMS. You need to blacklist it under <code>/etc/modprobe.d/</code>.}}
###i## lxc-freeze -n vm1
###i## lxc-info -n vm1
Name:          vm1
State:          FROZEN
PID:            6817
IP:            172.16.65.234
CPU use:        2.78 seconds
BlkIO use:      0 bytes
Memory use:    2.47 MiB
KMem use:      0 bytes
Link:          veth7E1J8R
TX bytes:      1.45 KiB
RX bytes:      3.85 KiB
Total bytes:  5.31 KiB
###i## lxc-unfreeze -n vm1
###i## lxc-info -n vm1
Name:          vm1
State:          RUNNING
PID:            6817
IP:            172.16.65.234
CPU use:        2.78 seconds
BlkIO use:      0 bytes
Memory use:    2.47 MiB
KMem use:      0 bytes
Link:          veth7E1J8R
TX bytes:      1.58 KiB
RX bytes:      11.13 KiB
Total bytes:  12.71 KiB
</console>


== Clones and snapshots  ==
{{fancynote|For an overview of other kernel options for Funtoo Linux, see [[Funtoo Linux Kernels]]. There may be modules that the Debian kernel doesn't include, a situation where [http://www.funtoo.org/wiki/Funtoo_Linux_Kernels#Using_Debian-Sources_with_Genkernel genkernel] would be useful. Also be sure to see [[:Category:Hardware Compatibility|hardware compatibility]] information.}}
... tbc ...


[[Category:Virtualization]]
Once <code>emerge</code> completes, you'll have a brand new kernel and initramfs installed to <code>/boot</code>, plus kernel headers installed in <code>/usr/src/linux</code>, and you'll be ready to configure the boot loader to load these to boot your Funtoo Linux system.

Revision as of 18:39, February 25, 2015

Configurando e instalando o kernel Linux

Agora é hora de construir e instalar um kernel Linux, o qual é o coração de qualquer sistema Funtoo Linux. O kernel é carregado pelo boot loader, e interfaces diretamente com o hardware do seu sistema, e permite programas regulares (userspace) serem executador.

Um kernel deve ser configurado propriamente para o hardware do seu sistema, desse modo ele suporta seus hard drives, file systems, placas de rede, e assim por diante. Usuários de Linux mais experientes pode escolher instalar o kernel sources e configurar e instalar seu próprio kernel. Se você não sabe como fazer isso, nós fornecemos ebuilds que construirão automaticamente um kernel "universal", módulos e initramfs para a inicialização do seu sistema que suporte todo o hardware. Esse é um jeito extremamente simples de construção de um kernel que colocará seu sistema para inicializar.

Qual é o nosso objetivo? Para construir um kernel que reconhecerá todo o hardware em seu sistema necessário para inicialização, você será cumprimentado por um prompt de login amigável depois que a instalação estiver completa. Esses instruções lhe guiarão através do processo de instalação de um kernel no modo "fácil" -- sem exigir configuração do usuário, ao utilizar um kernel "universal".

Package Sets

Antes que estalemos um kernel, vamos cobrir um recurso do Portage chamado package sets. Portage, o sistema gerenciador/ports de pacotes para o Funtoo Linux, manterá rastro de pacotes do sistema assim como pacotes que você tem instalado ao invocar emerge diretamente. Esses pacotes que são parte do sistema base são considerados parte do conjunto de pacote do "sistema", enquanto pacotes que você tem instalado ao digitá-los na linha de comando (tal qual "gnome" em emerge gnome) serão adicionados ao conjunto de pacote "world". Isso proporciona um jeito fácil de atualizar o sistema inteiro.

No entanto, as vezes é bom ser capaz de atualizar o kernel todo por sim só, ou deixar uma atualização do kernel fora da sua regular atualização completa do sistema. Para fazer isso, criaremo uma nova configuração de pacote chamada "kernel".

Configuração de Pacote do Kernel

Para criar a configuração de pacote do kernel, realize os seguintes passos:

(chroot) # mkdir /etc/portage/sets
(chroot) # echo sys-kernel/debian-sources > /etc/portage/sets/kernel

Agora, vamos querer definir uma variável USE para dizer ao debian-sources que construa um kernel "universal" e o initramfs para nós, para levar Funtoo Linux a funcionamento na inicialização. Para fazer isso, vamos configurar a variável binary USE para debian-sources, como a seguir:

(chroot) # echo "sys-kernel/debian-sources binary" >> /etc/portage/package.use

Se as varáveis USE forem novas para você, você estará se familiarizando com elas um pouco mais enquanto utiliza o Funtoo Linux. At their essence, ela são "switches" que você pode definir para configurar opções que podem ser construídas em vários pacotes. Elas são utilizadas para assim personalizar seu Funtoo Linux system para que conheça as suas exatas necessidades. We added support for a binary USE flag to the debian-sources ebuilds, as well as a few other of our kernel ebuilds, to make it easier for new users to get Funtoo Linux up and running.

Now, when we just want to update our system's packages, we'll type emerge -auDN @world, and it will update our world set, leaving out the kernel. Likewise, when we just want to update our kernel, we'll type emerge -au @kernel, and it will update our kernel, leaving out the world set.

Building the Kernel

   Note

See Funtoo Linux Kernels for a full list of kernels supported in Funtoo Linux. We recommend debian-sources for new users.

   Important

debian-sources with binary USE flag requires at least 14GB free in /var/tmp and takes around 1 hour to build on a Intel Core i7 Processor.

Let's emerge our kernel:

(chroot) # emerge -1 @kernel
   Important

Right now, the -1 option is required to not add our @kernel set to world-sets. This allows you to emerge it independently from @world. If you forget to use this option, edit /var/lib/portage/world-sets and remove the @kernel line. This will prevent kernel updates from being included in @world updates.

Note that while use of the binary USE flag makes installing a working kernel extremely simple, it is one part of Funtoo Linux that takes a very long time to build from source, because it is building a kernel that supports all hardware that Linux supports! So, get the build started, and then let your machine compile. Slower machines can take up to several hours to build the kernel, and you'll want to make sure that you've set MAKEOPTS in /etc/portage/make.conf to the number of processing cores/threads (plus one) in your system before starting to build it as quickly as possible -- see the /etc/portage/make.conf section if you forgot to do this.

   Note

NVIDIA card users: the binary USE flag installs the Nouveau drivers which cannot be loaded at the same time as the proprietary drivers, and cannot be unloaded at runtime because of KMS. You need to blacklist it under /etc/modprobe.d/.

   Note

For an overview of other kernel options for Funtoo Linux, see Funtoo Linux Kernels. There may be modules that the Debian kernel doesn't include, a situation where genkernel would be useful. Also be sure to see hardware compatibility information.

Once emerge completes, you'll have a brand new kernel and initramfs installed to /boot, plus kernel headers installed in /usr/src/linux, and you'll be ready to configure the boot loader to load these to boot your Funtoo Linux system.