Move Proxmox Boot Partition To USB Flash Drive On Legacy BIOS Systems

by ADMIN 70 views
Iklan Headers

This article provides a comprehensive guide on how to move the boot partition of Proxmox (or Debian) to a USB flash drive when installed on two NVMe disks in a ZFS RAID 1 configuration, especially on systems with a legacy BIOS that cannot boot from PCIe NVMe drives. This setup is particularly relevant for servers like the Dell R720xd, which, despite having UEFI boot options, might face limitations booting directly from NVMe drives.

Understanding the Challenge

The primary challenge arises from the legacy BIOS's inability to recognize and boot from NVMe drives directly connected via PCIe. While UEFI BIOS systems generally support NVMe booting, older systems with legacy BIOS require alternative boot methods. Installing the operating system on a USB flash drive offers a viable workaround, allowing the system to boot from the USB while utilizing the faster NVMe drives for the primary storage.

Prerequisites

Before proceeding, ensure you have the following:

  • A Proxmox or Debian system installed on two NVMe disks in a ZFS RAID 1 configuration.
  • A USB flash drive (8GB or larger recommended).
  • A live Linux environment (such as a Proxmox installation ISO or a Debian live image) for performing the migration.
  • Basic familiarity with Linux command-line operations.

Step-by-Step Guide

1. Boot from a Live Environment

Boot your system from a live Linux environment. This could be the Proxmox installation ISO or a Debian live image. This environment provides the necessary tools and utilities to manipulate the partitions and bootloader.

2. Identify Disks and Partitions

Once booted into the live environment, identify the disks and partitions using the lsblk command. This command lists all available block devices, including your NVMe drives and the USB flash drive. Note down the device names (e.g., /dev/nvme0n1, /dev/nvme1n1, /dev/sda) and partition numbers.

lsblk

3. Mount the ZFS RAID 1 Array

Mount the ZFS RAID 1 array to a temporary location. First, import the ZFS pool, then mount the root dataset. Replace your_pool_name with the actual name of your ZFS pool.

zpool import your_pool_name
zfs mount your_pool_name/ROOT/pve-1 #Or whichever dataset your root partition is on.

4. Prepare the USB Flash Drive

Partition and format the USB flash drive. You'll need to create at least two partitions: one for the boot partition and another for the EFI system partition (ESP) if your system uses UEFI. Since we are dealing with a legacy BIOS system, we will focus on creating a boot partition.

a. Partitioning the USB Drive

Use fdisk or parted to partition the USB drive. In this example, we'll use fdisk.

fdisk /dev/sda # Replace /dev/sda with your USB drive's device name

Within fdisk:

  • Type g to create a new GPT partition table.
  • Type n to create a new partition.
  • For partition number, press Enter to accept the default.
  • For first sector, press Enter to accept the default.
  • For last sector, specify the size of the boot partition (e.g., +1G for 1GB). Ensure you leave enough space for the boot files and future updates.
  • Type t to change the partition type.
  • Type 1 to select the partition.
  • Type 19 for "BIOS boot" partition. This sets the partition type to BIOS bootable.
  • Type a to make the partition bootable.
  • Type w to write the changes to disk.

b. Formatting the Boot Partition

Format the boot partition with a suitable filesystem, such as ext4.

mkfs.ext4 /dev/sda1 # Replace /dev/sda1 with your USB boot partition

c. Mount the USB Boot Partition

Create a mount point and mount the USB boot partition.

mkdir /mnt/usbboot
mount /dev/sda1 /mnt/usbboot

5. Copy Boot Files

Copy the necessary boot files from the ZFS RAID 1 array to the USB boot partition. This includes the contents of the /boot directory.

cp -r /mnt/zfsroot/boot/* /mnt/usbboot/

6. Install GRUB Bootloader

Install the GRUB bootloader on the USB drive. This step is crucial for making the USB drive bootable.

grub-install --target=i386-pc --recheck --boot-directory=/mnt/usbboot /dev/sda # Replace /dev/sda with your USB drive

7. Generate GRUB Configuration

Generate the GRUB configuration file. This file tells GRUB how to boot your system. You may need to bind mount some directories to properly generate the grub configuration.

mount --rbind /dev /mnt/usbboot/dev
mount --rbind /sys /mnt/usbboot/sys
mount --rbind /proc /mnt/usbboot/proc
chroot /mnt/usbboot
update-grub
exit
unmount /mnt/usbboot/dev
unmount /mnt/usbboot/sys
unmount /mnt/usbboot/proc

8. Update /boot/grub/grub.cfg

After generating the GRUB configuration, you may need to manually edit the /boot/grub/grub.cfg file on the USB drive to ensure it correctly points to your root partition on the ZFS RAID 1 array. This is particularly important if the generated configuration contains incorrect device names or UUIDs.

a. Identify ZFS Root Partition

Use zfs get -r mountpoint your_pool_name to find the mountpoint for your root file system. The output will give you the path, for example your_pool_name/ROOT/pve-1. Next find the UUID of the zfs pool by running zpool status -v. Take note of the pool GUID.

b. Edit grub.cfg

Edit the /mnt/usbboot/grub/grub.cfg file and locate the menu entries for your Proxmox or Debian installation. Modify the root= and zfs= lines to reflect the correct ZFS pool name and dataset. It should look something like this.

menuentry 'Proxmox VE GNU/Linux' --class proxmox --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-xxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
	load_video
	set gfxpayload=keep
	hinsource $chosen
	if [ x$feature_timeout_style = xy ] ;
	then
	  set timeout_style=menu
	  set timeout=5
	fi

	menuentry 'Proxmox VE GNU/Linux, with Linux 6.2.16-17-pve' --class proxmox --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-6.2.16-17-pve-advanced-xxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
	insmod zfs
	set root='zfs:your_pool_name/ROOT/pve-1'
	if [ x$feature_platform_search_hint = xy ]; then
	  search --no-floppy --fs-uuid --set=dev xxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
	else
	  search --no-floppy --fs-uuid --set=dev xxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
	fi
	linux /vmlinuz-6.2.16-17-pve root=rpool/ROOT/pve-1 ro zfs=your_pool_name boot=zfs
	initrd /initrd.img-6.2.16-17-pve
}

9. Unmount and Reboot

Unmount the USB boot partition and the ZFS RAID 1 array.

unmount /mnt/usbboot
zfs umount your_pool_name/ROOT/pve-1
zpool export your_pool_name

Reboot your system and ensure it boots from the USB drive. You may need to adjust your BIOS boot order to prioritize the USB drive.

Troubleshooting

  • System fails to boot: Double-check the GRUB configuration file (/boot/grub/grub.cfg) on the USB drive. Ensure the root= and zfs= parameters are correctly set to your ZFS pool and dataset.
  • GRUB errors: If you encounter GRUB errors, try reinstalling GRUB on the USB drive and regenerating the configuration file.
  • USB drive not detected: Ensure the USB drive is properly connected and that your BIOS settings allow booting from USB devices.

Conclusion

Moving the boot partition to a USB flash drive is a practical solution for booting Proxmox or Debian on systems with legacy BIOS that cannot boot from NVMe drives. By following this guide, you can successfully configure your system to boot from USB while leveraging the performance of NVMe storage in a ZFS RAID 1 configuration. This setup ensures both boot capability and data redundancy, providing a robust and reliable solution for your server environment.

  • Proxmox boot USB
  • Debian boot USB
  • NVMe boot legacy BIOS
  • ZFS RAID 1 boot
  • Dell R720xd Proxmox
  • Move boot partition
  • GRUB bootloader USB
  • Boot from USB
  • Proxmox installation guide
  • Debian installation guide