This is Gentoo's testing wiki. It is a non-operational environment and its textual content is outdated.

Please visit our production wiki at https://wiki.gentoo.org

Install Gentoo on a bootable USB stick/ko

From Gentoo Wiki (test)
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 100% complete.

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

준비

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

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

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

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

파일 /etc/portage/package.use/sys-apps
sys-apps/busybox static

이제 sys-apps/busybox 꾸러미를 설치하십시오:

root #emerge --ask sys-apps/busybox

커널 컴파일

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

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

root #mkdir /tmp/boot
root #genkernel --firmware --busybox --disklabel --bootdir=/tmp/boot --no-symlink --all-ramdisk-modules --install all

위 명령은 기본 커널을 빌드하고 램 디스크를 만든 다음 /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 메모리 스틱 준비

Create 2 partitions on the drive (assuming the installation will have a /boot and a / (root) partition). We assume that the USB stick is at /dev/sdb (run dmesg immediately after plugging in the USB stick to see which device is being used).

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.

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

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 --disklabel option of the genkernel command line earlier.

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

젠투 스테이지 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.

이 예제에서 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 메모리 스틱으로 부트로더를 설치하십시오.

The below sections give example configurations for lilo and syslinux.

lilo

Emerge lilo (from within the 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 will use the label of the disk instead of /dev/sdb2 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 scandelay 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 메모리 스틱에 설치하십시오:

(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/fstabConfigure the fstab file to work with labels
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로 마운트할 수 있을 만큼의 충분한 메모리를 보유하고 있다면 마운트하여 진행하는 것이 어쨌든 더 빠른 방법이 될 수 있습니다!