Install Gentoo on a bootable USB stick/ko

Booting Gentoo from a USB stick is really quite simple. The main challenge is to setup an initial ramdisk and to include the drivers for all the machines it is going to boot. This article will describe how to install Gentoo onto a USB stick that can be booted on any computer. This installation will be just like a regular desktop installation and changes will be persistent.

준비
몇가지 꾸러미를 설치하는 과정으로 시작하겠습니다. 여기서 중요한 대부분의 요소는 커널과 꾸러미입니다.

꾸러미별 USE 플래그를 추가하려면 에 새 파일을 만드십시오:

이제 꾸러미를 설치하십시오:

커널 컴파일
커널에 필요한 설정을 적용하고 컴파일 하십시오. 과정상 자세한 내용은커널 설정과 커널 설정 안내서를 참고하십시오. 여기서는 일반 커널이 더 많은 머신에서 부팅할 테므로 일반 커널을 활용하는게 좋음을 확실히 기억해두십시오.

During the configuration, it is of course possible to compile modules as these will be included in the initramfs and loaded at boot.

The above command will take some time as it will build the default kernel, create a ramdisk and then copy all files into.

USB 메모리 스틱 준비
Create 2 partitions on the drive (assuming the installation will have a and a  (root) partition). We assume that the USB stick is at (run dmesg immediately after plugging in the USB stick to see which device is being used).

첫번째 분할 공간을 부팅이 가능하게(명령으로 부팅 플래그 상태를 바꿈)했는지 확인하십시오

Now format the new partitions. In the example we use the ext2 file system but another file system for the partition can be used if it is supported in the kernel. Notice that during the formatting operation, a label is assigned to the partitions. This is important because it will be how the root file system is detected later as the USB stick can be booted on systems where the drive letter allocation is completely different. This is related to the  option of the genkernel command line earlier.

젠투 스테이지 3 설치
With the kernel, ramdisk and file systems ready, we now need the minimal installation to be performed. This includes a fresh stage3 as well as a Portage tree snapshot.


 * current-stage3
 * portage-latest

For this example and  are used. This next bit is the same as in the handbook for installing Gentoo.

The sections below cover those aspects of a Gentoo Linux installation that are specific to installing on an USB stick. It is recommended to use the Gentoo handbook instructions while keeping an eye on this article.

부트로더
In order to boot the new system, install a bootloader on the USB stick.

The below sections give example configurations for lilo and syslinux.

lilo
lilo를 (chroot 한 상태에서) 이머지하십시오:

파일을 편집하여 올바른 정보가 들어가도록 하십시오.

The lines after image are all easy but the append line contains some interesting options.


 * will use the label of the disk instead of which is important because these device numbers move around depending on the number of hard disks in the computer or number of USB disk drives.
 * Also important for USB booting is the  option, as USB devices need a little time to be detected by the kernel; that is what this option is for. When there are lots of modules booting takes a long time so it probably does not matter, but if there are only a few modules loaded then it is important, because the system could have booted before the kernel detects the USB device. Also, on newer machines with USB3 controllers it is necessary to add the xhci_hcd driver (built into the kernel or as a module).

이제 LILO(및 설정)를 USB 메모리 스틱에 설치하십시오:

The first warning is to be expected as we are not installing the boot loader onto the hard disk in the computer. The second warning will only cause a problem on machines that are old; if it is a problem try cutting down the kernel by removing modules.

syslinux
Put the boot sector onto the USB stick.

이제 부트로더를 설정하겠습니다.

Next install syslinux onto the USB stick. The  option is not absolutely necessary though.

요령
Although it is possible to use the system just made as a standard Gentoo system, it might be worthwhile to compile binary packages on a host and then installing them on the USB stick. Or if the system has enough memory just mount to a tmpfs, as compilation will be much quicker that way anyway!