Boot from USB using GRUB

My friend's laptop was in a car accident (he's fine!). However the laptop is very old its an Acer Aspire 1520 the CD-rom drive is broken and there is no floppy drive.

I made him a USB boot before I took a look at it and found that his BIOS cannot boot from USB. The only thing I have is a GRUB console but he is keen to just install XP (on USB) and use it just for Movies.

Is it possible using the GRUB console to get access to the USB and start the windows install? It's a tall order but I think this may be the way, or trying to install via LAN which I don't think will be achievable.


Solution 1:

Here is a quick example of grub commands that might just work, explanations and caveats below.

grub2

Most likely for post-2010 installs.

set root=(hd1,1)
chainloader +1
boot

grub

Most likely for pre-2005 installs.

root (hd1,0)
chainloader +1
boot

For the 2005-2010 period, your guess is as good as mine, but if you use the command for the wrong version, you only get a harmless syntax error on the first command.

Choosing the right root

At startup, grub will probe for your devices and assign numbers to them. All devices that are partitioned (hard disks and flash drives) will also have numbers assigned. The format is (<deviceName>,<partitionIndex>). In grub2, partition indexes changed, so the two examples above have the same effect despite looking to use different roots.

Your first device (hd0) is whichever device grub just loaded from. After that, you can usually assume that all the internal devices will come before your external devices. They will most likely be in the form of hd and a number.

After the comma is the partition index. Hard disks and thumb drives will almost always be partitioned, so you must choose the right (and most likely only) partition. CD-ROMs are usually not partitioned.

More documentation: http://www.gnu.org/software/grub/manual/html_node/Device-syntax.html

When choosing your root partition, you can use the Tab key to probe for device names and partition indexes. Just open parenthesis and start pressing Tab to see the list. Alternatively, newer versions provide the ls or find command.

Solution 2:

To elaborate on new123456's comment:

The USB device should be detected as a mass storage device and treated just like a hard drive. So, in grub, type root (hd (don't press Enter yet) and then hit tab once or twice to see what hard drives Grub can see. The USB device, if it's recognized, will probably be hd1. Don't specify a partition number; just add a closing parenthesis. So the line will be root (hd1). Then after that, type the following:

chainloader +1
boot

If that doesn't work, change root (hd1) to root (hd1,0) and try it again.

If for some reason Grub can't see the USB drive, try plugging in a USB CDROM and booting off that.

Solution 3:

The chainloader +1 thing might not work if the BIOS isn't good at booting from a USB key (which was why I was wanting to use Grub anyways).

In this case, there's some deep magic at https://help.ubuntu.com/community/Grub2/ISOBoot that works, at least for Ubuntu. The crucial bit is mucking with the grub command that identifies the vmlinuz file, passing the iso-scan/filename argument. Somehow, that helps it figure out that the entire boot filesystem is stuck in an ISO file. I don't know how the heck it works, but it does. These are (approximately) the Grub 2 commands I used:

loopback loop (fd0,msdos1)/path/to/iso/file
linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=/path/to/iso/file noprompt noeject
initrd (loop)/casper/initrd.lz
boot

The /path/to/iso/file should be the path to the ISO file on the USB key. The (fd0,msdos1) identifies the USB key. Tab-completion is super-helpful on the loopback line, and not useful for the arguments to vmlinuz.