Install Gentoo on a bootable USB stick/ko

From Gentoo Wiki
Jump to:navigation Jump to:search
This page is a translated version of the page Install Gentoo on a bootable USB stick and the translation is 62% complete.
Outdated translations are marked like this.

USB 메모리 스틱으로 젠투를 부팅하는 방법은 정말 쉽습니다. 주로 해볼만한 과정은 모든 머신에서 젠투를 부팅할 수 있게 초기화 램 디스크를 설정하는 부분입니다. 이 글에서는 어떤 컴퓨터에서든 USB 메모리 스틱으로 젠투를 설치하는 방법을 설명합니다. 이 설치 과정은 보통의 데스크톱 설치 과정과 유사하며 이렇게 바꾼 내용은 계속 남아있습니다.

참고
This article covers installation of a complete, functional, Gentoo system onto a USB drive. See the LiveUSB article for instructions on creating a simple bootable drive, that can for example be used for Gentoo installation.

준비

참고
이 지침에서는 현재 플랫폼이 젠투 리눅스 하나만 있다고 간주합니다. 하지만 주된 단계는 어떤 배포판에서든 젠투에서 하던 방식(프로그램 설치 등)대로 바꾸면 진행할 수 있습니다.

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

root #emerge --ask sys-kernel/gentoo-sources sys-kernel/genkernel

커널 컴파일

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

설정 과정에서 이와 같이 모듈을 initramfs에 포함하여 컴파일할 수 있고 부팅 과정에서 불러올 수 있습니다.

root #mkdir /tmp/boot

위 명령은 기본 커널을 빌드하고 램 디스크를 만든 다음 /tmp/boot에 모든 파일을 복사합니다.

root #ls /tmp/boot/
initramfs-genkernel-x86_64-3.5.2-gentoo
kernel-genkernel-x86_64-3.5.2-gentoo
System.map-genkernel-x86_64-3.5.2-gentoo

USB 메모리 스틱 준비

드라이브에 분할 공간을 두개 만듭니다(/boot/(루트) 파티션을 설치한다고 가정). USB 메모리 스틱은 /dev/sdb(USB 메모리 스틱을 장착한 다음 dmesg 명령을 바로 실행하면 어떤 장치가 USB 메모리 스틱인지 확인)에 있다고 가정합니다.

root #fdisk /dev/sdb
Command (m for help): d
Selected partition 1
 
Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-4001759, default 2048): 
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-4001759, default 4001759): +100M
 
Command (m for help): n
Partition type:
   p   primary (1 primary, 0 extended, 3 free)
   e   extended
Select (default p): p
Partition number (1-4, default 2):  
Using default value 2
First sector (206848-4001759, default 206848): 
Using default value 206848
Last sector, +sectors or +size{K,M,G} (206848-4001759, default 4001759): 
Using default value 4001759
 
Command (m for help): a
Partition number (1-4): 1
 
Command (m for help): p
 
Disk /dev/sdb: 2048 MB, 2048901120 bytes
255 heads, 63 sectors/track, 249 cylinders, total 4001760 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x001663df
 
   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *        2048      206847      102400   83  Linux
/dev/sdb2          206848     4001759     1897456   83  Linux
 
Command (m for help): w
The partition table has been altered!
 
Calling ioctl() to re-read partition table.
Syncing disks.

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

이제 새 파티션을 포맷하십시오. 여기서는 ext2 파일 시스템을 쓰지만 커널에서 지원하는 파일 시스템으로 /파티션을 포맷할 수 있습니다. 참고로 포맷 과정에서 파티션에 레이블을 할당합니다. 이 과정은 드라이브 문자 할당이 완전히 다른 USB 메모리 스틱의 루트 파일 시스템을 감지하는 수단이 되기 때문에 중요합니다. 이전에 언급했던 genkernel 명령의 --disklabel 옵션과 관련이 있습니다.

root #mkfs.ext2 -L GENTOO_USB_BOOT /dev/sdb1
root #mkfs.ext2 -L GENTOO_USB_ROOT /dev/sdb2

젠투 스테이지 3 설치

커널, 램 디스크, 파일 시스템을 준비하고 나면 최소한의 설치를 진행해야합니다. 포티지 트리 스냅샷 같은 곳에 최신 스테이지 3가 들어있습니다.

이 예제에서 stage3-amd64-20120621.tar.bz2portage-latest.tar.xz 를 사용하겠습니다. 이 다음 부분은 젠투 설치 핸드북에 있는 내용과 약간 비슷합니다.

root #mount /dev/sdb2 /mnt/gentoo
root #cd /mnt/gentoo
root #tar -xpf ~/Download/stage3-amd64-20120621.tar.bz2
root #cd usr
root #tar -xpf ~/Download/portage-latest.tar.xz
root #mount /dev/sdb1 /mnt/gentoo/boot
root #cp /tmp/boot/* /mnt/gentoo/boot

다음 장에서는 USB 메모리 스틱에 개별적으로 젠투 리눅스를 설치하는 양상을 다룹니다. 이 글의 내용을 진행하는 동안 젠투 핸드북을 활용하시면 좋습니다.

부트로더

새 시스템으로 부팅하려면 USB 메모리 스틱으로 부트로더를 설치하십시오.

아래에는 lilosyslinux의 예제 설정을 제시했습니다.

GRUB

경고
This method only applies to UEFI booting!

Emerge GRUB (from within the chroot):

(chroot) #emerge sys-boot/grub

Install GRUB to corresponding place with your platform information. Suppose you are running x86_64 machine with EFI partition mounted to /boot/efi, the following command will install GRUB into the USB stick:

(chroot) #grub-install --efi-directory=/boot/efi --target=x86_64-efi --removable
경고
Note that the --removable option is very important. It indicates that the target location is removable device. Don't forget it otherwise you may mess up your own system!

If nothing bad happens, run grub-mkconfig to generate the GRUB configuration:

(chroot) #grub-mkconfig -o /boot/grub/grub.cfg

Change the target directory accordingly if you use a different GRUB config directory.

lilo

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

(chroot) #emerge sys-boot/lilo

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

경고
이 설정은 상당히 중요해서 한 줄씩 언급해 나가겠습니다.
파일 /etc/lilo.confConfigure lilo.conf
boot=/dev/sdb              # The location of the USB Stick (currently)
lba32                      # use lba32 addressing (ignore)
compact                    # boot quickly by loading lots of blocks
                           # remove when there are problems with booting
prompt                     # Prompt for user input
timeout=20                 # Time to wait before default selection
default="Gentoo-352"       # Default selection after timeout
  
image=/boot/kernel-genkernel-x86_64-3.5.2-gentoo
	label="Gentoo-352"
	read-only
	root=/dev/ram0
	append="real_root=LABEL=GENTOO_USB_ROOT scandelay=5"
	initrd=/boot/initramfs-genkernel-x86_64-3.5.2-gentoo

이미지 다음에 나타나는 줄은 다루기 쉽지만, 추가로 붙어있는 줄에는 볼만한 옵션을 넣었습니다.

  • real_root=LABEL=GENTOO_USB_ROOT는 하드 디스크의 수와 USB 메모리 스틱 드라이브 수에 따라 장치 번호를 결정하기 때문에 /dev/sdb2 대신 다른 디스크 레이블을 사용합니다.
  • 또한 USB 메모리 스틱 부팅에 중요한 점은, USB 장치에서 커널을 찾는데 필요한 약간의 시간을 확보하기 위한 scandelay 옵션의 활용입니다. 부팅하는데 불러올 모듈이 많아 시간이 좀 걸린다면 문제되지 않겠지만, 모듈이 별로 없다면 커널에서 USB 장치를 감지하기 전에 시스템을 부팅해야 하기 때문에 중요합니다. 또한 USB 3.0 컨트롤러가 붙어있는 최신 장치라면 xhci_hcd 드라이버(커널에 넣어 빌드하거나 모듈로 빌드)를 추가해야합니다.

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

(chroot) #lilo
Warning: /dev/sdb is not on the first disk
Warning: The initial RAM disk is too big to fit between the kernel and
   the 15M-16M memory hole.  It will be loaded in the highest memory as
   though the configuration file specified "large-memory" and it will
   be assumed that the BIOS supports memory moves above 16M.
Added Gentoo-352 ? *
2 warnings were issued.

처음 나타나는 경고는 컴퓨터의 하드디스크에 부트로더를 설치하지 않기 때문에 나타나는 내용입니다. 두번째 경고 내용은 오래된 머신일 경우 문제가 발생합니다. 문제가 발생한다면 모듈을 제거해서 커널 규모를 줄여나가보십시오.

syslinux

경고
syslinux는 현재 ext{2,3,4}, btrfs, ntfs, fat 파일 시스템에서만 동작합니다.
(chroot) #emerge syslinux

USB 메모리 스틱에 부팅 섹터를 설정하십시오.

(chroot) #dd bs=440 count=1 conv=notrunc if=/usr/share/syslinux/mbr.bin of=/dev/sdb

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

(chroot) #mkdir /boot/syslinux
(chroot) #nano -w /boot/syslinux/syslinux.cfg
파일 /boot/syslinux/syslinux.cfg
PROMPT 1
TIMEOUT 50
DEFAULT gentoo
 
LABEL gentoo
        LINUX ../kernel-genkernel-x86_64-3.5.2-gentoo
        APPEND root=LABEL=GENTOO_USB_ROOT scandelay=3 ro
        INITRD ../initramfs-genkernel-x86_64-3.5.2-gentoo
참고
APPEND 줄의 ro는 는 루트 파티션을 (USB 메모리 스틱에 알맞은) 읽기 전용으로 마운트합니다. 부팅 과정에서 사용자가 (파일 시스템을 나중에 읽기/쓰기 모드로 마운트할 가능성이 있어) 시스템을 다룰 수 있게 하려면, rorw로 바꾸십시오.

다음 syslinux를 USB 스틱에 설치하십시오. --device /dev/sdb1 옵션을 그대로 따라 입력할 필요는 없습니다.

(chroot) #extlinux --device /dev/sdb1 --install /boot/syslinux

fstab

파일 /etc/fstab레이블이 동작하도록 fstab 설정
LABEL=GENTOO_USB_BOOT   /boot           ext2            noauto,noatime  1 2
LABEL=GENTOO_USB_ROOT   /               ext2            noatime         0 1
/dev/SWAP               none            swap            sw              0 0
/dev/cdrom              /mnt/cdrom      auto            noauto,ro       0 0
/dev/fd0                /mnt/floppy     auto            noauto          0 0

요령

시스템을 기본 젠투 시스템으로 바로 활용할 수 있겠지만, 호스트에서 바이너리 꾸러미를 컴파일하고 USB 메모리 스틱에 넣는 방식이 더욱 괜찮을 지도 모릅니다. 아니면 /var/tmp를 tmpfs로 마운트할 수 있을 만큼의 충분한 메모리를 보유하고 있다면 마운트하여 진행하는 것이 어쨌든 더 빠른 방법이 될 수 있습니다!

See also

  • Installation — an overview of the principles and practices of installing Gentoo on a running system.
  • LiveUSB — explains how to create a Gentoo LiveUSB or, in other words, how to emulate a x86 or amd64 Gentoo LiveCD using a USB drive.