Genkernel/ko

는 kernel과 initramfs 빌드를 자동화할 때 사용하려고 젠투에서 만든 도구입니다. 일부 기본 동작은 다음과 같습니다:


 * 커널 소스를 설정합니다.
 * 압축 커널을 만들고 에 복사합니다.
 * initramfs를 만들고 에 복사합니다.
 * 에 심볼릭 링크를 만듭니다.
 * initramfs에 암호화 관련 파일, 부팅 시작 이미지, 추가 모듈, 등의 개별 내용물을 넣습니다.
 * initramfs를 압축합니다.
 * bootloader를 설정합니다.

Emerge
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  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 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:

결과 시스템에서 동작하는 옵션
The configuration options listed here defines which features will or will not be enabled in the resulting kernel and initrd.

빌드할 도구를 선택할 때 동작하는 옵션
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.

컴파일 과정에서 동작하는 옵션
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 tells genkernel what action to perform. The following actions are supported:

시작하기
genkernel을 실행하는 방법에는 여러가지가 있지만, 대부분 사용자에게 덜 거슬리는 방법은 명령입니다. 여기서 대부분의 시스템에서 동작하는 일반 설정을 사용합니다. 앞서 언급했듯이 이 방식은 문제가 없는것이 아닙니다. 대부분의 사용자에게 불필요한 모듈을 만들어내며 컴파일 시간이 길어집니다. 아래에 제시한 방법은 루트 계정으로 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.

커널 바꾸기
The first thing that should be done is to allow the triggering of in the  file:

파일 관리
genkernel을 사용할 때 사용자는 커널 설정과 관련된 내용, 커널 이미지 파일 관리, 커널 소스를 시스템이 다루는 방법 등을 인지해야합니다.

소스 파일
After an, 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.

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

The symlink can be changed in different ways.


 * If the  USE is set the  symlink is automatically updated to point to the newly emerged sources.


 * If the  USE is not set, the user can change the destination of the symlink using the  followed by the  command.

genkernel will always (exclusively) 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   might be substituted with the system's architecture,   might be substituted with the version of the sources used, and   with the release of the sources.

It is this file that is used as a starting configuration when running .

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  run.

디렉터리에 커널과 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 first parameter speaks for itself.


 * 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, 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 (  is the number of the partition if a partition exists).
 * 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 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, first delete the new kernel image and remove the 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.

Using previous kernel configuration while changing the sources
The previous configuration can be used through the MENUCONFIG variable in as follows:

설치 CD로 네트워크 부팅하기
The 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 이미지 빌드
넷부팅 지원을 활성화하려면, 커널을 설정할 때 다음 옵션을 포함하십시오:

First, the kernel image must include the drivers for the system's Network Interface Cards (NIC). Normally, drivers for such devices will be compiled as modules. However, it is essential (for netbooting) that such drivers are compiled directly into the kernel image and not as modules.

다음 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 설정
The netboot images will ask the DHCP server on the network for an IP as well as a  option. Both can be specified per host using a MAC address to identify machines:

넷부팅 절차
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, press + at the boot prompt and then 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.

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

compile failed: Kernel not found
This failure can be experienced when attempting to compile a kernel for one architecture with a kernel file that has a target of a different architecture than the target. This could be as simple as a machine running an kernel attempting to compile for a  target.

This can be experienced when booting from a x86_64 LiveCD on a system that is capable of operating in 64-bits, however the target to be installed or repaired is 32-bits. After the compilation process begins, will attempt to automatically detect the architecture for the target based on the currently running kernel. If the currently running kernel is 64-bit, then, unless it is told otherwise, will presume it should be looking for a 64-bit kernel.

Suppose then that the kernel's file has x64 disabled. The command will execute and the resulting kernel binary will be placed in the associated  directory. When goes to install (move and rename) the kernel it cannot find the kernel because it expected a 64-bit kernel.

The solution to this failure is to set 's  option to, in this case, the  architecture. The final command could look like this:

To override the architecture choice permanently, modify the ARCH_OVERRIDE variable in the file.