How to boot from a 4TB drive with GTP using UEFI

November 18, 2016

Lang: cs en de es

Someone installs the system and that's the end of their efforts. Sometimes, however, the computer changes and using the old way of booting is no longer possible. How to migrate the system to a 4TB drive with GTP and boot using UEFI?

GTP and UEFI

On large disks, partitions larger than 2TB can only be created if a partition table of the type GPT. You cannot boot from such a partition the old-fashioned way using the BIOS, but must use UEFI.

Installing GNU/Linux is easy whether in BIOS or UEFI boot mode.
However, in case of a disk change, the question may arise, how to migrate the system to a 4TB GPT disk and boot using UEFI? For an experienced Linux admin this is a manageable task.

Migrating to UEFI

The brief procedure is as follows:

  1. Prepare a partition for UEFI with a FAT-12/16/32 file-system and mark it as boot,esp. All this can be conveniently done from the GUI program gparted.
  2. Install grub2-efi.
  3. Switch motherboard settings to boot using UEFI.
  4. Boot live CD/USB using UEFI
  5. Verify UEFI functionality:
     [ -d /sys/firmware/efi ] && echo "EFI boot on HDD" || echo "Legacy boot on HDD"
    
  6. Synchronize the system. To save time, the main part of the synchronization can be done while the system is still running.
  7. Create , configure and write the boot loader.

Savior

Creating, configuring and writing a boot loader is much like restoring/repairing a boot loader for the BIOS
Mounting the root partition and creating a directory for the UEFI partition and mounting it:

mkdir /mnt/sda4/
mount /dev/sda4 /mnt/sda4/
mkdir /mnt/sda4/boot/efi
mount /dev/sda1 /mnt/sda4/boot/efi
Mount directories, with the virtual system where kernel information and partition and proc directories are exported:
mkdir /mnt/sda4/sys
mkdir /mnt/sda4/proc
mkdir /mnt/sda4/dev
mount -o bind /sys /mnt/sda4/sys
mount -o bind /proc /mnt/sda4/proc
mount -o bind /dev /mnt/sda4/dev
Chroot to the root partition of the system:
chroot /mnt/sda4/
If the disk or otherwise partitions have changed, you need to be careful that their identifiers have changed. This requires editing the fstab and grub config files, and often generating a new initrd. I exclusively use UUID everywhere, which is always unique. (It can be set the same manually if needed.)
update-grub2
Write data for UEFI boot:
 grub2-install --target=x86_64-efi --efi-directory=/boot/efi \
 --bootloader-id=ubuntu --recheck --no-floppy --debug

Manage UEFI menu

You may find that you have installed the system correctly, but the computer will not boot using UEFI. This happens, for example, when installing another system on another disk, when the other disks are disconnected, and the installer removes other boot options from the UEFI menu.
The solution is simple, you need to add the option to boot the second system to the UEFI menu again. The efibootmgr tool is used to manage the UEFI manager. Using it from another Linux system you can add another item to the UEFI menu and then UEFI will be able to boot that item.
For example, this is how you add the ability to boot a system that has UEFI boot data on the first partition of the first disk:

efibootmgr -c -d /dev/sda -p 1 -l EFI/mageia/grubx64.efi -L mageia

Conclusion

On today's modern GNU/Linux distributions, migration is seamless because they have UEFI support by default. Verified on Mageia and Ubuntu distributions

Using UEFI and GTP can bring other benefits as well. For example, the first obvious one is faster boot.

Warning these modifications without sufficient knowledge and skills may cause your computer to temporarily fail to boot!

Články na podobné téma

VMware licensing change
Running Microsoft SQL Server on Linux
Backup: the Proxmox Backup Server
Linux as a router and firewall
How to upload a docker image to the Docker Registry
Linux: logical volume management
Linux Software RAID
Running a web application behind a proxy
Mailbox migration
Docker multistage build
Backing up your data by turning on your computer
Podman
Importing Windows into Proxmox virtualization
Docker and PHP mail
Proxmox virtualization
Docker and Cron
Lenovo ThinkPad X1 Carbon: LTE modem EM7544 commissioning
Yocto Project: Build custom operating system for embedded devices
Preparing a Linux server to run a web application in Python
How to address poor file share performance in Docker
How to get started using Docker correctly
Installing Linux on a dedicated HPE ProLiant DL320e server
How to stress test a web application
Why use the JFS filesystem
Btrfs file system
Raspberry PI
WINE - running Windous programs under Linux
GNU/Linux operating system

Newsletter

If you are interested in receiving occasional news by email.
You can register by filling in your email news subscription.


+