Booting Fedora ISO off HDD

Posted by JD 02/27/2014 at 18:00

If you want to boot from an ISO on the HDD, grub2 supports that. There is probably something related to the installed OS supporting it too – Ubuntu 12.04 does.

/etc/grub.d/40_custom contains:

#!/bin/sh
exec tail -n +3 $0
\# This file provides an easy way to add custom menu entries. Simply type the
\# menu entries you want to add after this comment. Be careful not to change
\# the ‘exec tail’ line above.
menuentry “Fedora 20 LXDE (i686 bit)” {
set isoname=“Fedora-Live-LXDE-i686-20-1”
set isofile=“/ISO/${isoname}.iso”
loopback loop (hd0,5)$isofile
linux (loop)/isolinux/vmlinuz0 root=live:CDLABEL=${isoname} rootfstype=auto ro rd.live.image quiet rhgb rd.luks=0 rd.md=0 rd.dm=0 iso-scan/filename=${isofile}
initrd (loop)/isolinux/initrd0.img
}

A few notes:

  • The loopback line (hd0,5) correlates to /dev/sda5. It cannot be encrypted.
  • The /ISO part of the location is just a directory off / on the partition.
  • Different distro ISO files have different internal layouts which determines the linux and initrd locations.
  • After saving the update for your specific needs, run sudo update-grub

For internal layouts of other distro ISO files, this AskUbuntu article has examples. Could be very handy.