Booting to a RAID drive from a USB key

I ran into a situation recently where I was building a new server install on a RAID controller in an old extra PC (Dell Optiplex). The BIOS in this machine wouldn’t allow a boot directly from the RAID card, but it did support booting from a USB flash drive.

My solution was to put a bootloader on the USB drive and have it load the operating system directly from the RAID logical volume.

  1. Boot into rescue mode from your distro’s installation DVD. I used CentOS 7 but any distro would probably be fine.
  2. Mount the RAID volume with your previously installed operating system using chroot /mnt/sysimage
  3. Once booted, insert your USB Flash Drive
  4. Type fdisk -l (and note which device is your USB)
  5. Type mkdir /mnt/USB && mount /dev/sdx1 /mnt/USB (replacing x with your actual usb device)
  6. Type grub-install –force –no-floppy –boot-directory=/mnt/USB/boot /dev/sdx (replacing x with your actual USB device)
  7. Type cd /mnt/USB/boot/grub2
  8. Type cp /boot/grub2/grub.cfg .
  9. You may need to update the grub.cfg on the USB so that the paths points to the correct location of the kernel image and initramdisk in /boot
  10. You should now be able to boot your operating system installed on the RAID volume off of the USB drive