Genkernel/ko

genkernel is used to automate the build process of the kernel and initramfs. Some of the general features include:
 * Configuring the kernel sources;
 * Building the compressed kernel and copying it to
 * Creating an initramfs and copying it to
 * Creating symlinks in
 * Adding custom content to the initramfs such as encryption related files, boot splash images, extra modules, and more;
 * Compressing the initramfs;
 * Configuring the bootloader.

설치
이렇게 하고 나면 genkernel 프로그램 설치를 진행할 수 있습니다.

Genkernel 실행
genkernel 실행 일반 명령 형태는 다음과 같습니다:

옵션
The actual behavior of genkernel depends on a large variety of options, the majority of which can be set/unset in the file or passed via the genkernel command on each invocation. Options passed over the command line take precedence over options defined in. The configuration file is very well documented, however some of the most commonly used options will be explored in this article. The goal is for the reader to be familiar with common genkernel invocations. For a more complete set of explanations refer to the comments in itself or to the output of the man genkernel command.

Options acting on user interactivity
The configuration options listed below help the user decide how to interact with the configuration process. Users can even choose whether or not the configuration file created in the process should be saved. The following are considered primary configuration options:

Options acting on the resulting system
The configuration options listed here defines which features will or will not be enabled in the resulting kernel and initrd.

Options acting on the choice of the tools used for building
The following options are supported by genkernel, and are passed to the relevant applications while the kernel is being assembled. These options affect the compiling tools used for the kernel compilation process, albeit at a much lower level.

Options acting on the compilation process
The following options usually take effect during the actual compilation:

Debugging options
The use of debugging options during the kernel compilation process controls the amount of information reported, as well as the presentation of said data.

동작
The action passed on the command line with the genkernel [options …] action tells genkernel what action to perform. The following actions are supported:


 * all
 * Builds all stages — the initrd, kernel image and modules.


 * bzImage
 * Only builds the kernel image.


 * kernel
 * Only builds the kernel image and modules.


 * initramfs
 * Only builds the initramfs/ramdisk image.


 * ramdisk</tt>
 * Only builds the initramfs/ramdisk image.

첫 Genkernel 실행
genkernel을 실행하는 방법에는 여러가지가 있지만, 대부분 사용자에게 덜 거슬리는 방법은 genkernel all 명령입니다. 여기서 대부분의 시스템에서 동작하는 일반 설정을 사용합니다. 앞서 언급했듯이 이 방식은 문제가 없는것이 아닙니다. 대부분의 사용자에게 불필요한 모듈을 만들어내며 컴파일 시간이 길어집니다. 아래에 제시한 방법은 루트 계정으로 genkernel에 각각의 옵션을 전달하여 효율적인 방법을 달성할 수 있음을 나타냅니다.

The above operation causes genkernel to create a framebuffer splash-enabled kernel that will have to be manually installed. While preparing the kernel source tree, genkernel will refrain from cleaning out any preexisting object files present in the source tree. A menu-driven kernel configuration utility will be displayed that allows the user to select which modules will be built for the system.

Replacing  with the   option allows genkernel to automatically install the new kernel in the  directory, and will create symlinks if   is specified. Using the  option allows genkernel to mount the  partition automatically, if necessary.

커널을 바꿀 때 Genkernel 사용
The first thing that should be done is to allow the triggering of make menuconfig</tt> in the file:

File Management by genkernel
While using genkernel, the user has to be aware of some aspects relating to kernel configuration and kernel image files management and the way the kernel sources are handled by the system.

genkernel에서 사용하는 소스 파일
After an emerge -u gentoo-sources</tt>, whenever new sources are available, a new kernel source directory is created under to host them. Normally, the active kernel sources directory is pointed to by the symlink.

디렉터리는 다음과 같을지도 모릅니다:

심볼릭 링크는 다양한 방법으로 바꿀 수 있습니다.

에  USE 플래그를 설정하면, 이머지한 새로운 소스로  심볼릭 링크를 자동으로 업데이트합니다.


 * If the  USE is not set, the user can change the destination of the symlink using the eselect kernel list</tt> followed by the eselect kernel set</tt> command.

Genkernel will always use the sources pointed by the symlink.

genkernel에서 사용하는 커널 설정 파일
If a kernel compilation has already been run with the active kernel sources, there might be a file inside the directory that contains the kernel configuration that has been applied while creating the last bzimage of the kernel. This file is named, for example where x86_64 might be substituted with the system's architecture, 3.7.9 might be substituted with the version of the sources used and r1 with the release of the sources.

It is this file that is used as a starting configuration when running  genkernel --menuconfig all</tt>.

If it is the first time that genkernel is run with the new kernel sources, or if the previous result has not been saved, this file is substituted with a default configuration file that resides at where x86_64 is substituted with the actual architecture.

컴파일한 설정 저장
If the  genkernel option is activated, either from the command line or inside, the compiled kernel configuration is saved (with the name given above) into the  directory. At the same time, the configuration is saved in the file in  directory but this file is not reused on the next genkernel all</tt> run.

/boot 디렉터리에 커널과 initramfs 설치
Specifying the  option when invoking genkernel, will ask genkernel to install the kernel image and the initramfs into the  directory. In order to run  a convenient manner, set the following in the  file:


 * 첫번째 매개변수는 그 자체를 의미합니다.


 * The second parameter tells genkernel to save the compiled kernel configuration into


 * The last two options tell genkernel to automatically update the grub configuration. In practice, the following happens:
 * If a previous kernel image with the same name already exist, it is renamed by appending to its name. A symlink  is automatically created that points to it.
 * The new kernel takes the place of any kernel with the same name into . If it is the first time a kernel is compiled, a symlink kernel is automatically created that points to the new kernel.

After running genkernel --menuconfig all</tt>, the directory might look like this:

부트로더 설정
The symlinks presented above in the bootloader's configuration can be used so that, even if the new kernel is not bootable, the user can always boot on the old one.

To allow the kernel and intird provided by genkernel to run correctly, provide a minimum information in bootloader's configuration file :
 * Add  to the kernel parameters passed to the kernel image, where  points to the root partition.
 * If splash is used, add a suitable mode line such as  to the parameters passed to the kernel and also add   or   depending on the verboseness required through the boot process.
 * Add the initrd information as required by the bootloader. Consult the Bootloader Configuration Chapter of the Gentoo Handbook for details on how to make the bootloader initrd-aware.

Here is how the file might look.

작업 파일 보존
The genkernel application automatically saves new changes to the files. If previous changes are to be preserved, then the following actions need to be taken.


 * The first file to preserve is the kernel configuration file in If the source has not changed prior to the recompilation of the kernel, the previously used name for this file will be used. So copying the previous configuration file under a different name helps in preserving the information while keeping the file available as a starting point for a new configuration.


 * The second important thing is to preserve the already bootable kernel and initramfs images. The way to accomplish this depends on the context:
 * If the last kernel compiled is bootable, running genkernel will rename this kernel (and similarly initramfs) image to and create a new . This mean that even if the new kernel is not bootable, users will always be able to boot the old one.
 * If the last kernel compiled is not bootable and sources haven't changed since the user compiled a bootable one, prior to running genkernel, first delete the new kernel image and remove the .old</tt> suffix from the last bootable one. Without this, if the newly compiled kernel is not bootable for the second time, the bootable will be kicked out by the renaming of the non bootable, giving the user an unbootable system. Use the same reasoning for initramfs.

소스를 바꿀 떄 이전 커널 설정 사용
The previous configuration can be used through the make menuconfig</tt> option in as follows:

설치 CD에서 Genkernel로 네트워크 부팅하기
The genkernel utility can build kernel and initrd images that provide support for network booting, or netbooting. With any luck, users should be able to netboot any recent computer into the environment provided by the Installation CD.

The magic lies in genkernel's linuxrc script: it will try to netmount the Installation CD using NFS. From there, the init scripts of the Installation CD can take over, as if the CD was present locally.

넷부팅을 지원하는 커널과 Initrd 이미지 빌드
넷부팅 지원을 활성화하려면, 커널을 설정할 때 다음 옵션을 포함하십시오:

우선 커널 이미지에 네트워크 인터페이스 카드(NIC) 드라이버가 들어가야합니다. 보통 각 장치의 드라이버는 모듈로 컴파일합니다. 그러나 (넷부팅시) 이런 드라이버는 모듈 방식이 아니라 커널 이미지에 바로 포함시키는 것이 중요합니다.

&lt;M&gt;</tt>이 아닌 &lt;*&gt;</tt> 로 선택했는지 확인하십시오.

다음 IP: DHCP support options와 IP: kernel level autoconfiguration을 활성화 하는것이 좋겠습니다. IP 주소와 설치 CD의 NFS 경로를 DHCP서버에서 설정할 수 있기 때문에, 계층 복잡화를 막습니다. 물론 커널 명령줄이 어떤 머신에서든 있는 그대로 남아있음을 의미합니다. 이더부팅 기능에 있어 이점이 상당히 중요합니다.

이 옵션은 부팅 과정에서 커널에게 DHCP 요청을 보내라고 알려줍니다.

또한, 최근의 젠투 설치 CD에서 필요하므로 SquashFS를 활성화하십시오. SquashFS 지원은 일반 커널 소스트리에 없습니다. SquashFS를 활성화하려면 일반 커널 소스를 패치하거나 gentoo-sources를 설치하십시오.

컴파일 과정이 끝나면, 커널 모듈이 들어간 압축 타르볼을 만드십시오. 이 과정은 커널 버전이 설치 CD의 커널 이미지 버전과 일치하지 않을때만 필요합니다.

모든 모듈이 들어간 아카이브를 만들려면:

네트워크 부팅 매커니즘에 따라 하나 이상의 단계를 따라야합니다:

이더부트 이미지를 만들려면:

OpenBoot / SPARC64 TFTP 이미지를 만들려면:

파일은 부트 이미지입니다.

Finally, copy this kernel to the TFTP server. The details are architecture-dependent and are beyond the scope of this guide. Please refer to the documentation for the specific platform of interest.

NFS 설정
To setup a NFS share that contains the Installation CD, use the loop device to mount the ISO image and then copy the contents of the CD into the NFS share. As a nice extra, genkernel's initrd scripts will extract all tar.gz files located in the directory. All that needs to be done here is copy the archive to the  directory.

다음 예제에서는 를 내보내는 NFS 공유로 가정합니다:

이제 파일을 에 복사하십시오:

DHCP 설정
netbook 이미지에서는 root-path</tt> 매개변수와 같이 IP를 받기 위한 네트워크의 DHCP 서버를 요청합니다. 머신을 식별한 MAC 주소를 사용하여 호스트별로 지정할 수 있습니다:

넷부팅 절차
Netbooting itself is again very platform-specific. The important part is to specify the  and   parameters on the kernel command line, as this will bring up the network interface and tell the initrd scripts to mount the Installation CD via NFS. Here are some platform-specific tips.

For etherboot, insert the etherboot disk into the drive and reboot. The kernel command line was specified when the image was constructed. With Sparc64, hit - at the boot prompt and enter:

For PXE, setup pxelinux (part of syslinux), then create a along the lines of:

도입부
If an initramfs is installed with genkernel, then take a look at the various boot options that can (or should) be defined in the bootloader configuration. The most common ones are added to this guide.

LVM 또는 소프트웨어-RAID 불러오기
If the system uses LVM or software-RAID, the initramfs has to be built using the  and   options. Do not forget to enable support during boot as well. This can be done using the dolvm and domdadm options.

단일 사용자 모드 부팅
어떤 이유로 인해 부팅에 실패했다면 단일 사용자 모드로 부팅하여 시스템을 복구할 수 있습니다. 이 방법은 서비스를 불러올때만 필요하며 과정이 끝나면 복구(루트) 쉘에서 사용자를 쫒아냅니다.