Differences
This shows you the differences between two versions of the page.
— |
en:freebsd:migrate_freebsd_legacy_gpt_boot_to_uefi [2019-09-25 17:11] (current) Decomo 作成 |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Migrate FreeBSD boot method from Legacy/GPT to UEFI/GPT ====== | ||
+ | |||
+ | 8 years have already passed since I made a Root on ZFS environemnt with Legacy/GPT boot on FreeBSD 9.0-BETA3. I'm using it until now while upgrading the OS, but the boot environment is no change. I thought it wasn't cool even in 2019 nowdays, so I tried to migrate the boot method to UEF/GPT boot. | ||
+ | |||
+ | This how-to is " | ||
+ | |||
+ | ===== System ===== | ||
+ | |||
+ | * FreeBSD 12.0-RELEASE-p4 | ||
+ | * Legacy/ | ||
+ | * A boot device is '' | ||
+ | * FreeBSD single-boot machine. | ||
+ | |||
+ | ===== Steps ===== | ||
+ | |||
+ | All you need is to make a EPS and put a UEFI boot loader on it. | ||
+ | |||
+ | ==== Create the EFI System Partition ==== | ||
+ | |||
+ | Create the ESP((EFI System Partition) on a boot storage. The boot loader for UEFI will be put there, but securing the partition is the biggest hurdle to do it. | ||
+ | |||
+ | It is okay if the disk has enough space otherwise you have no choice but to replace it with new one. In this case, adding a new disk as ZFS mirror member to the system pool makes it easy to synchronize the data. You managed to create the partition by well thought out, please. | ||
+ | |||
+ | < | ||
+ | # gpart add -a 4k -t efi -s 200m ada0 | ||
+ | </ | ||
+ | |||
+ | The partition size is as you like. FYI, the FreeBSD installer makes as 200MB. | ||
+ | |||
+ | I had a prepared 512MB ESP ('' | ||
+ | |||
+ | < | ||
+ | > gpart show ada0 | ||
+ | => 34 1099999933 | ||
+ | 34 | ||
+ | 40 | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | 1032848424 | ||
+ | 1074791464 | ||
+ | </ | ||
+ | |||
+ | Format the ESP for FAT32. | ||
+ | |||
+ | < | ||
+ | For 512 bytes per sector devices: | ||
+ | # newfs_msdos -F 32 -S 512 -c 4 ada0p1 | ||
+ | / | ||
+ | BytesPerSec=512 SecPerClust=4 ResSectors=32 FATs=2 Media=0xf0 SecPerTrack=63 Heads=16 HiddenSecs=0 HugeSectors=1048576 FATsecs=2040 RootCluster=2 FSInfo=1 Backup=2 | ||
+ | |||
+ | For 4096 bytes per sector devices: | ||
+ | # newfs_msdos -F 32 -S 4096 -c 1 ada0p1 | ||
+ | / | ||
+ | BytesPerSec=4096 SecPerClust=1 ResSectors=4 FATs=2 Media=0xf0 SecPerTrack=63 Heads=255 HiddenSecs=0 HugeSectors=131072 FATsecs=128 RootCluster=2 FSInfo=1 Backup=2 | ||
+ | </ | ||
+ | |||
+ | ==== Put UEFI boot loader ==== | ||
+ | |||
+ | Mount the created ESP. | ||
+ | |||
+ | < | ||
+ | $ mkdir /tmp/esp | ||
+ | # mount -t msdosfs /dev/ada0p1 /tmp/esp | ||
+ | </ | ||
+ | |||
+ | Make a folder and put a UEFI boot loader on the ESP. | ||
+ | < | ||
+ | $ mkdir -p / | ||
+ | $ cp / | ||
+ | </ | ||
+ | |||
+ | Write a UEFI shell script for boot. | ||
+ | < | ||
+ | $ echo ' | ||
+ | </ | ||
+ | |||
+ | It is okay that a file structure on the ESP looks like below: | ||
+ | < | ||
+ | $ cd /tmp/esp/ | ||
+ | $ find . | ||
+ | . | ||
+ | ./efi | ||
+ | ./efi/boot | ||
+ | ./ | ||
+ | ./ | ||
+ | </ | ||
+ | |||
+ | Surely unmount the ESP. | ||
+ | < | ||
+ | $ cd | ||
+ | # umount /tmp/esp | ||
+ | </ | ||
+ | |||
+ | Reboot your system. | ||
+ | < | ||
+ | # reboot | ||
+ | </ | ||
+ | |||
+ | ==== Change a BIOS setting ==== | ||
+ | |||
+ | Change boot method " | ||
+ | |||
+ | Save the config, reboot your system again, then the FreeBSD will boot under the UEFI environment. | ||
+ | |||
+ | {{ : | ||
+ | |||
+ | It may be success when display shows boot screen with a message " | ||