前回はUEFIがGPT形式のHDDからOSを起動する仕組みを解説し,
従来のSystem BIOSではHDDの起動順序等の設定はBIOSのメニュー画面からしか操作できなかったのに対し,
一方,
すなわち,
USBメモリからUEFI起動
前回紹介したように,
前回紹介したように,
$ ls -l /usr/lib64/grub/x86_64-efi/ 合計 20,307,968 -rw-r--r-- 1 root root 16,432 10月 30日 17:11 acpi.mod -rwxr-xr-x 1 root root 102,088 10月 30日 17:11 acpi.module* -rw-r--r-- 1 root root 1,928 10月 30日 17:11 adler32.mod -rwxr-xr-x 1 root root 13,328 10月 30日 17:11 adler32.module* -rw-r--r-- 1 root root 8,272 10月 30日 17:11 affs.mod -rwxr-xr-x 1 root root 48,344 10月 30日 17:11 affs.module* -rw-r--r-- 1 root root 9,016 10月 30日 17:11 afs.mod -rwxr-xr-x 1 root root 57,488 10月 30日 17:11 afs.module* ...
grubがブートローダとして機能するためには,
骨組みだけしかないgrubコアにgrub.
そのような場合のために用意されているのがgrub-mkimageコマンドです。このコマンドは,
$ grub-mkimage --help 使い方: grub-mkimage [OPTION...] [OPTION]... [MODULES] Make a bootable image of GRUB. -c, --config=FILE embed FILE as an early config -C, --compression=(xz|none|auto) choose the compression to use for core image -d, --directory=DIR use images and modules under DIR [default=/usr/lib64/grub/<platform>] -k, --pubkey=FILE embed FILE as public key for signature checking -m, --memdisk=FILE embed FILE as a memdisk image Implies `-p (memdisk)/boot/grub' and overrides any prefix supplied previously, but the prefix itself can be overridden by later options -n, --note add NOTE segment for CHRP IEEE1275 -o, --output=FILE output a generated image to FILE [default=stdout] -O, --format=FORMAT generate an image in FORMAT available formats: i386-coreboot, i386-multiboot, i386-pc, i386-pc-pxe, i386-pc-eltorito, i386-efi, i386-ieee1275, i386-qemu, x86_64-efi, i386-xen, ...
grubには250近いモジュールが用意されており,
$ grub-mkimage -v -p '' -o bootx64.efi -O x86_64-efi fat part_msdos iso9660 gzio \ all_video gfxterm font terminal normal linux echo test search configfile cpuid minicmd grub-mkimage: 情報: the total module size is 0x6ffb8. grub-mkimage: 情報: reading /usr/lib64/grub/x86_64-efi/kernel.img. grub-mkimage: 情報: locating the section .text at 0x0. grub-mkimage: 情報: locating the section .rodata at 0x9600. grub-mkimage: 情報: locating the section .rodata.str1.1 at 0x9798. ... grub-mkimage: 情報: kernel_img=0x7fcad3119010, kernel_size=0x18200. grub-mkimage: 情報: the core size is 0x881b8. grub-mkimage: 情報: writing 0x89400 bytes.
今回組み込んだモジュールは,
-p ''は起動時に必要なファイルを探すディレクトリを変更するための指定で,
grub-mkimageはgrubコアにこれらのモジュールを組み込み,
$ ls -lh bootx64.efi -rw-r--r-- 1 kojima users 549K 2月 23日 23:12 bootx64.efi $ file bootx64.efi bootx64.efi: PE32+ executable (EFI application) x86-64 (stripped to external PDB), for MS Windows
次に,
1: menuentry "UEFI Plamo Linux install from USB memory" {
2: linux (hd0)/isolinux/vmlinuz root=/dev/ram0 rw nomodeset vga16 unicon=eucjp vt.default_utf8=0 kbd=usbkbd
3: initrd (hd0)/isolinux/initrd.gz
4: }
2行目が読み込むカーネルと起動時のオプションの指定,(hd0)
の部分が(hd0,msdos1)
のようになります。
こうして作成したbootx64.