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

GRUB2/ko

From Gentoo Wiki (test)
Jump to:navigation Jump to:search
This page is a translated version of the page GRUB2 and the translation is 86% complete.
Outdated translations are marked like this.

GRUB2 (the GRand Unified Bootloader version 2) is a replacement for the original GRUB boot loader, now referred to as "GRUB Legacy". GRUB2 has an entirely separate code base from GRUB Legacy, and features a new shell-like syntax for advanced scripting capabilities.

한방에 접근하시려면 GRUB2 Quick Start를 보십시오.

GRUB Legacy에서 GRUB2로 옮겨가려면, GRUB2 Migration을 참고하십시오.

설치

The sys-boot/grub package is slotted. Both grub-0.97 (GRUB Legacy) and grub-2.02 may be installed at the same time; however, only one version at a time may be installed in the Master Boot Record (MBR) of a hard drive.

선행 과정

기본적으로 GRUB2는 빌드 시간에 기본 플랫폼 대상을 추측합니다. make.confGRUB_PLATFORMS 변수를 설정하여 우선 적용할 수 있습니다.

파일 /etc/portage/make.confExample of setting the GRUB_PLATFORMS variable for EMU, EFI, and PC platforms
GRUB_PLATFORMS="emu efi-32 efi-64 pc"

대상 CPU에 따라 다음 플랫폼을 지원합니다:

Target
Platform i386 ia64 mips mipsel powerpc spac64 x86_64
arc No No No Yes No No No
coreboot Yes No No No No No 32-bit
efi Yes Yes No No No No Yes
emu Yes Yes Yes Yes Yes Yes Yes
ieee1275 Yes No No No Yes Yes 32-bit
loongson No No No Yes No No No
multiboot Yes No No No No No 32-bit
qemu Yes No No No No No 32-bit
qemu-mips No No Yes No No No No
pc Yes No No No No No 32-bit
참고
GRUB_PLATFORMS 변수 값을 바꿀 때마다 GRUB2 이진 파일 상태가 바뀌게 다시 이머지해야합니다. emerge 섹션 하단의 --newuse --deep 옵션을 활용했는지 확인하십시오.

The amd64 profiles enable support for (U)EFI functionality by default. When using a BIOS-based system, set GRUB_PLATFORMS variable to pc to avoid unneeded dependencies.

USE 플래그

USE flags for sys-boot/grub GNU GRUB boot loader

device-mapper Enable support for device-mapper from sys-fs/lvm2
doc Add extra documentation (API, Javadoc, etc). It is recommended to enable per package instead of globally
efiemu Build and install the efiemu runtimes
fonts Build and install fonts for the gfxterm module
libzfs Enable support for sys-fs/zfs
mount Build and install the grub-mount utility
nls Add Native Language Support (using gettext - GNU locale utilities)
sdl Add support for Simple Direct Layer (media library)
test Enable dependencies and/or preparations necessary to run tests (usually controlled by FEATURES=test but can be toggled independently)
themes Build and install GRUB themes (starfield)
truetype Build and install grub-mkfont conversion utility
verify-sig Verify upstream signatures on distfiles

Emerge

GRUB2를 설치하려면 일반적인 emerge 문법을 사용하십시오:

root #emerge --ask --newuse --deep sys-boot/grub:2

추가 프로그램

추가로, os-prober 유틸리티(sys-boot/os-prober 꾸러미에 있음)를 설치하여 grub-mkconfig 명령을 실행할 때 GRUB2가 다른 운영체제도 찾을 수 있도록 하십시오. 대부분의 경우, 이런 조치로 GRUB2에서 Windows 7, 8.1, 10 및 기타 리눅스 배포판 등의 다른 운영체제를 자동으로 찾을 수 있습니다.

root #emerge --ask --newuse sys-boot/os-prober

GRUB2(그리고 추가로 sys-boot/os-prober도) 설치는 부트 로더를 자동으로 활성화하지 않습니다. 단지 이 설치 과정은 운영체제에 프로그램을 설치하는 과정일 뿐이지만, 시스템 자체에 부트 로더를 설치(하여 시스템을 부팅할 때 부트로터를 사용)하려면, 설정 부분에서 다루는 추가 과정을 거쳐야합니다.

설정

GRUB2 설정에 중요한 두가지 부분이 있습니다:

  1. GRUB2 프로그램을 시스템의 부트로더로 설치합니다.
  2. GRUB2 부트로더 자체를 설정합니다.

GRUB2 프로그램의 설치는 시스템 형태에 따르며, 부트로더 설치 에서 다룹니다. 우선 부트로더 자체 설정을 다루겠습니다.

주 설정 파일

grub-mkconfig 스크립트는 grub 설정을 만들 때 사용합니다. /etc/grub.d/*에 있는 설정 파일과 /etc/default/grub 설정 파일에서 함께 사용하여 최종적으로 GRUB2 자체에서 사용하는 유일한 설정 파일 /boot/grub/grub.cfg를 만듭니다.

File Format Edits recommended? Description
/usr/sbin/grub-mkconfig POSIX shell script No Installed as part of the sys-boot/grub:2 package. Run this script to generate /boot/grub/grub.cfg after configuring the files described below.
/boot/grub/grub.cfg GRUB2 shell script No The file generated by grub-mkconfig. This file is evaluated by GRUB2's built-in script interpreter and doesn't necessarily support all POSIX commands or syntax. See the scripting reference in the GRUB manual for supported features. Be aware that modifications to this file won't persist to the next time grub-mkconfig is run.
/etc/grub.d/* POSIX shell scripts Maybe Each script under /etc/grub.d/* that has its execute bit set is evaluated in sequence, and the stdout is concatenated to form the final /boot/grub/grub.cfg (or whatever file is given to the grub-mkconfig -o option). These scripts use the current system shell and therefore can use any supported syntax. Ideally they should be POSIX-compatible scripts, and the output script must be compatible with the GRUB2 interpreter. It may be necessary to disable or add scripts. For instance, to add menu items that couldn't be automatically generated.
/boot/grub/custom.cfg GRUB2 shell script Maybe The /etc/grub.d/41_custom script will reference this file to be read in at boot time if it exists. This file provides a place to add additional entries or commands and does not require regeneration of the main grub.cfg file.
/etc/default/grub POSIX shell script Yes In most cases this is the only file that should be modified directly. It is mainly used to assign variables used by the scripts in /etc/grub.d to generate a working configuration file. See GRUB2 configuration variables or the official reference for supported variables.

GRUB2는 관리자가 부팅 옵션 설정을 (GRUB LegacyLILO 처럼) 직접 관리할 필요가 없습니다. 대신 grub-mkconfig 명령으로 자체 설정 파일(/boot/grub/grub.cfg)을 만들 수 있습니다. 이 유틸리티는 /etc/grub.d/ 의 스크립트와 /etc/default/grub 설정을 활용합니다.

경고
grub-mkconfig 유틸리티는 소프트웨어 RAID를 사용중이라면 제대로 동작하지 않습니다. /etc/grub.d/에서 직접 스크립트를 설정해야 하며, 설정하지 않으면 설치하고 나서는 시스템이 부팅할 수 없는 상태로 남습니다.

하나 이상의 설정을 수정한 후, grub-mkconfig 유틸리티에 -o 옵션을 붙여 /boot/grub/grub.cfg 출력 파일(GRUB2 기본 출력 위치)을 가리켜 실행하십시오:

root #grub-mkconfig -o /boot/grub/grub.cfg
Generating grub.cfg ...
Found linux image: /boot/vmlinuz-3.3.0-gentoo
done

grub-mkconfig 유틸리티를 호출할 때마다 새 설정 파일을 만듭니다.

경고
grub-mkconfig 가 찾은 항목을 알려주지 않으면 어떤 항목도 없는거나 마찬가집니다. 이 경우 GRUB2 은 시스템을 다시 시작할 때 부팅 선택 항목을 제공하지 않아 일이 까다로워질 수 있으며, 문제를 해결하는데 시간을 까먹습니다. 시스템을 다시 시작하기 전에 기대하던대로 출력이 나오는지 확인하십시오.

설정 매개 변수

/etc/default/grub에 있는 다음 변수는 GRUB2를 동작하도록 설정하는 일반적인 변수입니다:

변수 설명 기본값
GRUB_DEFAULT 부팅 과정에서 선택할 기본 메뉴 항목을 정의합니다. 인덱스 번호, 메뉴 제목, 또는 "saved"가 값이 될 수 있습니다. 첫번째로 발견한 항목이 기본값입니다.
GRUB_TIMEOUT 기본 메뉴 항목으로 부팅하기 전 (초 단위로) 기다립니다. 0 값 설정은 바로 부팅을 의미하며, -1 은 사용자의 입력이 들어오기 전까지 계속 기다림을 의미합니다. 기본값은 5초입니다.
GRUB_CMDLINE_LINUX 모든 리눅스 메뉴 항목의 커널 명령 줄에 전달할 매개변수입니다. 이를 테면, 최대 절전 기능을 지원하려면, GRUB_CMDLINE_LINUX="resume=/dev/sdXY" 줄을 추가하고 /dev/sdXY 부분에는 스왑 파티션을 넣습니다.
GRUB_CMDLINE_LINUX_DEFAULT 비 복구 리눅스 메뉴 항목의 커널 명령줄에 전달할 매개변수입니다.
GRUB_DEVICE 초기 루트 장치(예: 커널의 root= 매개 변수) 입니다. grub-mkconfig 명령의 루트 장치 자동 감지 결과 설정을 덮어쓰려면 이 항목을 설정하십시오. 예를 들어, GRUB_DEVICE=/dev/ram0 설정은 커널 명령 줄에서 root=/dev/ram0 로 설정하도록 강제합니다.

좀 더 완벽한 내용은 GRUB2 설정 변수en 하위 페이지를 참고하십시오.

매개변수를 수정했으면, grub-mkconfig 명령으로 GRUB2 설정 파일을 다시 만드십시오.

설정 스크립트 활성화/활성 해제

/etc/grub.d/ 디렉터리에는 grub-mkconfig에서 grub.cfg 파일을 만들때 사용하는 스크립트가 있습니다. 기본적으로 이 디렉터리의 내용은 다음과 비슷해야 합니다:

user $ls /etc/grub.d/
00_header  10_linux  20_linux_xen  30_os-prober  40_custom  41_custom README

GRUB2는 실행하도록 표시한 설치 스크립트를 사용(기본적으로 이미 다 갖춰져 있음)합니다. 일부 스크립트의 사용 여부를 해제하려면, chmod 명령을 사용하여 간단하게 스크립트 파일 권한의 실행 비트를 제거하십시오. 다음 예제에서는 모든 스크립트 중 00_header10_linux 스크립트의 실행 여부를 비활성화합니다:

root #chmod -x /etc/grub.d/{20_linux_xen,30_os-prober,40_custom,41_custom}

스크립트를 수정한 후(또는 실행 비트를 제거한 후), grub-mkconfig 명령으로 GRUB 설정 파일을 다시 만드십시오.

설정 스크립트 다루기

일부 기능이나 GRUB2 기능은 설정 스크립트를 수정할 때 살펴볼 수 있습니다. 예를 들어 FreeBSD와 듀얼 뷰팅을 하려 할 때, 기능이 동작하도록 하려면 다음 처리 절차가 필요합니다.

/etc/grub.d/40_custom 스크립트를 다음 내용으로 바꾸십시오:

파일 /etc/grub.d/40_customAdding an entry for dual booting
menuentry "FreeBSD" --class freebsd --class bsd --class os {
 insmod ufs2
 insmod bsd
 set root=(hd0,1)
 kfreebsd /boot/kernel/kernel
 kfreebsd_loadenv /boot/device.hints
 set kFreeBSD.vfs.root.mountfrom=ufs:/dev/ada0s1a
 set kFreeBSD.vfs.root.mountfrom.options=rw
 set kFreeBSD.hw.psm.synaptics_support=1
}

/dev/sda1 또는 (hd0,1)은 FreeBSD가 있는 공간입니다. 일반 UFS 설치를 FreeBSD 공간 용도로 사용한다면 /dev/sda1 은 컨테이너(논리 공간)가 됩니다. 컨테이너에는 스왑 공간과 루트 공간이 있습니다. ls -la /etc/grub.d/40_custom를 실행하여 40_custom 스크립트가 실행 가능한지 확인하십시오. 만약 실행 비트를 설정하지 않았다면 chmod u+x 40_custom 명령으로 설정하십시오.

참고
GRUB Legacy의 분할 영역 번호 부여에 익숙한 사용자는 GRUB2의 분할 영역 시작 번호가 0이 아닌 1임을 숙지해야 합니다.

다음 grub-install 명령으로 GRUB2를 설치하고 GRUB2의 설정 파일을 업데이트하십시오:

root #grub-install /dev/sda
root #grub-mkconfig -o /boot/grub/grub.cfg

부트 로더 설치

GRUB2 시스템 부트로더 설치는 시스템을 어떻게 부팅할것인지(BIOS냐 UEFI냐), 부트로더가 올라간 디스크에 어떻게 설치하고 분할하느냐(MBR 또는 GPT 분할 배치)에 달려있습니다.

이 게시글은 다음 상황을 다룹니다:

시스템에 맞는 설치 과정을 선택하십시오.

BIOS와 MBR

참고
시스템을 마이크로소프트 윈도우와 듀얼 부팅을 수행한다면, 시스템에 UEFI 펌웨어가 없는지 확인하십시오. 이럼에도 '기존 BIOS' 모드로 부팅한다면, 마이크로소프트 윈도우가 부팅을 거부합니다.

/boot 위치가 있는지 확인하시고 이 위치에서 분할 공간을 사용한다면 마운트했는지 확인하십시오:

root #mount /boot

grub-install 명령을 실행하여 관련 파일을 /boot/grub에 복사하십시오. PC 플랫폼에서는 주 부트 레코드(MBR)에 부팅 이미지를 설치하거나 디스크 공간의 부트 섹터에 설치합니다. 잘 동작한다면, grub-install을 실행한 다음의 출력 결과는 다음과 같습니다:

root #grub-install /dev/sda
Installation finished. No error reported.

grub-install 명령은 CPU 아키텍처와 시스템 플랫폼을 설정할 때 --target 옵션을 받아들입니다. 설정하지 않으면 grub-install에서 적당한 값을 추측하려듭니다. amd64/x86 시스템에서는 기본적으로 i386-pc 설정 값을 사용합니다. 또한 grub-install 명령에서는 GRUB2 설치 관리자에게 --boot-directory 옵션으로 GRUB2 부팅 파일을 찾을 때 살펴볼 디렉터리 값을 넘기기도 합니다. 기본 값은 현재 /boot 디렉터리지만 루트 공간을 옮기려 할 경우 쓸모있습니다.

BIOS용 MBR 분할

첫번째 분할 공간 이전에 충분한 공간을 두었는지 확인하십시오. 첫번째 2048 섹터에 최소한 1MiB 디스크 여유공간을 두어 주 부트 레코드를 넣어야 합니다. BIOS 부팅 파티션 이라는 추가 공간을 만드는 것이 좋습니다(만 추천하지는 않습니다). 이 공간은 정의할 필요만 있을 뿐, 포맷하지는 않습니다. 시스템을 GPT 분할 영역 구성으로 바꿀 때만 필요합니다. MBR로 그대로 두는 경우에는 필요하지 않습니다.


젠투 설치 절차를 따랐다면 BIOS 부팅 공간은 이미 존재합니다.

BIOS와 GPT

참고
시스템을 마이크로소프트 윈도우와 듀얼 부팅을 수행한다면, 시스템에 UEFI 펌웨어가 없는지 확인하십시오. 이럼에도 '기존 BIOS' 모드로 부팅한다면, 마이크로소프트 윈도우가 부팅을 거부합니다. 또한 이전 마이크로소프트 윈도우 시스템은 GPT를 지원하지 않습니다. MBR-GPT 혼합 방식을 사용하는 방안으로 접근할 수 있는데, 이 방식으로 접근하려면 Hybrid partition tableen을 참고하십시오.

/boot 공간이 필요하면, /boot 공간을 마운트하고 시작하십시오:

root #mount /boot

잘 동작한다면, grub-install을 실행 출력 결과는 다음과 같습니다:

root #grub-install /dev/sda
Installation finished. No error reported.

grub-install 명령은 CPU 아키텍처와 시스템 플랫폼을 설정할 때 --target 옵션을 받아들입니다. 설정하지 않으면 grub-install에서 적당한 값을 추정합니다. amd64/x86 시스템에서는 기본적으로 i386-pc 설정 값을 사용합니다. 또한 grub-install 명령에서는 GRUB2 부팅 파일을 찾을 때 살펴볼 디렉터리를 GRUB2 설치 관리자에 알려줄 --boot-directory 옵션을 받아들이기도 합니다. 기본값은 현재 /boot 디렉터리지만 루트 공간을 옮기려 할 경우 쓸모있습니다.

BIOS용 GPT 분할

GPT 파티션 테이블이 시스템에 있을 경우, EF02 형식(EF00 형식의 EFI 시스템 파티션(ESP)와는 다름)의 작은 BIOS 부트 파티션이 있어야합니다. 충분한 1MiB 공간이 있어야 동작할 텐데, 2-4MiB 설정 값이 안전한 선택입니다. BIOS 부트 파티션은 부트로더 스테이지 2를 유지합니다. BIOS 부트 파티션은 파일 시스템으로 포맷할 필요가 없습니다. grub-install 명령이 기존 파일시스템을 다른 어떤 자체 파일 시스템으로 덮어씁니다.

중요
/boot에 마운트한 일반 공간과 BIOS 부트 파티션이 동일하지 않습니다. /boot 경로와 BIOS 부팅 공간은 다른 공간이며, 개별적으로 다루어야합니다. BIOS 부트 파티션은 일반 공간처럼 시스템에 마운트하면 안됩니다(예: /etc/fstab에 정의하면 안됩니다). /boot 공간은 문제없이 마운트할 수 있으며, /etc/fstab 파일에 나타날 수 있습니다.

디스크 공간을 BIOS 파티션으로 만들려면 parted (sys-block/parted) 도구를 활용하여 다음을 입력하십시오(1 값을 BIOS 부팅 파티션으로 표시할 공간의 번호로 바꾸십시오!):

(parted)set 1 bios_grub on

sys-apps/gptfdiskcgdisk 유틸리티에서는 공간 형식을 0xEF02로 설정하고 레이블을 gptbios로 설정하시면 됩니다.

EFI 시스템 파티션은 필요하지 않지만, 나중에 시스템 마더보드를 UEFI 보드로 업그레이드 했을 때, BIOS 부트 파티션이 EFI 시스템 파티션으로 변환하기에 크기가 충분한 지 확인할 때 민감할 수 있습니다.

다음 내용은 gdisk 유틸리티에서 GPT 방식으로 디스크 공간 분할을 수행하여 BIOS 부트 [0xEF02] 파티션과 EFI [0xEF00] 파티션으로 나눈 후, p 키를 눌렀을 때의 출력 화면입니다:

root #gdisk /dev/sdc
GPT fdisk (gdisk) version 0.8.1
 
Partition table scan:
  MBR: protective
  BSD: not present
  APM: not present
  GPT: present
 
Found valid GPT with protective MBR; using GPT.
 
Command (? for help): p
Disk /dev/sdc: 976773168 sectors, 465.8 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): AA369F4D-37A4-4C0D-A357-DC24B99A6337
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 976773134
Partitions will be aligned on 2048-sector boundaries
Total free space is 2014 sectors (1007.0 KiB)
 
Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048       828377087   395.0 GiB   8E00  Linux LVM
   2       828377088       891291647   30.0 GiB    0700  Microsoft basic data
   3       891291648       975177727   40.0 GiB    0700  Microsoft basic data
   4       975177728       976754687   770.0 MiB   8300  Linux filesystem
   5       976754688       976756735   1024.0 KiB  EF02  BIOS boot partition
   6       976756736       976773134   8.0 MiB     EF00  EFI System
 
Command (? for help): 
참고
fdisk 명령을 사용할 때, GPT 공간을 설정할 경우 0x 16진수 접두부는 입력하지 않아도 됩니다.

동일한 설정을 활용하여, parted 유틸리티에서 약간 다른 문법으로 출력하겠습니다:

root #parted /dev/sdc
GNU Parted 3.0
Using /dev/sdc
(parted) print
...
Sector size (logical/physical): 512B/512B
Partition Table: gpt
  
Number  Start   End    Size    File system  Name                  Flags
 1      1049kB  424GB  424GB                Linux LVM             lvm
 2      424GB   456GB  32.2GB               Microsoft basic data
 3      456GB   499GB  42.9GB               Microsoft basic data
 4      499GB   500GB  807MB   ext2         Linux filesystem
 5      500GB   500GB  1049kB               BIOS boot partition   bios_grub
 6      500GB   500GB  8396kB               EFI System            boot
  
(parted)

gdisk 에서 공간을 분할하는 것은 fdisk 공간 분할 유틸리티를 사용해본 사용자들에게는 이미 익숙하기 때문에 간단합니다. gdisk를 시작한 후 초기 메뉴에서 n(새로 만들기)를 입력한 후, (필요하다면) 시작, 끝 섹터를 입력하고, 공간 형식을 EFI 시스템 파티션으로 만들기 위해 EF00로 입력하십시오.

젠투 설치 절차를 이미 따른 사용자라면 이미 적당한 공간 분할 설정을 끝냈을겁니다.

UEFI와 GPT

/boot 위치가 있는지 확인하시고 이 위치에서 분할 공간을 사용한다면 마운트했는지 확인하십시오:

root #mount /boot

grub-install 명령을 실행하여 관련 파일을 /boot/grub에 복사하십시오. /boot/grub에 GRUB2를 설치하며 /boot/efi/EFI/gentoo/grubx64.efi 핵심 이미지를 복사하고 부팅 항목에 추가할 efibootmgr를 호출합니다.

root #grub-install --efi-directory=/boot/efi
Installation finished. No error reported.

위 명령은 vfat 형식의 EFI 시스템 파티션(ESP)를 /boot/efi에 마운드했다 가정합니다. ESP를 /boot레 직접 마운트했다면, --efi-directory=/boot 옵션을 사용하십시오.

grub-install 명령은 CPU 아키텍처와 시스템 플랫폼을 설정할 때 --target 옵션을 받아들입니다. 이 옵션을 설정하지 않으면 grub-install에서 적당한 값 추정을 시도합니다. AMD64 UEFI 부팅 시스템에서는 기본적으로 x86_64-efi 설정 값을 사용합니다. 또한 grub-install 명령에서는 GRUB2 부팅 파일을 찾을 때 살펴볼 디렉터리를 GRUB2 설치 관리자에 알려줄 --boot-directory 옵션을 받아들이기도 합니다. 기본 값은 현재 /boot 디렉터리지만 루트 공간을 옮기려 할 경우 쓸모있습니다.

UEFI용 GPT 분할

GRUB2에서 UEFI GPT 부팅을 수행할 때, 시스템은 FAT 파일 시스템으로 제공하는 EFI 파티션을 보유해야 합니다.

/dev/sda1/boot/efi 공간을 만들면 /dev/sda1/boot 공간으로 EFI 공간을 바꿀 수 있습니다. GRUB2의 성공적인 UEFI 부팅 시나리오에서 루트 공간과 EFI 공간, 두 개의 공간을(swap 공간이 필요하다면 전부 세개) 다룰 수 있습니다. 이 설정을 사용하면 /boot 폴더를 (/boot의)루트 / 공간에 넣고 EFI 공간을 (/boot/efi의)boot 폴더에 마운트 합니다. 확실히 이해하려면 하단의 /etc/fstab 파일을 살펴보십시오.

파일 /etc/fstabExample of an UEFI capable /etc/fstab file with a swap partition:
/dev/sda1		/boot/efi	vfat		noauto,noatime	1 2
/dev/sda2		none		swap		sw		0 0
/dev/sda3		/		ext4		noatime		0 1

/boot/efi의 100MB 공간을 만들때는 여러

  • .efi 파일을 저장할 충분한 공간을 확보해야합니다(항목 여러개는 필요하지 않을지도 모릅니다. 대부분의 시스템은 한개만 사용할테니까요).

공간을 분할할 선택한 도구를 활용하여 저장 공간을 분할하십시오. gdisk(sys-apps/gptfdisk)와 parted (sys-block/parted) 도구는 이러한 목적에 안성맞춤입니다. gdisk 유틸리티를 사용할 때는, EF00 형식을 사용하는지 확인하십시오.

다음 예제와 같이 mkdosfs로 EFI 시스템 파이션에 FAT 파일 시스템을 만들고 /etc/fstab에 추가하십시오:

root #mkdosfs -F 32 -n efi-boot /dev/sda1
root #mkdir /boot/efi
파일 /etc/fstabAdding the /boot/efi mount entry
/dev/sda1		/boot/efi	vfat		noauto,noatime	1 2
root #mount /boot/efi
참고
/etc/portage/make.confGRUB_PLATFORMS 변수를 설정하면 도움이 될 수 있습니다. GRUB2에서 적당한 EFI 타겟을 감지할 때 사용할 옵션을 결정하도록 도움을 줍니다. 32비트 UEFI 시스템에서는 efi-32를, 64비트 UEFI 시스템에서는 efi-64를 씁니다.
중요
GRUB2를 제대로 설치하려면 EFI 디렉터리를 반드시 마운트 해야하며, grub-install 명령을 제대로 실행하려면 efivars 커널 모듈을 불러와야합니다.

대안: 기본 UEFI 펌웨어 위치 사용

시스템 UEFI 펌웨어에서 GRUB2 EFI 부트로더 파일 찾기에 실패했다면, 사용 중인 기본 부트로더 위치를 동작 방안으로 제공해야합니다. 이런 조치를 통해 efibootmgr에서 관리하는 부팅 메뉴를 피하여 기능성이 줄어들 수는 있지만, 오류에 덜 취약합니다. 이렇게 하려면 EFI 공간을 /boot/efi 에 마운트한 후 /boot/efi/EFI/gentoo/grubx64.efigrubx64.efi 파일을 /boot/efi/EFI/BOOT/BOOTX64.EFI로 복사하십시오. 이 예제는 64-bit UEFI 시스템을 가정하였으므로, 32-bit UEFI 시스템에서는 시스템의 환경에 따라 조절하십시오.

외부 기능

GRUB2는 강력한 부트로더로 만들어주는 수많은 기능이 있습니다. 다음과 같은 기능을 지원합니다:

  • Booting from UEFI platforms.
  • Booting from GPT partitioned drives without needing a hybrid MBR (hybrid MBR can enabled as needed for compatibility or portability).
  • Booting from a btrfs formatted /boot partition.
  • Booting from a ZFS pool.
  • Booting directly from a btrfs raid set without needing an initramfs for early mount setup.
  • Booting directly from logical volume management (such as LVM2).
  • Booting with support for DM-RAID (RAID 0, 1, 4, 5, 6, 9 and 10).
  • Booting from encrypted devices (LUKS).

일부 몇가지 기능을 자세히 설명하도록 하겠습니다.

체인 로딩

GRUB2에서는 GRUB Legacy에 비하면 확실히 체인 로딩 모드가 바뀌었습니다. 다른 부트 로더를 체인 로딩하려면, chainloader 옵션을 사용하십시오.

파일 /etc/grub.d/40_customChainloading another bootloader
menuentry "Custom Super-bootloader example" {
     insmod part_msdos
     insmod chain
     chainloader (hd1,1)+1
}

체인 로딩에 대한 더 많은 내용은 체인 로딩en 하위 페이지를 살펴보십시오.

프레임버퍼 화면 사용

GRUB2에서 framebuffer 그래픽 화면을 사용하려면 GRUB에 truetype USE 플래그를 활성화 한 상태에서 다시 이머지하십시오. 글꼴 변환 유틸리티와 함께 기본 트루타입 글꼴을 설치합니다.

root #emerge --ask --newuse sys-boot/grub:2

/etc/default/grub에 있는 기본 GRUB2 설정 파일 설정을 진행하십시오. 예를 들면:

파일 /etc/default/grub프레임버퍼 설정
# Set resolution and color depth
GRUB_GFXMODE=1366x768x32
 
# Keep resolution when loading the kernel
GRUB_GFXPAYLOAD_LINUX=keep
 
# Set a background image
GRUB_BACKGROUND="/boot/grub/bg.png"
 
# Use a custom font, converted using grub-mkfont utility
GRUB_FONT="/boot/grub/fonts/roboto.pf2"

시스템 그래픽 카드에서 어떤 디스플레이 모드를 지원하는지 찾아보려면 GRUB2 쉘에서 다음 명령을 사용하십시오:

(grub)insmod all_video
(grub)videoinfo

문제 해결

대부분의 문제는 공간 배치를 올바르게 처리했는지 확인하여 해결할 수 있습니다. 디스크의 첫번째 공간 이전에 충분한 공간을 두었는지 확인하거나, 추가적으로 BIOS 부트 파티션이 존재하는지 확인하십시오. 또한 grub-mkconfig 명령으로 /boot/grub/grub.cfg 파일을 제대로 만들었거나, 개별 메뉴 항목을 제대로 만들었는지 검증하십시오.

GRUB2 문제 해결 내용을 찾아보려면 문제 해결en 하위 게시글을 참고하십시오.

Motherboard firmware not finding the .EFI file

Some motherboard manufacturers seem to only support one location for the .EFI file in the EFI System Partition (ESP). If this seems to be the case, simply move GRUB's default file to the /efi/boot/ location. First, make sure the ESP is mounted. Presuming the ESP is mounted at /boot/efi (as suggested in the Handbook), execute:

root #mkdir -p /boot/efi/efi/boot
root #cp /boot/efi/efi/gentoo/grubx64.efi /boot/efi/efi/boot/bootx64.efi

This should aid the motherboard firmware in loading the GRUB executable. Reboot the system to see if the firmware now correctly loads GRUB.

chroot 환경의 os-prober와 UEFI

sys-boot/os-prober 유틸리티는 마이크로소프트 윈도우 같은 대안 설치 운영체제를 찾는데 사용합니다. 제대로 활용하려면 EFI 시스템 분할 영역 시험을 목적으로 환경 설정에 들어있는 udev 정보를 찾아봐야합니다.

이 명령을실 행하여 필요한 파일을 호스트 환경에 제시하십시오(예제에서는 핸드북에서와 같이 젠투를 /mnt/gentoo 디렉터리에 마운트했습니다):

root #mkdir -p /mnt/gentoo/run/udev
root #mount -o bind /run/udev /mnt/gentoo/run/udev
root #mount --make-rslave /mnt/gentoo/run/udev

Installing a new kernel

Whenever a new kernel is installed, GRUB2 must be reconfigured to recognize it. This can be done using grub-mkconfig, as shown below, or can be done manually.

참고
Make sure the /boot partition is mounted for this step.
root #grub-mkconfig -o /boot/grub/grub.cfg
Generating grub.cfg ...
Found linux image: /boot/kernel-3.3.8-gentoo
Found initrd image: /boot/initramfs-genkernel-x86_64-3.3.8-gentoo
Found linux image: /boot/kernel-3.2.12-gentoo
Found initrd image: /boot/initramfs-genkernel-x86_64-3.2.12-gentoo
done

Note that GRUB2 only needs to be reconfigured, not reinstalled to the boot drive's Master Boot Record (MBR). On the other hand, when GRUB2 itself has been upgraded it does need to be reinstalled on the boot drive, but usually does not need to be reconfigured.

추가 참조

몇가지 개별적인 GRUB2 자료가 있습니다:

  • 체인 로딩 에서는 GRUB2에서 다른 부트로더로 부팅하는 방법을 설명합니다. 듀얼 부팅 시스템을 꾸리거나 GRUB2에서 ISO 파일을 설정해야 할 경우에 읽어보셔야 합니다.
  • 고급 저장 장치 에서는 소프트웨어 RAID, 논리 볼륨, 암호화 파일 시스템과 같은 좀 더 고급 기술을 사용한 저장장치를 사용하는 경우, GRUB2를 설치하고 사용할 때 필요한 단계를 문서화했습니다.
  • 설정 변수에서는 /etc/default/grub 파일 같은 곳에서 사용하는 GRUB2 설정 변수의 완전한 목록을 문서화했습니다.
  • 문제 해결에서는 일반적인 GRUB2 오류의 목록을 (해결책과 함께) 나타냅니다.
  • 혼합형 분할 테이블

외부 자료

더 많은 정보는 다음 링크를 보십시오: