Genkernel/ko

From Gentoo Wiki
Jump to:navigation Jump to:search
This page is a translated version of the page Genkernel and the translation is 47% complete.
Outdated translations are marked like this.

genkernel커널initramfs 빌드를 자동화할 때 사용하기 위해 젠투에서 만든 도구입니다. 일부 일반 기능은 다음과 같습니다:

  • 커널 소스를 설정합니다.
  • bzImage 압축 커널을 만들고 /boot 에 복사합니다.
  • initramfs를 만들고 /boot에 복사합니다.
  • /boot에 심볼릭 링크를 만듭니다.
  • initramfs에 암호화 관련 파일, 부팅 시작 이미지, 추가 모듈, 등의 개별 내용물을 넣습니다.
  • initramfs를 압축합니다.
  • 부트로더를 설정하여 새로 만든 커널과 initramfs로 부팅합니다.
참고
개별 커널 설정을 genkernel이 "자동화"한다고 일반적으로 오해합니다. genkernel은 커널 빌드 과정을 자동화하며 initramfs를 조립하지만, 개별 커널 설정 파일을 만들지는 않습니다. 아키텍처별 기반 하위 시스템에서 보통 사용하는 설정을 갖춘 일반 커널 설정 파일을 사용합니다. 아키텍처 기본값에 대한 자세한 내용은 업스트림 저장소에서 볼 수 있습니다. 아키텍처와 커널 설정 파일을 선택하십시오.

설치

USE 플래그

USE flags for sys-kernel/genkernel Gentoo automatic kernel building scripts

firmware Prefer system firmware sys-kernel/linux-firmware over local copy.
ibm Add support for IBM ppc64 specific systems

Emerge

genkernel 설치를 시작하십시오:

root #emerge --ask sys-kernel/genkernel

사용법

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

root #genkernel [options ...] action

옵션

실제 genkernel의 동작은 상당히 다양한 옵션에 따라 달라지며, 주된 설정은 /etc/genkernel.conf 파일의 설정 변수를 설정/해제하거나 genkernel을 실행할 때마다 옵션을 전달하는 식으로 처리할 수 있습니다. 명령행으로 전달한 옵션은 /etc/genkerne.conf에 정의한 옵션보다 우선합니다. 설정 파일에는 설명이 잘 되어 있지만 대부분 옵션은 이 문서에서 찾아볼 수 있습니다. 이 문서의 작성 목적은 독자 여러분께서 일반적인 genkernel 실행에 익숙해지도록 하기 위함입니다. 더 완벽한 설명은 /etc/genkernel.conf 자체에서 찾아보시거나 man genkernel 출력 결과에서 살펴보십시오.

참고
일부 옵션은 반대 동작을 실행하는 변종 옵션이 있습니다. --[no-]option_name 같은 식으로 나타나며, 반대 효과는 다음 예제의 각 괄호로 나타냈습니다.
코드 각 옵션의 활성/비활성화
--[no-]menuconfig : Activates [deactivates] ...
이 옵션에서 반대 효과를 나타내는데 no-로 시작하는 부분, 그리고 결과가 선택의 여지가 아닌 경우 각괄호를 제외하고 표현합니다.

사용자와 상호작용시 동작하는 옵션

하단에 나타난 설정 옵션은 사용자 여러분께서 설정 단계를 어떻게 처리할 지 결정하는데 도움을 줍니다. 여러분은 설정 과정에서 저장할 파일을 저장할 지 말지를 결정할 수 있습니다. 다음 목록은 초기 설정 옵션으로 고려할 내용입니다:

--config=/path/to/genkernel.conf
사용할 Genkernel 설정 파일입니다(기본값: /etc/genkernel.conf).
--[no-]menuconfig
커널을 빌드하기 전에 make menuconfig 명령(대화실 설정 메뉴 화면)을 활성(또는 비활성) 합니다.
--gconfig
GTK+ 라이브러리 기반 커널 설정 화면을 제공합니다. 이 옵션은 X 윈도우 시스템을 기반으로 활용하므로 대부분의 사용자가 이 도구를 활용하여 커널을 쉽고 분명하게 설정할 수 있는 이점이 있습니다. 다만, 이 옵션을 활용하려면 X 윈도 시스템이 있어야 하기 때문에 명령행에서는 동작하지 않는 단점이 있습니다.
--xconfig
Qt 라이브러리 기반 커널 설정 화면을 제공합니다. 이 옵션은 X 윈도우 시스템을 기반으로 활용하므로 대부분의 사용자가 이 도구를 활용하여 커널을 쉽고 분명하게 설정할 수 있는 이점이 있습니다. 다만, 이 옵현을 활용하려면 X 윈도 시스템이 있어야 하기 때문에 명령행에서는 동작하지 않는 단점이 있습니다.
--[no-]save-config
추후 활용을 위해 /etc/kernels 경로에 커널 설정을 저장 할지[말지] 를 결정합니다.
--kernname=NickName
/boot 디렉터리의 커널 및 초기화 램 디스크 이미지 수정을 서용하여 만든 이미지의 이름을 kernel-NickName-versioninitramfs-NickName-version 이름을 가지게 합니다.

결과 시스템에 대해 동작하는 옵션

하단에 언급한 설정 옵션은 커널 및 초기화 램 디스크 결과물 도출상 어떤 특징(기능)을 활성화할 지 말 지 여부를 정의합니다.

--[no-]splash
genkernel에서 initrd 이미지에 만든 Fbsplash 프레임버퍼 시작 화면을 활성화(또는 비활성화) 합니다. fbsplash에서 사용하는 기본 테미를 사용하지 않으려면 --splash=PreferredTheme 옵션을 사용하십시오(PreferredTheme 자리에 /etc/splash 디렉터리에 있는 디렉터리 이름 중 제목 하나를 지정하면 됩니다).
--splash-res=PreferredResolution
이 옵션은 시스템을 시작할 때 initrd에서 지원하는 시작 화면의 해상도를 선택할 수 있게 합니다. 두가지 이유로 쓸만합니다. 첫째는 시스템과 관련있는 시작 화면 해상도를 선택할 수 있습니다. 두번째 이유로는, (initrd에서 시스템 설정과 관계없는 해상도를 지원하여) initrd에서 불필요한 디스크 공간이 늘어나는 일을 막습니다만, 설치 CD용으로 커널을 컴파일 한다면 없애버리는게 낫습니다. 이 옵션은 가능한 모든 해상도를 지원할 수 있습니다.
--do-keymap-auto
부팅 과정에서 키 배치 설정을 선택할 수 있게 강제합니다.
--lvm
논리 볼륨 관리자en (LVM2) 저장 장치가 시스템에 있는 경우 지원할 수 있도록 정적 바이너리를 포함합니다. 관련(정적) LVM2 바이너리가 없는 경우 컴파일합니다. 이 옵션을 활성화하기 전 시스템에 sys-fs/lvm2 꾸러미를 설치하고(emerge sys-fs/lvm2), 젠투 위키의 LVM 게시글을 살펴보십시오.
--dmraid
커널 장치 매퍼 하위 시스템을 활용하여 RAID 매핑을 만드는 DMRAID 지원을 포함합니다. DMRAIDen은 소프트웨어 RAID 셋(예: ATARAID)과 DOS 파티션을 발견하고, 활성/비활성하며 속성 값을 표시합니다.
--luks
리눅스 통합 키 설정(또는 LUKS) 지원 기능을 포함합니다. LUKS로 루트 파일 시스템을 포함한 장치 암호화를 할 수 있습니다. 부트로더의 crypt_root 값에 암호화 한 장치를 설정하십시오(그리고 root는 LUKS가 만든 비 암호화 장치여야합니다).
--disklabel
initrd에 디스크 레이블과 UUID 지원 기능을 추가합니다.
--iscsi
initrd에 iSCSI 지원 기능을 추가합니다.
--multipath
initrd에 Multipathen 지원 기능을 추가합니다.
--linuxrc=/path/to/the/linuxrc_file
사용자가 만든 linuxrc를 지정합니다. linuxrc는 커널 시작 단계에 실제 부팅 과정 수행 전 초기화 목적으로 사용하는 스크립트입니다. 기본 linuxrc 스크립트는 /usr/share/genkernel/ 디렉터리에 있습니다. 이 스크립트는 모듈화된 작은 커널로 부팅할 수 있게 합니다. 시스템에서 필요한 몇가지 드라이버(모듈)을 최소한으로 불러옵니다.
--cachedir=/path/to/alt/dir
커널을 컴파일할 때 사용하는 기본 캐시 위치를 우선 사용할 값을 지정합니다.
--tempdir=/path/to/new/tempdir
커널을 컴파일하는 동안 genkernel에서 사용할 임시 디렉터리 위치를 지정합니다.
--unionfs
initrd 이미지에 통합 파일 시스템en 지원 기능을 넣습니다.
--mountboot
Detects whether or not the /boot 디렉터리에서 제각기 다른 분할 공간을 마운트할 지 말지를 감지합니다. /etc/fstab 스크립트를 검사하여 (필요한 경우) 부팅 분할 공간을 마운트 할 방식을 결정합니다.

빌드할 도구를 선택할 때 동작하는 옵션

다음 옵션은 genkernel에서 지원하며, 커널을 구성하는 동안 관련 프로그램에 전달합니다. 이 옵션은 상당히 저수준에서이긴 하지만, 커널 컴파일 과정에서 컴파일 도구에 영향을 줍니다.

--kernel-cc=someCompiler
커널 컴파일 과정에 관여하는 컴파일러를 지정합니다.
--kernel-ld=someLinker
커널 컴파일 과정에 관여하는 링커를 지정합니다.
--kernel-as=someAssembler
커널 컴파일 과정에 관여하는 어셈블러를 지정합니다.
--kernel-make=someMake
커널 컴파일 과정에 관여하는 GNU make 유틸리티의 대안 수단을 지정합니다.
--utils-cc=someCompiler
지원 유틸리티 컴파일 과정에 관여하는 컴파일러를 지정합니다.
--utils-ld=someLinker
지원 유틸리티 컴파일 과정에 관여하는 링커를 지정합니다.
--utils-as=someAssembler
지원 유틸리티 컴파일 과정에 관여하는 어셈블러를 지정합니다.
--utils-make=someMake
지원 유틸리티 컴파일 과정에 관여하는GNU make 유틸리티의 대안 수단을 지정합니다.
--makeopts=-jX
커널(및 유틸리티)를 컴파일 하는 동안 make 유틸리티에서 처리할 수 있는 동시 스레드 수를 지정합니다. X 변수는 자유롭게 지정할 수 있지만 보통 시스템에서 사용하는 코어의 수에 1을 더하거나 시스템의 코어 수를 그냥 사용합니다. 따라서 하나의 코어를 사용하는 시스템이라면 보통 사용하는 값은 -j2 또는 -j1입니다. 반면에 두 개의 코어를 사용하는 시스템이라면 -j3 또는 -j2 옵션이 되겠습니다. (Hyper-Threading™ (HT) 기술을 적용하여, 커널에서 Symmetric Multi-Processing (SMP) 기능 지원을 활성화하고 사용할 수 있는 프로세서의 경우 두개의 코어를 지녔다고 간주할 수 있습니다.)

컴파일 과정에서 동작하는 옵션

다음 옵션은 보통 실제 컴파일을 수행하는 동안 영향을 줍니다:

--kerneldir=/path/to/sources/
/usr/src/linux/ 위치 대신 사용할 대체 커널 소스코드 위치를 지정합니다.
--kernel-config=/path/to/config-file
/path/to/sources/.config 기본 설정 파일 대신 사용할 커널 설정 파일을 지정합니다.
--module-prefix=/path/to/prefix-directory/
대신 사용할 커널 모듈 설치 위치 디렉터리의 앞부분(기본 경로는 /lib/modules 디렉터리)을 지정합니다.
--[no-]clean
커널을 컴파일 하기 전 make clean 명령 실행을 활성화(또는 비활성화)합니다. make clean 명령은 커널 소스 트리상 모든 객체 파일과 의존성을 제거합니다.
--[no-]mrproper
커널을 컴파일 하기 전 make mrproper 명령 실행을 활성화(또는 비활성화)합니다. 위에 make clean 명령을 언급한 바와 마찬가지로make mrproper 명령도 커널 소스 트리 상 모든 객체 파일과 의존성을 제거합니다. 다만 이전 설정 파일(/path/to/sources/.config 또는 /path/to/sources/.config.old) 도 커널 소스 트리에서 제거합니다. 커널의 .config 파일이 사라지는 일이 달갑지 않으면 이 옵션의 비활성화를 고려하십시오!
--oldconfig
/usr/share/genkernel의 일반 스크립트에서 시스템 아키텍처 설정 정보를 수집하는 make oldconfig 명령을 실행합니다. 대화식 과정이 아니며 어떤 사용자 입력도 받지 않습니다. 게다가 --oldconfig--clean 옵션과 결합하여 사용하면 후자 옵션이 반전되어 실제로는 --no-clean 옵션을 사용하는 상황과 비슷해집니다.
--callback="echo hello"
커널과 관련 모듈을 빌드한 후 지정 인자(이 경우 echo hello 명령)를 호출하지만, initrd 이미지를 빌드하기 전 과정에서 호출합니다. 콜백 처리에 실패하여 관련 항목을 이머지한 후 initrd 이미지에 외부 모듈을 설치할 때 쓸만하며, genkernel 모듈 그룹을 재정의합니다.
--[no-]install
새 커널 이미지, 설정 파일, initrc 이미지, 시스템 맵 파일을 부팅 분할 영역에 설치하는 make install 명령을 활성화(또는 비활성화)합니다. 컴파일한 어떤 모듈이든 마찬가지로 설치합니다. 기본적으로 install 명령을 실행하기 전 genkernel은 /boot 디렉터리가 다른 분할 영역에 존재하는 경우 마운트를 시도합니다.
--no-ramdisk-modules
genkernel에서 만든 initrd 이미지로의 모듈 복사를 중단합니다. 이 옵션은 no- 접두부가 붙은 규칙의 예외사항입니다. 이 접두부가 빠진 genkernel 옵션은 없습니다.
--all-ramdisk-modules
genkernel 에서 만든 initrd 이미지에 사용할 수 있는 모든 모듈을 복사합니다.
--genzimage
커널 이미지를 만들기 전, initrd 이미지를 만듭니다(이 꼼수는 현재 PPC Pegasos 시스템에만 적용합니다).

디버그 옵션

커널 컴파일 과정에서 사용하는 다음 디버깅 사용 옵션 값에 따라 나타나는 데이터와 보고하는 수많은 정보의 출력 내용을 관리합니다.

--loglevel=<0|1|2|3|4|5>
genkernel에서 제공하는 정보의 상세 수준을 다룹니다. <verblevel> 변수는 0 부터 5까지의 정수입니다. '0'은 최소한의 수준, 반면에 '5'는 가능한 한 genkernel이 커널을 컴파일하는 동안 출력할 수 있는 최대한의 많은 내용을 출력합니다.
--logfile=/path/to/output_file
(위에서 보여드린)--loglevel 옵션 값을 무시하고 genkernel에서 출력하는 모든 디버깅 데이터를 지정 출력 파일로 내보냅니다. /var/log/genkernel.log 파일이 기본 출력 대상입니다.
--[no-]color
이스케이프 시퀀스를 활용하여(genkernel에서 보여주는) 디버깅 출력 정보의 색상 출력을 [비]활성화합니다.
--[no-]debug-cleanup
디버깅 목적으로 출력한 디버깅 출력 내용의 실행 후 제거를 [비]활성화합니다.

동작

genkernel [options …] action 명령행으로 전달한 동작은 어떤 동작을 수행해야 하는지 genkernel에 알려줍니다. 다음 동작을 지원합니다:

동작 설명
all initrd, 커널 이미지, 모듈을 포함한 모든 스테이지를 빌드합니다.
bzImage 커널 이미지만 빌드합니다.
kernel 커널 이미지와 모듈만 빌드합니다.
initramfs initramfs/ramdisk 이미지만 빌드합니다.
ramdisk initramfs/ramdisk 이미지만 빌드합니다.

설정

시작하기

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

root #genkernel --splash --no-install --no-clean --menuconfig all

위 명령을 실행하면 genkernel이 프레임버퍼 스플래시를 활성화한 커널(--splash) 을 만들되, 직접 설치해야 합니다(--no-install). 커널 소스 트리를 준비하는 동안, genkernel은 소스 트리에 있는 이전 객체 파일 제거를 중단합니다(--no-clean). 사용자가 시스템에 빌드할 모듈을 선택할 수 있는 메뉴 기반 커널 설정 유틸리티를 띄웁니다(--menuconfig).

--no-install 옵션을 --install 옵션으로 바꾸면 genkernel이 /boot 디렉터리에 새 커널을 자동으로 설치할 수 있고 --symlink를 지정했다면 심볼릭 링크도 만듭니다. --mountboot 옵션을 사용하면, 필요한 경우 genkernel에서 /boot 분할 공간을 마운트합니다.

참고
시작할 때 /etc/genkernel.conf 파일을 genkernel 명령에서 제공하며, 명령행 옵션으로 우선 적용하는 항목을 제외한 모든 옵션을 이 파일에 지정하고, 적용할 후 있음을 잊지 마십시오.

커널 바꾸기

우선 /etc/genkernel.conf 파일에서 make menuconfig 실행을 허용해야합니다:

파일 /etc/genkernel.conf/etc/genkernel.conf에서 설정 메뉴 사용 강제
# Run 'make menuconfig' before compiling this kernel?
MENUCONFIG="yes"

파일 관리

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

소스 파일

emerge -u gentoo-sources 명령을 실행한 후, 새 소스 코드가 언제 존재하든지간에, 새 커널 소스코드 디렉터리를 /usr/src/에 만들어 제공합니다. 보통 활성 커널 소스 디렉터리는 /usr/src/linux 심볼릭 링크가 가리킵니다.

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

user $ls -l /usr/src
total 16
lrwxrwxrwx  1 root root   19 21 Mar   2013 linux -> linux-3.7.10-gentoo
drwxr-xr-x 24 root root 4096 25 Aug  10:39 linux-3.10.7-gentoo
drwxr-xr-x 20 root root 4096 21 Apr  19:42 linux-3.7.10-gentoo
drwxr-xr-x 21 root root 4096 14 Mar   2013 linux-3.7.9-gentoo

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

  • /etc/portage/make.confsymlink USE 플래그를 설정하면, 이머지한 새로운 소스로 /usr/src/linux 심볼릭 링크를 자동으로 업데이트합니다.
  • symlink USE 플래그를 설정하지 않았다면, eselect kernel list 명령을 사용하여 심볼릭 링크 대상을 살펴보고, eselect kernel set 명령으로 설정할 수 있습니다.

genkernel 은 항상(배타적으로) /usr/src/linux 심볼릭 링크가 가리키는 소스 코드를 사용합니다.

genkernel에서 사용하는 커널 설정 파일

커널 컴파일 과정을 이미 활성화된 커널 소스 코드를 대상으로 진행했을 경우, /etc/kernels 디렉터리에 최근 커널의 bzimage을 만드는 동안 적용한 커널 설정이 들어갑니다. 이 파일은 kernel-config-x86_64-3.7.9-gentoo-r1 과 같은 이름을 달고 있는데 x86_64는 시스템 아키텍처, 3.7.9 는 커널 버전, r1은 소스 코드의 개정 버전을 나타냅니다.

여기서 언급하는 파일이 kernel-config-x86_64-3.7.9-gentoo-r1 파일이며 genkernel --menuconfig all 명령을 실행하여 설정을 시작할 때 사용합니다.

genkernel을 새 커널 소스로 처음 실행하거나 이전의 설정 결과를 저장하지 않았다면 이 파일을 usr/share/genkernel/arch/x86_64/kernel-config의 기본 설정 파일로 두며, 여기서 x86_64는 실제 아키텍처 부분입니다.

참고
이 기본 설정 파일로의 경로는 /etc/genkernel.conf 파일의 DEFAULT_KERNEL_CONFIG 변수를 설정하여 바꾸어야 합니다.
컴파일한 설정 저장

--save-config genkernel 옵션을 활성화하면, 명령줄 또는 /etc/genkernel.conf 파일에서 컴파일한 커널의 설정을 /etc/kernels 디렉터리에 (위에서 말한 이름대로) 저장합니다. 동시에 설정은 /usr/src/linux 디렉터리에 .config 파일로 저장하지만 genkernel all 을 실행할 때 다시 사용하지 않습니다.

경고
알아두셔야 할 사항은 --save-config 옵션으로 genkernel을 매번 실행할 때마다 /etc/kernels 디렉터리의 설정 파일을 덮어씁니다. 따라서, 이 설정 파일을 보존하려면 genkernel을 실행하기 에 새 파일로 복사하시는것이 좋겠습니다
/boot 디렉터리에 커널과 initramfs 설치

genkernel을 실행할 때 --install 옵션을 지정하면 genkernel에 커널 이미지와 initramfs를 /boot 디렉터리에 설치하라고 요청합니다. --install 옵션을 편한 방식대로 실행하려면 /etc/genkernel.conf 파일에서 다음과 같은 부분을 설정하십시오:

파일 /etc/genkernel.conf커널과 initramfs 자동 저장 설정
# Mount BOOTDIR automatically if it is not mounted?
MOUNTBOOT="yes"
  
# Save the new configuration in /etc/kernels upon
# successful compilation
SAVE_CONFIG="yes"
  
# Make symlinks in BOOTDIR automatically?
SYMLINK="yes"
  
# Add new kernel to grub2?
BOOTLOADER="grub2"
  • 첫번째 매개변수는 그 자체를 의미합니다.
  • 두번째 매개변수는 genkernel에 /etc/kernels에 커널 설정 내용을 저장하라고 일러줍니다
  • 마지막 옵션 두개는 genkernel에 자동으로 grub 설정을 업데이트하라고 알려줍니다. 실제로 다음 두가지 일이 일어납니다:
    • 동일한 이름을 가진 이전 커널 이미지가 있으면, .old 파일 이름이 기존의 파일 이름 뒤에 붙습니다. kernel.old 심볼릭 링크를 자동으로 만들어 해당 파일을 가리킵니다.
    • 어떤 동일한 이름의 커널이든 새 커널은 /boot에 들어갑니다. 커널을 처음 컴파일하면, 새 커널을 가리키는 커널 심볼릭 링크를 자동으로 만듭니다.

genkernel --menuconfig all를 실행한 후의 /boot 디렉터리 모습은 다음과 같습니다:

user $ls -al /boot
total 41336
drwxr-xr-x  3 root root    4096 20 avril 17:23 .
drwxr-xr-x 24 root root    4096 15 sept. 12:31 ..
lrwxrwxrwx  1 root root       1 24 févr.  2013 boot -> .
drwxr-xr-x  2 root root    4096 24 févr.  2013 grub
lrwxrwxrwx  1 root root      40 20 avril 17:23 initramfs -> initramfs-genkernel-x86_64-3.7.10-gentoo
-rw-r--r--  1 root root 1314412 20 avril 17:23 initramfs-genkernel-x86_64-3.7.10-gentoo
-rw-r--r--  1 root root 1313548 21 mars   2013 initramfs-genkernel-x86_64-3.7.10-gentoo.old
-rw-r--r--  1 root root 1295344 25 févr.  2013 initramfs-genkernel-x86_64-3.7.9-gentoo
-rw-r--r--  1 root root 3310324 25 févr.  2013 initramfs-genkernel-x86_64-3.7.9-gentoo.old
lrwxrwxrwx  1 root root      44 20 avril 17:23 initramfs.old -> initramfs-genkernel-x86_64-3.7.10-gentoo.old
lrwxrwxrwx  1 root root      37 20 avril 17:23 kernel -> kernel-genkernel-x86_64-3.7.10-gentoo
-rw-r--r--  1 root root 4866656 20 avril 17:23 kernel-genkernel-x86_64-3.7.10-gentoo
-rw-r--r--  1 root root 4866560 21 mars   2013 kernel-genkernel-x86_64-3.7.10-gentoo.old
-rw-r--r--  1 root root 4552288 25 févr.  2013 kernel-genkernel-x86_64-3.7.9-gentoo
-rw-r--r--  1 root root 3400736 25 févr.  2013 kernel-genkernel-x86_64-3.7.9-gentoo.old
lrwxrwxrwx  1 root root      41 20 avril 17:23 kernel.old -> kernel-genkernel-x86_64-3.7.10-gentoo.old

부트로더 설정

extlinux

TODO

GRUB Legacy
경고
The following text is about GRUB Legacy which was removed in Gentoo in February 2019. If at all possible, please migrate to GRUB2 as soon as possible.

위의 부트로더 설정에서 나타난 심볼릭 링크를 사용할 수 있는 상태로 나타나므로, 새 커널로 부팅할 수 없어도 사용자는 이전 커널로 항상 부팅할 수 있습니다.

genkernel에서 제공하는 커널과 initrd를 제대로 동작하게 하려면 부트로더 설정 파일에 최소한의 정보를 제공하십시오:

  • 커널 이미지로 전달할 커널 매개 변수에 root=/dev/sdaN를 추가하십시오. 여기서 /dev/sdaN은 루트 공간을 나타냅니다(N는 공간이 존재할 경우 해당 공간의 번호입니다).
  • 시작 화면을 사용한다면 vga=0x317와 같은 적당한 디스플레이 모드를 커널에 전달할 매개변수에 추가하시고 부팅 과정에서 메시지를 최대한 자세하게 표시할 지 여부에 따라 splash=verbose 또는 splash=silent도 추가하십시오.
  • 부트로더에서 필요한 initrd 정보를 추가하십시오. initrd를 부트로더가 인식할 수 있게 하는 방법이 무엇인지 알아보려면 젠투 핸드북의 부트 로더 설정을 참고하십시오.

grub.conf 파일 내용은 다음과 같습니다.

파일 /boot/grub/grub.confgrub.conf 파일 예제
# This is a sample grub.conf for use with Genkernel, per the Gentoo handbook 
# http://www.gentoo.org/doc/en/handbook/handbook-x86.xml?part=1&chap=10#doc_chap2 
# If you are not using Genkernel and you need help creating this file, you 
# should consult the handbook. Alternatively, consult the grub.conf.sample that 
# is included with the Grub documentation. 
  
default 0 
timeout 5
splashimage=(hd1,0)/boot/grub/splash.xpm.gz 
   
title Gentoo Linux 
root (hd0,6) 
kernel /boot/kernel initrd=/dev/ram0 root=/dev/sda7 rootfstype=ext4  
initrd /boot/initramfs
  
title Gentoo Linux old kernel 
root (hd0,6) 
kernel /boot/kernel.old initrd=/dev/ram0 root=/dev/sda7 rootfstype=ext4 
initrd /boot/initramfs.old
GRUB

TODO

systemd-boot

TODO

작업 파일 보존

genkernel 프로그램은 바뀐 설정을 자동으로 파일에 저장합니다. 앞서 저장한 내용을 유지하려면 다음 조치가 필요합니다.

  • 커널을 다시 컴파일 하기 전 설정 원본이 바뀌지 않았을 경우, /etc/kernels/에 있는 커널 설정 파일 중 설정을 유지하려는 파일에 앞서 사용한 파일 이름을 그대로 사용합니다. 따라서 새 설정을 시작할 시점으로 유지할 때 이 파일을 다른 이름으로 복사하시면 이전 설정을 유지할 수 있습니다.
  • 두 번째 중요한 점이 있다면, 부팅할 수 있는 커널과 initramfs 이미지의 보존입니다. 상황에 따라 처리할 수 있는 방법이 다릅니다:
  1. 최근 컴파일한 커널이 부팅할 수 있는 커널일 경우, genkernel을 실행하면 커널(및 initramfs 도?) 이미지 이름을 kernel-genkernel-ARCH-X.Y.Z-gentoo-rx.old 로 바꾸고 kernel-genkernel-ARCH-X.Y.Z-gentoo-rx 파일을 새로 만듭니다. 새 커널로 부팅할 수 없어도 사용자는 이전 커널로 부팅할 수 있음을 의미합니다.
  2. 최근 컴파일한 커널이 부팅할 수 없고 사용자가 컴파일 할 수 있게 컴파일 한 이후로 소스 코드가 바뀌지 않았다면, genkernel을 실행하기 전에 새 커널 이미지를 삭제하고 최근 부팅한 커널의 .old 접미부를 제거하십시오. 이렇게 하지 않으면 다음에 새로 컴파일한 커널로 부팅할 수 없을 경우, 부팅할 수 있는 kernel-genkernel-ARCH-X.Y.Z-gentoo-rx.old 이미지를 부팅할 수 없는 kernel-genkernel-ARCH-X.Y.Z-gentoo-rx 이미지로 바꾸어 없애버려 부팅할 수 없는 시스템으로 만듭니다. initramfs에도 동일한 이유가 적용됩니다.
참고
Since genkernel-4, it is recommended to create new, independent revisions each with its own kernel image, initramfs and installed modules in /lib/modules using genkernel --kernel-append-localversion=-my-new-revision all.

소스를 바꿀 때 이전 커널 설정 사용

이전 설정은 다음과 같이 /etc/genkernel.confMENUCONFIG 변수에서 사용할 수 있습니다:

파일 /etc/genkernel.confmake menuconfig 설정
# Run 'make menuconfig' before compiling this kernel?
MENUCONFIG="yes"
참고
설정 원본을 kernel-genkernel-ARCH-version-gentoo-rx에서 kernel-genkernel-ARCH-version-gentoo-r(x+1)로 바뀌거나 kernel-genkernel-ARCH-version-gentoo에서 kernel-genkernel-ARCH-(version+1)-gentoo로 바뀌어도 genkernel을 사용할 때 make oldconfig 를 사용할 필요가 없습니다. 왜냐면 make menuconfig에서 메뉴로 이전 설정을 가능한대로 불러오기 때문입니다. 그래도, 주의를 기울여 각 옵션과 새 섹션을 검토 해보시는 게 좋습니다.

Checking that initramfs includes necessary modules/utilities before booting

Before booting the system, it might be wise checking that initramfs includes necessary utilities and modules. For example, to utilize remote unlock capabilities for a headless system using LUKS, ensure that kernel modules for your network interface card, dropbear, and cryptsetup have been included.

Using lsinitrd

Since genkernel-4, created initramfs can be processed using the lsinitrd command from the sys-kernel/dracut package:

user $lsinitrd /boot/initramfs-5.3.14-gentoo-r1-x86_64-wifitest2.img
Image: /boot/initramfs-5.3.14-gentoo-r1-x86_64-wifitest2.img: 4,5M
========================================================================
Version: Genkernel 4.0.1 (2019-12-16 00:48:10 UTC)
 
Arguments: --boot-font=none --keymap --compress-initramfs --no-microcode-initramfs --ramdisk-modules --busybox --no-btrfs --no-iscsi --no-multipath --no-dmraid --mdadm --lvm --no-unionfs --no-zfs --no-splash --no-strace --no-gpg --luks --no-firmware --firmware-dir=/lib/firmware --ssh --no-e2fsprogs --no-xfsprogs
 
dracut modules:
========================================================================
drwxr-xr-x  16 root     root            0  Dec 16 01:49 .
drwxr-xr-x   2 root     root            0  Dec 16 01:49 bin
lrwxrwxrwx   1 root     root            7  Dec 16 01:49 bin/ash -> busybox
lrwxrwxrwx   1 root     root            7  Dec 16 01:49 bin/[ -> busybox
-rwxr-xr-x   1 root     root      2351376  Dec 16 01:49 bin/busybox
lrwxrwxrwx   1 root     root            7  Dec 16 01:49 bin/cat -> busybox
lrwxrwxrwx   1 root     root            7  Dec 16 01:49 bin/cut -> busybox
lrwxrwxrwx   1 root     root            7  Dec 16 01:49 bin/echo -> busybox
lrwxrwxrwx   1 root     root            7  Dec 16 01:49 bin/mknod -> busybox
lrwxrwxrwx   1 root     root            7  Dec 16 01:49 bin/mount -> busybox
lrwxrwxrwx   1 root     root            7  Dec 16 01:49 bin/sh -> busybox
lrwxrwxrwx   1 root     root            7  Dec 16 01:49 bin/uname -> busybox
drwxr-xr-x   2 root     root            0  Dec 16 01:49 dev
drwxr-xr-x   8 root     root            0  Dec 16 01:49 etc
-rw-r--r--   1 root     root           24  Dec 16 01:49 etc/build_date
-rw-r--r--   1 root     root           16  Dec 16 01:49 etc/build_id
drwxr-xr-x   2 root     root            0  Dec 16 01:49 etc/dropbear
-rw-------   1 root     root          140  Dec 16 01:49 etc/dropbear/dropbear_ecdsa_host_key
-rw-------   1 root     root          806  Dec 16 01:49 etc/dropbear/dropbear_rsa_host_key
prw-r--r--   1 root     root            0  Dec 16 01:49 etc/dropbear/fifo_root
prw-r--r--   1 root     root            0  Dec 16 01:49 etc/dropbear/fifo_swap
-rw-r--r--   1 root     root           97  Dec 16 01:49 etc/fstab
-rw-r--r--   1 root     root           14  Dec 16 01:49 etc/group
-rw-r--r--   1 root     root         3742  Dec 16 01:49 etc/initrd.defaults
-rw-r--r--   1 root     root        69232  Dec 16 01:49 etc/initrd.scripts
-rw-r--r--   1 root     root          441  Dec 16 01:49 etc/ld.so.cache
-rw-r--r--   1 root     root           78  Dec 16 01:49 etc/ld.so.conf
drwxr-xr-x   2 root     root            0  Dec 16 01:49 etc/ld.so.conf.d
-rw-r--r--   1 root     root           81  Dec 16 01:49 etc/ld.so.conf.d/05gcc-x86_64-pc-linux-gnu.conf
-rw-r--r--   1 root     root         2298  Dec 16 01:49 etc/localtime
drwxr-xr-x   3 root     root            0  Dec 16 01:49 etc/lvm
drwxr-xr-x   2 root     root            0  Dec 16 01:49 etc/lvm/cache
-rw-r--r--   1 root     root        95231  Dec 16 01:49 etc/lvm/lvm.conf
-rw-r--r--   1 root     root         2882  Dec 16 01:49 etc/mdadm.conf
drwxr-xr-x   3 root     root            0  Dec 16 01:49 etc/mdev
-rw-r--r--   1 root     root         1172  Dec 16 01:49 etc/mdev.conf
drwxr-xr-x   2 root     root            0  Dec 16 01:49 etc/mdev/helpers
-rwxr-xr-x   1 root     root          666  Dec 16 01:49 etc/mdev/helpers/nvme
-rwxr-xr-x   1 root     root         1295  Dec 16 01:49 etc/mdev/helpers/storage-device
drwxr-xr-x   2 root     root            0  Dec 16 01:49 etc/modprobe.d
-rw-r--r--   1 root     root         1186  Dec 16 01:49 etc/modprobe.d/aliases.conf
-rw-r--r--   1 root     root          122  Dec 16 01:49 etc/modprobe.d/i386.conf
drwxr-xr-x   2 root     root            0  Dec 16 01:49 etc/modules
-rw-r--r--   1 root     root           24  Dec 16 01:49 etc/modules/ataraid
-rw-r--r--   1 root     root           21  Dec 16 01:49 etc/modules/block
-rw-r--r--   1 root     root          180  Dec 16 01:49 etc/modules/crypto
-rw-r--r--   1 root     root           26  Dec 16 01:49 etc/modules/dmraid
-rw-r--r--   1 root     root           23  Dec 16 01:49 etc/modules/firewire
-rw-r--r--   1 root     root          123  Dec 16 01:49 etc/modules/fs
-rw-r--r--   1 root     root           86  Dec 16 01:49 etc/modules/hyperv
-rw-r--r--   1 root     root           40  Dec 16 01:49 etc/modules/iscsi
-rw-r--r--   1 root     root          437  Dec 16 01:49 etc/modules/lvm
-rw-r--r--   1 root     root          194  Dec 16 01:49 etc/modules/mdadm
-rw-r--r--   1 root     root           75  Dec 16 01:49 etc/modules/multipath
-rw-r--r--   1 root     root          214  Dec 16 01:49 etc/modules/net
-rw-r--r--   1 root     root           56  Dec 16 01:49 etc/modules/nvme
-rw-r--r--   1 root     root          519  Dec 16 01:49 etc/modules/pata
-rw-r--r--   1 root     root           83  Dec 16 01:49 etc/modules/pcmcia
-rw-r--r--   1 root     root          158  Dec 16 01:49 etc/modules/sata
-rw-r--r--   1 root     root          523  Dec 16 01:49 etc/modules/scsi
-rw-r--r--   1 root     root          350  Dec 16 01:49 etc/modules/usb
-rw-r--r--   1 root     root          133  Dec 16 01:49 etc/modules/virtio
-rw-r--r--   1 root     root           15  Dec 16 01:49 etc/modules/waitscan
-rw-r--r--   1 root     root           47  Dec 16 01:49 etc/passwd
-rw-r-----   1 root     root           22  Dec 16 01:49 etc/shadow
-rw-r--r--   1 root     root           25  Dec 16 01:49 etc/shells
-rwxr-xr-x   1 root     root        32331  Dec 16 01:49 init
drwxr-xr-x   2 root     root            0  Dec 16 01:49 .initrd
drwxr-xr-x   6 root     root            0  Dec 16 01:49 lib
lrwxrwxrwx   1 root     root            3  Dec 16 01:49 lib32 -> lib
lrwxrwxrwx   1 root     root            3  Dec 16 01:49 lib64 -> lib
drwxr-xr-x   2 root     root            0  Dec 16 01:49 lib/console
drwxr-xr-x   2 root     root            0  Dec 16 01:49 lib/dracut
-rw-r--r--   1 root     root          312  Dec 16 01:49 lib/dracut/build-parameter.txt
-rw-r--r--   1 root     root           42  Dec 16 01:49 lib/dracut/dracut-gk-version.info
drwxr-xr-x   2 root     root            0  Dec 16 01:49 lib/keymaps
lrwxrwxrwx   1 root     root            9  Dec 16 01:49 lib/keymaps/10.map -> croat.map
lrwxrwxrwx   1 root     root            6  Dec 16 01:49 lib/keymaps/11.map -> cz.map
lrwxrwxrwx   1 root     root            6  Dec 16 01:49 lib/keymaps/12.map -> de.map
lrwxrwxrwx   1 root     root            6  Dec 16 01:49 lib/keymaps/13.map -> dk.map
lrwxrwxrwx   1 root     root           10  Dec 16 01:49 lib/keymaps/14.map -> dvorak.map
lrwxrwxrwx   1 root     root            6  Dec 16 01:49 lib/keymaps/15.map -> es.map
lrwxrwxrwx   1 root     root            6  Dec 16 01:49 lib/keymaps/16.map -> et.map
lrwxrwxrwx   1 root     root            6  Dec 16 01:49 lib/keymaps/17.map -> fi.map
lrwxrwxrwx   1 root     root            6  Dec 16 01:49 lib/keymaps/18.map -> fr.map
lrwxrwxrwx   1 root     root            6  Dec 16 01:49 lib/keymaps/19.map -> gr.map
lrwxrwxrwx   1 root     root           10  Dec 16 01:49 lib/keymaps/1.map -> azerty.map
lrwxrwxrwx   1 root     root            6  Dec 16 01:49 lib/keymaps/20.map -> hu.map
lrwxrwxrwx   1 root     root            6  Dec 16 01:49 lib/keymaps/21.map -> il.map
lrwxrwxrwx   1 root     root            6  Dec 16 01:49 lib/keymaps/22.map -> is.map
lrwxrwxrwx   1 root     root            6  Dec 16 01:49 lib/keymaps/23.map -> it.map
lrwxrwxrwx   1 root     root            6  Dec 16 01:49 lib/keymaps/24.map -> jp.map
lrwxrwxrwx   1 root     root            6  Dec 16 01:49 lib/keymaps/25.map -> la.map
lrwxrwxrwx   1 root     root            6  Dec 16 01:49 lib/keymaps/26.map -> lt.map
lrwxrwxrwx   1 root     root            6  Dec 16 01:49 lib/keymaps/27.map -> mk.map
lrwxrwxrwx   1 root     root            6  Dec 16 01:49 lib/keymaps/28.map -> nl.map
lrwxrwxrwx   1 root     root            6  Dec 16 01:49 lib/keymaps/29.map -> no.map
lrwxrwxrwx   1 root     root            6  Dec 16 01:49 lib/keymaps/2.map -> be.map
lrwxrwxrwx   1 root     root            6  Dec 16 01:49 lib/keymaps/30.map -> pl.map
lrwxrwxrwx   1 root     root            6  Dec 16 01:49 lib/keymaps/31.map -> pt.map
lrwxrwxrwx   1 root     root            6  Dec 16 01:49 lib/keymaps/32.map -> ro.map
lrwxrwxrwx   1 root     root            6  Dec 16 01:49 lib/keymaps/33.map -> ru.map
lrwxrwxrwx   1 root     root            6  Dec 16 01:49 lib/keymaps/34.map -> se.map
lrwxrwxrwx   1 root     root            6  Dec 16 01:49 lib/keymaps/35.map -> sf.map
lrwxrwxrwx   1 root     root            6  Dec 16 01:49 lib/keymaps/36.map -> sg.map
lrwxrwxrwx   1 root     root            8  Dec 16 01:49 lib/keymaps/37.map -> sk-y.map
lrwxrwxrwx   1 root     root            8  Dec 16 01:49 lib/keymaps/38.map -> sk-z.map
lrwxrwxrwx   1 root     root           11  Dec 16 01:49 lib/keymaps/39.map -> slovene.map
lrwxrwxrwx   1 root     root            8  Dec 16 01:49 lib/keymaps/3.map -> bepo.map
lrwxrwxrwx   1 root     root            7  Dec 16 01:49 lib/keymaps/40.map -> trf.map
lrwxrwxrwx   1 root     root            6  Dec 16 01:49 lib/keymaps/41.map -> ua.map
lrwxrwxrwx   1 root     root            6  Dec 16 01:49 lib/keymaps/42.map -> uk.map
lrwxrwxrwx   1 root     root            6  Dec 16 01:49 lib/keymaps/43.map -> us.map
lrwxrwxrwx   1 root     root           10  Dec 16 01:49 lib/keymaps/44.map -> wangbe.map
lrwxrwxrwx   1 root     root            6  Dec 16 01:49 lib/keymaps/4.map -> bg.map
lrwxrwxrwx   1 root     root            8  Dec 16 01:49 lib/keymaps/5.map -> br-a.map
lrwxrwxrwx   1 root     root            8  Dec 16 01:49 lib/keymaps/6.map -> br-l.map
lrwxrwxrwx   1 root     root            6  Dec 16 01:49 lib/keymaps/7.map -> by.map
lrwxrwxrwx   1 root     root            6  Dec 16 01:49 lib/keymaps/8.map -> cf.map
lrwxrwxrwx   1 root     root           11  Dec 16 01:49 lib/keymaps/9.map -> colemak.map
-rw-r--r--   1 root     root         2823  Dec 16 01:49 lib/keymaps/azerty.map
-rw-r--r--   1 root     root         2823  Dec 16 01:49 lib/keymaps/be.map
-rw-r--r--   1 root     root         2823  Dec 16 01:49 lib/keymaps/bepo.map
-rw-r--r--   1 root     root         2823  Dec 16 01:49 lib/keymaps/bg.map
-rw-r--r--   1 root     root         2823  Dec 16 01:49 lib/keymaps/br-a.map
-rw-r--r--   1 root     root         2823  Dec 16 01:49 lib/keymaps/br-l.map
-rw-r--r--   1 root     root         2823  Dec 16 01:49 lib/keymaps/by.map
-rw-r--r--   1 root     root         2823  Dec 16 01:49 lib/keymaps/cf.map
-rw-r--r--   1 root     root         2823  Dec 16 01:49 lib/keymaps/colemak.map
-rw-r--r--   1 root     root         2823  Dec 16 01:49 lib/keymaps/croat.map
-rw-r--r--   1 root     root         2823  Dec 16 01:49 lib/keymaps/cz.map
-rw-r--r--   1 root     root         2823  Dec 16 01:49 lib/keymaps/de.map
-rw-r--r--   1 root     root         2823  Dec 16 01:49 lib/keymaps/dk.map
-rw-r--r--   1 root     root         2823  Dec 16 01:49 lib/keymaps/dvorak.map
-rw-r--r--   1 root     root         2823  Dec 16 01:49 lib/keymaps/es.map
-rw-r--r--   1 root     root         2823  Dec 16 01:49 lib/keymaps/et.map
-rw-r--r--   1 root     root         2823  Dec 16 01:49 lib/keymaps/fi.map
-rw-r--r--   1 root     root         2823  Dec 16 01:49 lib/keymaps/fr.map
-rw-r--r--   1 root     root         2823  Dec 16 01:49 lib/keymaps/gr.map
-rw-r--r--   1 root     root         2823  Dec 16 01:49 lib/keymaps/hu.map
-rw-r--r--   1 root     root         2823  Dec 16 01:49 lib/keymaps/il.map
-rw-r--r--   1 root     root         2823  Dec 16 01:49 lib/keymaps/is.map
-rw-r--r--   1 root     root         2823  Dec 16 01:49 lib/keymaps/it.map
-rw-r--r--   1 root     root         2823  Dec 16 01:49 lib/keymaps/jp.map
-rw-r--r--   1 root     root          518  Dec 16 01:49 lib/keymaps/keymapList
-rw-r--r--   1 root     root         2823  Dec 16 01:49 lib/keymaps/la.map
-rw-r--r--   1 root     root         2823  Dec 16 01:49 lib/keymaps/lt.map
-rw-r--r--   1 root     root         2823  Dec 16 01:49 lib/keymaps/mk.map
-rw-r--r--   1 root     root         2823  Dec 16 01:49 lib/keymaps/nl.map
-rw-r--r--   1 root     root         2823  Dec 16 01:49 lib/keymaps/no.map
-rw-r--r--   1 root     root         2823  Dec 16 01:49 lib/keymaps/pl.map
-rw-r--r--   1 root     root         2823  Dec 16 01:49 lib/keymaps/pt.map
-rw-r--r--   1 root     root         2823  Dec 16 01:49 lib/keymaps/ro.map
-rw-r--r--   1 root     root         2823  Dec 16 01:49 lib/keymaps/ru.map
-rw-r--r--   1 root     root         2823  Dec 16 01:49 lib/keymaps/se.map
-rw-r--r--   1 root     root         2823  Dec 16 01:49 lib/keymaps/sf.map
-rw-r--r--   1 root     root         2823  Dec 16 01:49 lib/keymaps/sg.map
-rw-r--r--   1 root     root         2823  Dec 16 01:49 lib/keymaps/sk-y.map
-rw-r--r--   1 root     root         2823  Dec 16 01:49 lib/keymaps/sk-z.map
-rw-r--r--   1 root     root         2823  Dec 16 01:49 lib/keymaps/slovene.map
-rw-r--r--   1 root     root         2823  Dec 16 01:49 lib/keymaps/trf.map
-rw-r--r--   1 root     root         2823  Dec 16 01:49 lib/keymaps/ua.map
-rw-r--r--   1 root     root         2823  Dec 16 01:49 lib/keymaps/uk.map
-rw-r--r--   1 root     root         2823  Dec 16 01:49 lib/keymaps/us.map
-rw-r--r--   1 root     root         2823  Dec 16 01:49 lib/keymaps/wangbe.map
-rwxr-xr-x   1 root     root       169376  Dec 16 01:49 lib/ld-linux-x86-64.so.2
-rwxr-xr-x   1 root     root      1913648  Dec 16 01:49 lib/libc.so.6
-rwxr-xr-x   1 root     root        26800  Dec 16 01:49 lib/libnss_dns.so
lrwxrwxrwx   1 root     root           13  Dec 16 01:49 lib/libnss_dns.so.2 -> libnss_dns.so
-rwxr-xr-x   1 root     root        51536  Dec 16 01:49 lib/libnss_files.so
lrwxrwxrwx   1 root     root           15  Dec 16 01:49 lib/libnss_files.so.2 -> libnss_files.so
-rwxr-xr-x   1 root     root        88736  Dec 16 01:49 lib/libresolv.so.2
drwxr-xr-x   3 root     root            0  Dec 16 01:49 lib/modules
drwxr-xr-x   3 root     root            0  Dec 16 01:49 lib/modules/5.3.14-gentoo-r1-x86_64-wifitest2
drwxr-xr-x   5 root     root            0  Dec 16 01:49 lib/modules/5.3.14-gentoo-r1-x86_64-wifitest2/kernel
drwxr-xr-x   2 root     root            0  Dec 16 01:49 lib/modules/5.3.14-gentoo-r1-x86_64-wifitest2/kernel/crypto
-rw-r--r--   1 root     root         7152  Dec 16 01:49 lib/modules/5.3.14-gentoo-r1-x86_64-wifitest2/kernel/crypto/algif_rng.ko
drwxr-xr-x   6 root     root            0  Dec 16 01:49 lib/modules/5.3.14-gentoo-r1-x86_64-wifitest2/kernel/drivers
drwxr-xr-x   3 root     root            0  Dec 16 01:49 lib/modules/5.3.14-gentoo-r1-x86_64-wifitest2/kernel/drivers/hid
drwxr-xr-x   2 root     root            0  Dec 16 01:49 lib/modules/5.3.14-gentoo-r1-x86_64-wifitest2/kernel/drivers/hid/usbhid
-rw-r--r--   1 root     root        66448  Dec 16 01:49 lib/modules/5.3.14-gentoo-r1-x86_64-wifitest2/kernel/drivers/hid/usbhid/usbhid.ko
drwxr-xr-x   2 root     root            0  Dec 16 01:49 lib/modules/5.3.14-gentoo-r1-x86_64-wifitest2/kernel/drivers/md
-rw-r--r--   1 root     root        19024  Dec 16 01:49 lib/modules/5.3.14-gentoo-r1-x86_64-wifitest2/kernel/drivers/md/dm-log.ko
-rw-r--r--   1 root     root        27256  Dec 16 01:49 lib/modules/5.3.14-gentoo-r1-x86_64-wifitest2/kernel/drivers/md/dm-mirror.ko
-rw-r--r--   1 root     root        49200  Dec 16 01:49 lib/modules/5.3.14-gentoo-r1-x86_64-wifitest2/kernel/drivers/md/dm-raid.ko
-rw-r--r--   1 root     root        16536  Dec 16 01:49 lib/modules/5.3.14-gentoo-r1-x86_64-wifitest2/kernel/drivers/md/dm-region-hash.ko
drwxr-xr-x   3 root     root            0  Dec 16 01:49 lib/modules/5.3.14-gentoo-r1-x86_64-wifitest2/kernel/drivers/net
drwxr-xr-x   2 root     root            0  Dec 16 01:49 lib/modules/5.3.14-gentoo-r1-x86_64-wifitest2/kernel/drivers/net/intel
drwxr-xr-x   2 root     root            0  Dec 16 01:49 lib/modules/5.3.14-gentoo-r1-x86_64-wifitest2/kernel/drivers/net/intel/e1000
-rw-r--r--   1 root     root        70480  Dec 16 01:49 lib/modules/5.3.14-gentoo-r1-x86_64-wifitest2/kernel/drivers/net/intel/e1000/e1000.ko
drwxr-xr-x   6 root     root            0  Dec 16 01:49 lib/modules/5.3.14-gentoo-r1-x86_64-wifitest2/kernel/drivers/usb
drwxr-xr-x   2 root     root            0  Dec 16 01:49 lib/modules/5.3.14-gentoo-r1-x86_64-wifitest2/kernel/drivers/usb/common
-rw-r--r--   1 root     root         6584  Dec 16 01:49 lib/modules/5.3.14-gentoo-r1-x86_64-wifitest2/kernel/drivers/usb/common/usb-common.ko
drwxr-xr-x   2 root     root            0  Dec 16 01:49 lib/modules/5.3.14-gentoo-r1-x86_64-wifitest2/kernel/drivers/usb/core
-rw-r--r--   1 root     root       308944  Dec 16 01:49 lib/modules/5.3.14-gentoo-r1-x86_64-wifitest2/kernel/drivers/usb/core/usbcore.ko
drwxr-xr-x   2 root     root            0  Dec 16 01:49 lib/modules/5.3.14-gentoo-r1-x86_64-wifitest2/kernel/drivers/usb/host
-rw-r--r--   1 root     root        60416  Dec 16 01:49 lib/modules/5.3.14-gentoo-r1-x86_64-wifitest2/kernel/drivers/usb/host/ehci-hcd.ko
-rw-r--r--   1 root     root        10616  Dec 16 01:49 lib/modules/5.3.14-gentoo-r1-x86_64-wifitest2/kernel/drivers/usb/host/ehci-pci.ko
-rw-r--r--   1 root     root        46072  Dec 16 01:49 lib/modules/5.3.14-gentoo-r1-x86_64-wifitest2/kernel/drivers/usb/host/ohci-hcd.ko
-rw-r--r--   1 root     root        35896  Dec 16 01:49 lib/modules/5.3.14-gentoo-r1-x86_64-wifitest2/kernel/drivers/usb/host/uhci-hcd.ko
drwxr-xr-x   2 root     root            0  Dec 16 01:49 lib/modules/5.3.14-gentoo-r1-x86_64-wifitest2/kernel/drivers/usb/storage
-rw-r--r--   1 root     root       126512  Dec 16 01:49 lib/modules/5.3.14-gentoo-r1-x86_64-wifitest2/kernel/drivers/usb/storage/usb-storage.ko
drwxr-xr-x   3 root     root            0  Dec 16 01:49 lib/modules/5.3.14-gentoo-r1-x86_64-wifitest2/kernel/fs
drwxr-xr-x   2 root     root            0  Dec 16 01:49 lib/modules/5.3.14-gentoo-r1-x86_64-wifitest2/kernel/fs/fat
-rw-r--r--   1 root     root        95664  Dec 16 01:49 lib/modules/5.3.14-gentoo-r1-x86_64-wifitest2/kernel/fs/fat/fat.ko
-rw-r--r--   1 root     root        16104  Dec 16 01:49 lib/modules/5.3.14-gentoo-r1-x86_64-wifitest2/kernel/fs/fat/msdos.ko
-rw-r--r--   1 root     root        32434  Dec 16 01:49 lib/modules/5.3.14-gentoo-r1-x86_64-wifitest2/modules.alias
-rw-r--r--   1 root     root        42356  Dec 16 01:49 lib/modules/5.3.14-gentoo-r1-x86_64-wifitest2/modules.alias.bin
-rw-r--r--   1 root     root         8132  Dec 16 01:49 lib/modules/5.3.14-gentoo-r1-x86_64-wifitest2/modules.builtin
-rw-r--r--   1 root     root        11529  Dec 16 01:49 lib/modules/5.3.14-gentoo-r1-x86_64-wifitest2/modules.builtin.bin
-rw-r--r--   1 root     root        15196  Dec 16 01:49 lib/modules/5.3.14-gentoo-r1-x86_64-wifitest2/modules.dep
-rw-r--r--   1 root     root        23748  Dec 16 01:49 lib/modules/5.3.14-gentoo-r1-x86_64-wifitest2/modules.dep.bin
-rw-r--r--   1 root     root            0  Dec 16 01:49 lib/modules/5.3.14-gentoo-r1-x86_64-wifitest2/modules.devname
-rw-r--r--   1 root     root         8320  Dec 16 01:49 lib/modules/5.3.14-gentoo-r1-x86_64-wifitest2/modules.order
-rw-r--r--   1 root     root          117  Dec 16 01:49 lib/modules/5.3.14-gentoo-r1-x86_64-wifitest2/modules.softdep
-rw-r--r--   1 root     root        24707  Dec 16 01:49 lib/modules/5.3.14-gentoo-r1-x86_64-wifitest2/modules.symbols
-rw-r--r--   1 root     root        29469  Dec 16 01:49 lib/modules/5.3.14-gentoo-r1-x86_64-wifitest2/modules.symbols.bin
lrwxrwxrwx   1 root     root            4  Dec 16 01:49 linuxrc -> init
drwxr-xr-x   2 root     root            0  Dec 16 01:49 mnt
drwxr-xr-x   2 root     root            0  Dec 16 01:49 proc
drwxr-xr-x   3 root     root            0  Dec 16 01:49 root
drwx------   2 root     root            0  Dec 16 01:49 root/.ssh
-rw-------   1 root     root          742  Dec 16 01:49 root/.ssh/authorized_keys
drwxr-xr-x   2 root     root            0  Dec 16 01:49 run
-rw-r--r--   1 root     root            0  Dec 16 01:49 run/utmp
drwxr-xr-x   2 root     root            0  Dec 16 01:49 sbin
-rwxr-xr-x   1 root     root      1105720  Dec 16 01:49 sbin/blkid
-rwxr-xr-x   1 root     root      2813384  Dec 16 01:49 sbin/cryptsetup
lrwxrwxrwx   1 root     root           19  Dec 16 01:49 sbin/dmsetup -> ../usr/sbin/dmsetup
lrwxrwxrwx   1 root     root           19  Dec 16 01:49 sbin/dmstats -> ../usr/sbin/dmstats
lrwxrwxrwx   1 root     root            7  Dec 16 01:49 sbin/init -> ../init
lrwxrwxrwx   1 root     root           15  Dec 16 01:49 sbin/lvm -> ../usr/sbin/lvm
-rwxr-xr-x   1 root     root      1510360  Dec 16 01:49 sbin/mdadm
-rwxr-xr-x   1 root     root      1267904  Dec 16 01:49 sbin/mdmon
drwxr-xr-x   2 root     root            0  Dec 16 01:49 sys
drwxrwxrwt   2 root     root            0  Dec 16 01:49 tmp
drwxr-xr-x   6 root     root            0  Dec 16 01:49 usr
drwxr-xr-x   2 root     root            0  Dec 16 01:49 usr/bin
lrwxrwxrwx   1 root     root           13  Dec 16 01:49 usr/bin/dropbearconvert -> dropbearmulti
lrwxrwxrwx   1 root     root           13  Dec 16 01:49 usr/bin/dropbearkey -> dropbearmulti
-rwxr-xr-x   1 root     root      1365144  Dec 16 01:49 usr/bin/dropbearmulti
-rwxr-xr-x   1 root     root         2881  Dec 16 01:49 usr/bin/login-remote.sh
lrwxrwxrwx   1 root     root           13  Dec 16 01:49 usr/bin/scp -> dropbearmulti
drwxr-xr-x   2 root     root            0  Dec 16 01:49 usr/lib
lrwxrwxrwx   1 root     root            3  Dec 16 01:49 usr/lib32 -> lib
lrwxrwxrwx   1 root     root            3  Dec 16 01:49 usr/lib64 -> lib
drwxr-xr-x   2 root     root            0  Dec 16 01:49 usr/sbin
lrwxrwxrwx   1 root     root           11  Dec 16 01:49 usr/sbin/cache_check -> pdata_tools
lrwxrwxrwx   1 root     root           11  Dec 16 01:49 usr/sbin/cache_dump -> pdata_tools
lrwxrwxrwx   1 root     root           11  Dec 16 01:49 usr/sbin/cache_metadata_size -> pdata_tools
lrwxrwxrwx   1 root     root           11  Dec 16 01:49 usr/sbin/cache_repair -> pdata_tools
lrwxrwxrwx   1 root     root           11  Dec 16 01:49 usr/sbin/cache_restore -> pdata_tools
lrwxrwxrwx   1 root     root           11  Dec 16 01:49 usr/sbin/cache_writeback -> pdata_tools
-rwxr-xr-x   1 root     root      1262952  Dec 16 01:49 usr/sbin/dmsetup
lrwxrwxrwx   1 root     root            7  Dec 16 01:49 usr/sbin/dmstats -> dmsetup
lrwxrwxrwx   1 root     root           20  Dec 16 01:49 usr/sbin/dropbear -> ../bin/dropbearmulti
lrwxrwxrwx   1 root     root           11  Dec 16 01:49 usr/sbin/era_check -> pdata_tools
lrwxrwxrwx   1 root     root           11  Dec 16 01:49 usr/sbin/era_dump -> pdata_tools
lrwxrwxrwx   1 root     root           11  Dec 16 01:49 usr/sbin/era_invalidate -> pdata_tools
lrwxrwxrwx   1 root     root           11  Dec 16 01:49 usr/sbin/era_restore -> pdata_tools
-rwxr-xr-x   1 root     root      2905416  Dec 16 01:49 usr/sbin/lvm
-rwxr-xr-x   1 root     root      3061192  Dec 16 01:49 usr/sbin/pdata_tools
-rwxr-xr-x   1 root     root          609  Dec 16 01:49 usr/sbin/resume-boot
lrwxrwxrwx   1 root     root           11  Dec 16 01:49 usr/sbin/thin_check -> pdata_tools
lrwxrwxrwx   1 root     root           11  Dec 16 01:49 usr/sbin/thin_delta -> pdata_tools
lrwxrwxrwx   1 root     root           11  Dec 16 01:49 usr/sbin/thin_dump -> pdata_tools
lrwxrwxrwx   1 root     root           11  Dec 16 01:49 usr/sbin/thin_ls -> pdata_tools
lrwxrwxrwx   1 root     root           11  Dec 16 01:49 usr/sbin/thin_metadata_size -> pdata_tools
lrwxrwxrwx   1 root     root           11  Dec 16 01:49 usr/sbin/thin_repair -> pdata_tools
lrwxrwxrwx   1 root     root           11  Dec 16 01:49 usr/sbin/thin_restore -> pdata_tools
lrwxrwxrwx   1 root     root           11  Dec 16 01:49 usr/sbin/thin_rmap -> pdata_tools
lrwxrwxrwx   1 root     root           11  Dec 16 01:49 usr/sbin/thin_trim -> pdata_tools
-rwxr-xr-x   1 root     root         3076  Dec 16 01:49 usr/sbin/unlock-luks
drwxr-xr-x   3 root     root            0  Dec 16 01:49 usr/share
drwxr-xr-x   2 root     root            0  Dec 16 01:49 usr/share/udhcpc
-rwxr-xr-x   1 root     root         1098  Dec 16 01:49 usr/share/udhcpc/default.script
drwxr-xr-x   3 root     root            0  Dec 16 01:49 var
drwxr-xr-x   2 root     root            0  Dec 16 01:49 var/log
-rw-r--r--   1 root     root            0  Dec 16 01:49 var/log/lastlog
-rw-r--r--   1 root     root            0  Dec 16 01:49 var/log/wtmp
lrwxrwxrwx   1 root     root            6  Dec 16 01:49 var/run -> ../run
========================================================================

The output above shows the e1000.ko file for an Intel NIC, the dropbear executable (usr/bin/dropbearmulti), and the cryptsetup (sbin/cryptsetup) executable have been embedded into the initramfs file.

Manual extraction

To extract a generated initramfs to inspect its content:

root #mkdir /tmp/initramfs
root #cd /tmp/initramfs
root #xzcat /boot/initramfs-5.3.14-gentoo-r1-x86_64-wifitest2.img | cpio -idmv
root #ls -l sbin/cryptsetup
-rwxr-xr-x   1 root     root      2813384  Dec 16 01:49 sbin/cryptsetup
참고
Manual extraction will be difficult if CPU microcode updates have been embedded into the initramfs.

Microcode loading

For microcode (ucode) updates, kernel must support (early-)microcode loading and microcode updates must be present early at boot. See Microcode article for more details.

Microcode loading support in kernel

By default, genkernel will enable microcode loading support in kernel for both, AMD and Intel processors. This behavior can be controlled through MICROCODE option in /etc/genkernel.conf or by using the --microcode=(no|all|amd|intel command-line parameter during invocation.

Embedding microcode updates into initramfs

To embed microcode (ucode) updates into initramfs, MICROCODE_INITRAMFS must be enabled in /etc/genkernel.conf or command-line parameter --microcode-initramfs must be passed at invocation. This will cause genkernel to prepend microcode(s) for selected processor (see --microcode option above) to initramfs in case sys-firmware/intel-microcode with the split-ucode USE flag for Intel processors and/or sys-kernel/linux-firmware for AMD processors is installed.

참고
The technique of embedding microcode updates into the initramfs has been deprecated for modern systems in favor of using bootloaders (like sys-boot/grub) which are capable of loading multiple initramfs files. When using GRUB, or another modern bootloader, it is recommended to install sys-firmware/intel-microcode for Intel and sys-kernel/linux-firmware for AMD processors, both require the initramfs USE flag to be enabled. Let the bootloader load /boot/amd-uc.img and/or /boot/intel-uc.img in addition to genkernel's initramfs. This will enable updating of the CPU microcode independently of kernel/initramfs updates.

Firmware loading

Specific firmware files can easily be added to genkernel's automatically generated initramfs by listing them (with their relative paths) in variable FIRMWARE_FILES in /etc/genkernel.conf. When sys-kernel/genkernel is installed with USE="firmware" it will prefer firmware files from /lib/firmware.

파일 /etc/genkernel.confIncluding firmware in the initramfs
# Add firmware(s) to initramfs
FIRMWARE="yes"
 
# Specify directory to pull from
FIRMWARE_DIR="/lib/firmware"
 
# Specify a comma-separated list of firmware files or directories to include,
# relative to FIRMWARE_DIR.  If empty or unset, the full contents of 
# FIRMWARE_DIR will be included (if FIRMWARE option above is set to YES).
FIRMWARE_FILES="<comma-separated list of firmware files here>"

In case sys-kernel/gentoo-sources is installed with USE="experimental" and the kernel is configured with CONFIG_GENTOO_PRINT_FIRMWARE_INFO=y, the following command gets a comma-separated list of all currently loaded firmware files for the use in the FIRMWARE_FILES variable from /etc/genkernel.conf as illustrated above (the output is just an example):

root #dmesg -t | grep '^Loading firmware*' | sed 's/^Loading\sfirmware:\s//' | echo $(cat) | tr ' ' ','
amdgpu/green_sardine_sdma.bin,amdgpu/green_sardine_asd.bin,amdgpu/green_sardine_ta.bin,amdgpu/green_sardine_pfp.bin,amdgpu/green_sardine_me.bin,amdgpu/green_sardine_ce.bin,amdgpu/green_sardine_rlc.bin,amdgpu/green_sardine_mec.bin,amdgpu/green_sardine_dmcub.bin,amdgpu/green_sardine_vcn.bin,regulatory.db,regulatory.db.p7s,rtw89/rtw8852a_fw.bin,rtl_bt/rtl8852au_fw.bin,rtl_bt/rtl8852au_config.bin,rtl_nic/rtl8168h-2.fw

It is also possible to incorporate the firmware into the kernel image directly, but be aware that CONFIG_EXTRA_FIRMWARE in the kernel configuration file .config (normally found in /usr/src/linux) requires a space-separated list (output example):

root #dmesg -t | grep '^Loading firmware*' | sed 's/^Loading\sfirmware:\s//' | echo $(cat)
amdgpu/green_sardine_sdma.bin amdgpu/green_sardine_asd.bin amdgpu/green_sardine_ta.bin amdgpu/green_sardine_pfp.bin amdgpu/green_sardine_me.bin amdgpu/green_sardine_ce.bin amdgpu/green_sardine_rlc.bin amdgpu/green_sardine_mec.bin amdgpu/green_sardine_dmcub.bin amdgpu/green_sardine_vcn.bin regulatory.db regulatory.db.p7s rtw89/rtw8852a_fw.bin rtl_bt/rtl8852au_fw.bin rtl_bt/rtl8852au_config.bin rtl_nic/rtl8168h-2.fw
참고
Such a list will only be complete if the drivers successfully load all the required firmware(s): In case a driver requires more than one firmware file but fails loading the first one, only this will be listed and thereby other required firmware filenames will be missing. A recommended procedure to find all required firmware files is to compile the respective drivers as modules first, M in the kernel configuration, and to not have them included in the initramfs. This way they will be loaded after the switch to the real / (root) directory, where all firmware files will be available from sys-kernel/linux-firmware (and others) under /lib/firmware. When a system boots successfully with this method, running the above command will gather a complete list of the required firmware files. They may then be included in the initramfs (or the kernel itself), allowing for the drivers to be compiled directly into the kernel, * in the kernel configuration, or to include the drivers as kernel modules in the initramfs as well. In both cases loading the modules will be earlier and it will be successful with the availability of the firmware files in the initramfs, which must be loaded alongside the kernel e.g. using GRUB.

Remote rescue shell

genkernel can embed the net-misc/dropbear SSH daemon into the initramfs which will allow fixing certain things on boot remotely when initramfs is at least able to load. The most common used feature will be remote unlock capability for LUKS-encrypted root or swap devices or ZFS volumes.

Pre-requirement for SSH daemon support in initramfs

A authorized_keys file must exist before genkernel will be invoked. By default, genkernel will look for /etc/dropbear/authorized_keys. Command-line argument --ssh-authorized-keys-file=/path/to/custom/authorized_keys or genkernel configuration option SSH_AUTHORIZED_KEYS_FILE can be used to alter default value.

요령
Create /etc/dropbear/authorized_keys as a symlink to /root/.ssh/authorized_keys for example to keep root access and remote rescue shell access in sync!

Adding SSH support to initramfs

To embed SSH daemon into genkernel's initramfs, run genkernel with --ssh command-line argument or set SSH="yes" in genkernel configuration file. Needless to mention that this feature will require working network at boot. The following example will just (re-)build initramfs with SSH daemon embedded:

root #genkernel --ssh initramfs
* Gentoo Linux Genkernel; Version 4.0.1
* Using genkernel configuration from '/etc/genkernel.conf' ...
* Running with options: --ssh initramfs

* Working with Linux kernel 5.3.14-gentoo-r1-x86_64 for x86_64
* Using kernel config file '/etc/kernels/kernel-config-5.3.14-gentoo-r1-x86_64' ...

* initramfs: >> Initializing ...
*         >> Appending devices cpio data ...
*         >> Appending base_layout cpio data ...
*         >> Appending auxilary cpio data ...
*         >> Appending blkid cpio data ...
*         >> Appending busybox cpio data ...
*         >> Appending dropbear cpio data ...
=================================================================
This initramfs' sshd will use the following host key(s):
256 MD5:a5:13:09:90:5b:f6:a1:95:49:9f:87:d9:fa:e5:d8:02 (ECDSA)
256 SHA256:5dxNGEOwH9hvX4+sV4WtzRV/9m8/hrhgnNtTplZf5x8 (ECDSA)
2048 MD5:1d:e6:cc:ce:c8:96:a0:73:3e:4c:2a:56:ce:b9:10:26 (RSA)
2048 SHA256:V4WrMKhfVSxSeW3XIbW8dSaAmXiwN6jiMA/geNKLcqA (RSA)
=================================================================
*         >> Appending modprobed cpio data ...
*         >> Appending modules cpio data ...
*         >> Appending linker cpio data ...
*         >> Deduping cpio ...
*         >> Pre-generating initramfs' /etc/ld.so.cache ...
*         >> Compressing cpio data (.xz) ...
*
* You will find the initramfs in '/boot/initramfs-5.3.14-gentoo-r1-x86_64.img'.

* WARNING... WARNING... WARNING...
* Additional kernel parameters that *may* be required to boot properly:
* - Add "dosshd" to start SSH daemon in initramfs

* Do NOT report kernel bugs as genkernel bugs unless your bug
* is about the default genkernel configuration...
*
* Make sure you have the latest ~arch genkernel before reporting bugs.
참고
By default, genkernel will generate own, dedicated SSH host keys for any missing supported key algorithm for embedded SSH daemon. This will allow to differentiate between real system's SSH daemon and initramfs' SSH daemon. To use host's SSH host keys instead or generate new keys at runtime on each boot use --ssh-host-keys command-line option and see genkernel's man page for more details.

Enabling SSH daemon on boot

Just adding SSH daemon to initramfs is not enough. Because exposing any network service could be a security risk, this feature must be enabled via the kernel command-line argument dosshd! See Configure Network for how to configure network in genkernel.

Remote unlock

There are two possibilities to unlock LUKS-encrypted root and/or swap volume: A manual way, through an SSH connection, run a command and will get prompted for passphrase(s) or an automatic way where user passes passphrase through SSH as command.

참고
This will require a kernel/initramfs generated with --luks command-line argument and kernel must be booted with crypt_root (and/or crypt_swap) kernel command-line argument. ZFS user must generate kernel/initramfs with --zfs command-line argument and kernel must be booted with dozfs kernel command-line argument.
Manual unlock

Connect to the remote system through SSH and run the following commands:

user $ssh root@remote-system-running-genkernel-initramfs-with-dosshd
>> Welcome to Genkernel 4.0.1 (2019-12-16 22:34:14 UTC) remote rescue shell!
>> ...running Linux kernel 5.3.14-gentoo-r1-x86_64

>> The lockfile '/tmp/remote-rescueshell.lock' was created.
>> In order to resume boot process, run 'resume-boot'.
>> Be aware that it will kill your connection which means
>> you will no longer be able to work in this shell.
>> To remote unlock LUKS-encrypted root device, run 'unlock-luks root'.

remote rescueshell ~ # unlock-luks root
>> Detected real_root as a md device. Setting up the device node ...
Enter passphrase for /dev/md126:
>> LUKS device /dev/md126 opened
remote rescueshell ~ # resume-boot
>> Resuming boot process ...
참고
In this example, system was booted with just crypt_root= set in kernel command-line. In case system was booted with crypt_swap= there will be an additional prompt regarding how to unlock swap. ZFS user will get prompted to use unlock-zfs command instead.
Automatic unlock

It's basically the same like manual unlock just without the need to manually run resume-boot. In case user has both, encrypted root and swap volume, user must unlock swap volume first:

user $cat /path/to/secret.key/on/local/disk | ssh root@remote-system-running-genkernel-initramfs-with-dosshd post root
>> Detected real_root as a md device. Setting up the device node ...
>> LUKS device /dev/md126 opened
>> Resuming boot process ...
참고
Automatic unlock is not available for ZFS users.

네트워크 부팅하기

설치 CD로 네트워크 부팅하기

genkernel 유틸리티에서는 네트워크 부팅을 지원하는 커널 및 initrd 이미지를 만들 수 있습니다. 행운을 위해, 사용자는 설치 CD에서 제공한 환경에서 어떤 최근에 가동을 진행한 컴퓨터로든 네트워크 부팅을 할 수 있어야합니다.

마법은 genkernel의 linuxrc 스크립트에 있습니다: NFS를 사용한 설치 CD의 넷 마운트를 시도합니다. 이렇게 하여, 설치 CD가 로컬에 존재하여 설치 CD의 init 스크립트가 동작하는 것처럼 동작합니다.

넷부팅을 지원하는 커널과 Initrd 이미지 빌드

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

경고
genkernel의 넷부팅 기능은 시험 단계이며 버그가 있습니다.

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

커널 다양한 NIC 드라이버를 지원하는 3.x.x 버전대 커널 설정
'"`UNIQ--pre-00000023-QINU`"'
참고
<M>이 아닌 <*> 로 선택했는지 확인하십시오.

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

커널 DHCP를 지원하는 3.x.x 버전대 커널 설정
'"`UNIQ--pre-00000026-QINU`"'

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

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

커널 SquashFS를 지원하는 커널 설정
'"`UNIQ--pre-00000029-QINU`"'

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

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

root #cd /
root #tar -cf /tmp/modules-X.Y.Z.tar.gz /lib/modules/X.Y.Z/

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

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

root #emerge --ask net-misc/mknbi
root #cd /boot
root #mkelf-linux -params="root=/dev/ram0 init=/linuxrc ip=dhcp" kernel... initrd... > etherboot.img

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

root #emerge --ask sys-apps/sparc-utils
root #cd /boot
root #elftoaout kernel... -o kernel.aout
root #piggyback64 kernel.aout System.map-... initrd-...
root #mv kernel.aout openboot.img

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

마지막으로 TFTP 서버로 커널을 복사하십시오. 아키텍처별 상세 내용은 이 안내서의 범위를 벗어납니다. 플랫폼 별 관심 내용은 해당 문서를 참고하십시오.

NFS 설정

설치 CD를 띄운 NFS 공유를 설정하려면, 루프 장치를 활용하여 ISO 이미지를 마운트하고 NFS 공유를 통해 CD의 내용을 복사합니다. 괜찮은 추가 선택지가 있다면 genkernel의 initrd 스크립트에서 /nfs/livecd/add/ 디렉터리 경로의 모든 tar.gz 파일을 압축해제합니다. 여기서 /nfs/livecd/add/ 디렉터리에 modules-X.Y.Z.tar.gz 아카이브를 복사하기만 하면 됩니다.

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

root #mount /tmp/gentoo-livecd.iso /mnt/cdrom -o loop
root #cp -p /mnt/cdrom /nfs/livecd
root #umount /mnt/cdrom

이제 modules.tar.gz 파일을 /add에 복사하십시오:

root #mkdir /nfs/livecd/add
root #cp /tmp/modules-X.Y.Z.tar.gz /nfs/livecd/add

DHCP 설정

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

파일 /etc/dhcpd.conf예제 dhcpd.conf 클라이언트 설정
# Here, 192.168.1.2 is the NFS server while 192.168.1.10 will be the IP address of the netbooted machine
host netbootableMachine {
         hardware ethernet 11:22:33:44:55:66;
         fixed-address 192.168.1.10;
         option root-path "192.168.1.2:/nfs/livecd";
}

넷부팅 절차

넷부팅은 플랫폼 별로 다릅니다. 여기서 중요한 부분은 커널 명령줄의 ip=dhcpinit=/linuxrc 매개 변수이며, 이 매개변수를 통해 네트워크 인터페이스 동작을 활성화하고 initrd 스크립트로 하여금 NFS를 통해 설치 CD에 마운트하라고 지시합니다. 플랫폼별 요령을 안내해드리겠습니다.

etherboot 방식을 진행하려면 etherboot 디스크를 드라이브에 넣고 다시 부팅하십시오. 이미지를 만들었다면 커널 명령행을 이미 지정했습니다.

Spart64에서는 부팅 프롬프트에서 Stop+A 키를 누르고 Enter 키를 누르십시오:

okboot net ip=dhcp init=/linuxrc

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

파일 pxelinux.cfg/default기본 항목
DEFAULT gentoo
TIMEOUT 40
PROMPT 1
  
LABEL gentoo
    KERNEL kernel-X.Y.Z
    APPEND initrd=initrd-X.Y.Z root=/dev/ram0 init=/linuxrc ip=dhcp

genkernel initramfs 부팅

도입부

initramfs를 genkernel로 설치하면, 부트로더에서 설정할 수 있는(해야 할) 다양한 부팅 옵션을 살펴보십시오. 대부분은 이 안내서에 추가했습니다.

LVM 또는 소프트웨어-RAID 불러오기

LVM 또는 software-RAID를 사용중이라면 --lvm--mdadm 옵션을 활용하여 initramfs에 기능을 추가하여 빌드해야 합니다. 마찬가지로 부팅하는 동안의 기능 활성화를 잊지마십시오. dolvm, domdadm 옵션으로 설정할 수 있습니다.

파일 /boot/grub/grub.confLVM 또는 MDADM 지원 활성화
# Example for GRUB 1.x
title Gentoo Linux
root (hd0,0)
kernel /vmlinuz root=/dev/md3 dolvm domdadm
initrd /initramfs-genkernel-x86_64-3.4.3
단일 사용자 모드 부팅

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

파일 /boot/grub/grub.conf단일 사용자 모드로 부팅
# Example for GRUB 1.x
title Gentoo Linux
root (hd0,0)
kernel /vmlinuz root=/dev/md3 init_opts=S
initrd /initramfs-genkernel-x86_64-3.4.3

Cross-compile support

To build kernel and/or initramfs for a different platform as genkernel is being executed on, kernel/initramfs must be cross-compiled.

root #genkernel --mdadm --no-install --cross-compile=aarch64-linux-gnu all

The above command causes genkernel to create a kernel supporting MD raid and embed mdadm into initramfs (--mdadm), both kernel and initramfs will have to be manually installed (--no-install). The kernel and programs embedded into initramfs will run on arm64 (--cross-compile=aarch64-linux-gnu).

--cross-compile=<target triplet>
Target triple (i.e. aarch64-linux-gnu) to build for. Only needed when the system running genkernel has a different architecture like the system which should boot the created kernel/initramfs.
요령
The recommended way to create a cross-compile environment is using sys-devel/crossdev. See the how to create a cross-compile environment article for more details.

Initramfs kernel command-line parameters

참고
The following parameter list is just an excerpt. Always check man genkernel from the version you are using.
root=<...>
Specifies the device node of the root filesystem to mount. I.e. root=/dev/sda3, root=UUID=a1e5968c-bd1b-41ee-bf08-2d0ed376fa83.
cdroot
This attempts to load livecd.squashfs and is used for loading live media.
crypt_root=<...>
This specifies the device encrypted by LUKS, which contains the root filesystem to mount. Supports same syntax like root kernel command-line parameter from above.
참고
Will require that at least initramfs was built with --luks option set.
crypt_swap=<...>
This specifies the swap device encrypted by LUKS. For more details please see crypt_root kernel command-line parameter from above.
root_trim=(yes|no)
Enables TRIM support for a LUKS-based root device.
참고
Will require that at least initramfs was built with --luks option set and is only useful for flash-based volumes.
ip=<dhcp,addr/cidr>
Normally used to tell the kernel that it should start a network interface which can be specified using gk.net.iface kernel parameter. By default, dhcp will be used. You can set a specific IP address using addr/CIDR notation, i.e. 1.2.3.4/24.
gk.net.dhcp.retries=<...>
By default we will send up to 3 DHCP discovery requests.
gk.net.iface=<interface,macaddr>
By default we will use the interface named eth0. Use this kernel parameter to specify another interface.
You can also specify a MAC address (00:00:00:00:00:00 format) instead of an interface name.
gk.net.gw=<...>
Optional gateway. If ip is set to dhcp, this kernel parameter will be ignored.
gk.net.routes=<...>
Optional additional routes. If ip is set to dhcp, this kernel parameter will be ignored.
gk.net.timeout.dad=<...>
By default we will wait up to 10 seconds for IPv6's DAD to complete. At the moment, we only wait for DAD while bringing down an interface to prevent a race condition.
gk.net.timeout.deconfiguration=<...>
By default we will wait up to 10 seconds while bringing down an interface to prevent a race condition.
gk.net.timeout.dhcp=<...>
By default we will wait up to 10 seconds for a DHCP server reply.
gk.net.timeout.interface=<...>
By default we will wait up to 10 seconds for interface to show up.
gk.prompt.timeout=<...>
By default a prompt within genkernel initramfs like shown when set root could not be found will never timeout. Use this option to set a timeout.
참고
When dosshd is used, gk.prompt.timeout will be set to 30 seconds when not set. This will allow remote user to provide answer through GK_PROMPT_FILE which is set to /tmp/current_prompt by default.
dosshd
Will bring up an interface and start a SSH daemon within initramfs allowing to remotely unlock encrypted devices or just for debugging purpose. See ip option for how to configure network.
참고
Will require that initramfs was built at least with --ssh option set.
gk.sshd.port=<...>
By default, sshd will listen on port 22.
gk.sshd.wait=<...>
Wait X seconds after setting up sshd, useful when you want to login (and thus pause boot process) before booting real system.
dolvm
Activate LVM volumes on bootup.
참고
Will require that initramfs was built at least with --lvm option set.
lvmraid=<...>
Specify RAID devices to set up before the activation of LVM volumes. Implies option dolvm from above.
domdadm (Deprecated in Genkernel 4.2.0, udev rules now control MD assembly)
Scan for RAID arrays on bootup.
참고
Will require that initramfs was built at least with --mdadm option set.
dozfs[=cache,force]
Scan for bootable ZFS pools on bootup. Optionally use cachefile or force import if necessary or perform both actions.
참고
Will require that initramfs was built at least with --zfs option set.
gk.log.disabled=<...>
By default, any shown message and external command calls will be logged to /tmp/init.log in initramfs. This boolean option allows you to disable logging for some reason.
gk.log.keep=<...>
When set to a boolean value, genkernel will preserve /tmp/init.log, see above, and copy file to /genkernel-boot.log on root device (see root or real_root kernel command-line parameter above). You can also set your own file like /root/my-genkernel-boot.log to copy log to a custom path.
참고
The default file /genkernel-boot.log on root was chosen because genkernel's initramfs will only mount root filesystem by default. If you want to store the log file in /var/log/genkernel-boot.log for example make sure that this mountpoint is accessible, see /etc/initramfs.mounts.
gk.hw.load-all=<...>
By default, genkernel loads various module groups (nvme, sata, scsi, pata, usb...) until block device specified in root parameter (see above) becomes available. This boolean option can be used to force loading of all module groups regardless whether root device is already available when set to yes.

문제 해결

Can I use genkernel for systemd-based systems?

Yes.

Genkernel? Genkernel-next? Dracut?

참고
sys-kernel/genkernel-next has been removed from the Gentoo repository as of August, 20, 2020

Gentoo is about choices. sys-kernel/genkernel-next was created as fork of sys-kernel/genkernel when genkernel development was stuck, booting a systemd-based system using kernel/initramfs created with sys-kernel/genkernel was a problem (systemd support in sys-kernel/genkernel is fixed for quite some time) and some developers wanted support for things like sys-boot/plymouth which requires sys-fs/udev which was not and still is not compatible with genkernel's main idea (see "Note" right at the beginning of this article). While the name suggests that sys-kernel/genkernel-next is or will be the successor of sys-kernel/genkernel, it is just misleading: Since 2013 there are some requests to merge genkernel-next back into genkernel but the process became stuck. Since the release of sys-kernel/genkernel-4 which changed a lot and the fact that there was no progress in sys-kernel/genkernel-next development since 2018, it's now very unlikely that genkernel-next will ever merge back into genkernel.

sys-kernel/dracut in comparison to sys-kernel/genkernel is just a generic tool for creating an initramfs. It cannot help you with creating a kernel like genkernel does. I.e. while both, genkernel and dracut supports booting from LUKS-encrypted root volume, only genkernel will ensure that kernel will have all required options set. It's also worthwhile to mention that genkernel will compile most packages (LVM, cryptsetup, mdadm, sshd...) used in initramfs on its own whereas dracut will copy binaries from host system which can be a problem for some setups. That's also the reason why you can use genkernel to create kernel/initramfs for another system (cross-compile) which isn't supported in dracut or genkernel-next.

How do I create a separate kernel/initramfs to test something?

root #genkernel --kernel-config=/proc/config.gz --kernel-append-localversion=-test42 --menuconfig all

The above command causes genkernel to build a new kernel and initramfs (all) based on config from current running kernel (--kernel-config=/proc/config.gz), invoke menuconfig (--menuconfig) allowing user to adjust configuration and will append -test42 to kernel's LOCALVERSION variable (--kernel-append-localversion=-test42) which will affect naming of kernel image, modules dir and initramfs by default.

How do I rebuild external modules (such as xtables-addons, nvidia-drivers...) for new kernel?

By default, genkernel will call emerge @module-rebuild when building a kernel to ensure that out-of-tree modules installed through the package manager are still present in new/rebuilt kernel. This feature can be toggled via --[no-]module-rebuild command-line argument or MODULEREBUILD in /etc/genkernel.conf.

How do I run additional commands after kernel has been built?

Genkernel provides a callback for that (before version 4, callback was used to rebuild external modules). See CMD_CALLBACK in /etc/genkernel.conf for more details.

How do I use ccache or distcc with genkernel?

Set up ccache or distcc the normal way like you would do for sys-apps/portage. Now you set --kernel-cc command-line parameter or adjust KERNEL_CC in /etc/genkernel.conf for the tool you want to use. Do the same for UTILS_CC (--utils-cc) and UTILS_CXX (--utils-cxx).

ERROR: compile_kernel(): compile_generic() failed to compile the "bzImage" target!

Check /var/log/genkernel.log first. In most cases, a root cause will appear like:

파일 /var/log/genkernel.log
[...]
  AR      drivers/usb/built-in.a
  AR      drivers/built-in.a
  GEN     .version
  CHK     include/generated/compile.h
  AR      built-in.a
  LD      vmlinux.o
  MODPOST vmlinux.o
ld: .tmp_vmlinux1: final close failed: No space left on device
make: *** [Makefile:1032: vmlinux] Error 1
 
* ERROR: compile_kernel(): compile_generic() failed to compile the "bzImage" target!
* Please consult '/var/log/genkernel.log' for more information and any
* errors that were reported above.
*
* Report any genkernel bugs to bugs.gentoo.org and
* assign your bug to genkernel@gentoo.org. Please include
* as much information as you can in your bug report; attaching
* '/var/log/genkernel.log' so that your issue can be dealt with effectively.
*
* Please do *not* report kernel compilation failures as genkernel bugs!
*
 
* mount: >> Boot partition state on '/boot' was not changed; Skipping restore boot partition state ...
>>> Ended on: 2019-12-16 02:30:19 (after 0 days 0 hours 07 minutes 49 seconds)
</pre>

In other words: The system has run out of disk space (No space left on device) during compilation.

To guard against problems like this set CHECK_FREE_DISK_SPACE_BOOTDIR=50 and CHECK_FREE_DISK_SPACE_KERNELOUTPUTDIR=4000 in /etc/genkernel.conf in which case genkernel would fail early with a message like

root #genkernel --kernel-config=/proc/config.gz all
* Gentoo Linux Genkernel; Version 4.0.1
* Using genkernel configuration from '/etc/genkernel.conf' ...
* Running with options: --kernel-config=/proc/config.gz all
 
* Working with Linux kernel 4.19.89-gentoo-x86_64 for x86_64
* Using kernel config file '/proc/config.gz' ...
*
* Note: The version above is subject to change (depends on config and status of kernel sources).
* ERROR: 4000 MB free disk space is required in '/usr/src/linux' but only 1026 MB is available!
[...]

Is the order of kernel command-line arguments important?

No.

Help! Something isn't working!

To report a problem, please always provide /var/log/genkernel.log (sometimes it maybe necessary to compress that file before sharing or attaching to bugs) which will help developers a lot. Even if the command is run with --loglevel=1 (default), the logfile will always contain complete output (no need to re-run with logging turned on) which will help developers to understand, reproduce and maybe fix a bug.

추가 참조

  • 직접 커널 설정 - 가끔은 직접 설정해야 하기도 합니다.
  • Dracut - 젠투에서 활용할 수 있는 또 다른 initramfs 빌더입니다.

This page is based on a document formerly found on our main website gentoo.org.
The following people contributed to the original document: Tim Yamin, Jimi Ayodele, Thomas Seiler, Joshua Saddler (nightmorph), Sebastian Pipping (sping) , José Fournier (jaaf)
They are listed here because wiki history does not allow for any external attribution. If you edit the wiki article, please do not add yourself here; your contributions are recorded on each article's associated history page.