I will soon need to build a few new PCs that do not have optical drives (one will be a firewall, for example). They do not need the drives for day-to-day usage but I do need to get an OS on them. Since virtually all consumer boards now have USB and I have piles of unused flash drives laying around I decided not to spend the money on an external drive and go the flash drive route.
Here are the steps I took to get my Linux ISOs to boot off a USB flash drive. For these exact steps to work you will need an existing Linux installation (a LiveCD will work just fine).
- Create a new, formatted partition big enough to store your ISOs. I am using EXT4 but any filesystem supported by GRUB2 will work. I prefer to use GParted for this.
- Mount your new partition. Most Linux desktop distributions will do this automatically for you if you just unplug the device and plug it back in.
- Install GRUB2:
grub-install --force --no-floppy --root-directory=[path partition was mounted] /dev/sdX
where X is the flash drive.
- Copy over any ISOs you want to be able to boot to the root of your new partition.
- Create
[path partition was mounted]/boot/grub/grub.cfg
and add the lines
set timeout=5
set default=0
- In
[path partition was mounted]/boot/grub/grub.cfg
add any of the following example entries for your favorite distributions:
menuentry "Ubuntu 10.10 Desktop i386" {
loopback loop /ubuntu-10.10-desktop-i386.iso
linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=/ubuntu-10.10-desktop-i386.iso noeject noprompt splash --
initrd (loop)/casper/initrd.lz
}
menuentry "Ubuntu 10.10 Server i386" {
loopback loop /ubuntu-10.10-server-i386.iso
linux (loop)/install/vmlinuz boot=casper iso-scan/filename=/ubuntu-10.10-server-i386.iso noeject noprompt splash --
initrd (loop)/install/initrd.gz
}
menuentry "Darik's Boot And Nuke" {
loopback loop /dban-2.2.6_i586.iso
linux (loop)/DBAN.BZI nuke="dwipe" iso-scan/filename=/dban-2.2.6_i586.iso silent --
}
menuentry "Memtest 86+" {
linux16 /memtest86+.bin
}
I could not, for the life of me, get any Windows ISOs to boot using GRUB2. On top of that I came across a number of people trying to do the same thing whom all failed. If anyone gets this working please post in the comments. I may be able to chainload into another boot loader but that is for another day.
[Source]
Update 2011.02.18
I found this. It may be nothing but it also may be a jumping off point from which to boot from a Windows ISO.
Update 2021.06.16
I finally figured out how to get the Windows installer to boot from a USB flash drive. Thank you to Doc in the comments for kicking me off in the right direction!
- First create an NTFS partition. I made mine a second 8GB partition which fit everything comfortably.
- Download the Windows 10 ISO from Microsoft. (I know it feels dirty but Microsoft is offering this for free and legit so why not take advantage?)
- Copy the entire contents of this ISO onto your new NTFS partition (not the ISO itself).
- Add the following to
[path partition was mounted]/boot/grub/grub.cfg
menuentry "Windows 10" {
set root=(hd0,msdos2)
insmod ntfs
insmod chain
ntldr /bootmgr
}
Note the line set root=(hd0,msdos2)
. msdos2
must be set to whichever partition you copied the Windows 10 files to (counting starts at 1, not 0). Also note this is still using MBR, not GPT/UEFI. Maybe I will update with that at a later date but it should not be too hard to figure out.
You will need to disable Secure Boot for any of this to work.