Grub and USB

Derek Broughton news at pointerstop.ca
Wed Aug 20 13:12:50 UTC 2008


Karl Larsen wrote:

>     New Subject. I have a running hard drive connected to my computer
> via a USB port. I need to put grub in the MBR of the USB hard drive OR
> put it on /media/disk/. I have a big problem with this. Grub likes to
> work with (hd1,2) and all my experience has been with things that will
> match that kind of partition location.
> 
>     People on this list have said it is a simple matter to get a USB
> hard drive to boot if you put the grub root at /media/disk/.

I've dealt with this issue numerous times, and I've never seen that
suggestion.  I think you're confused.

> I say you 
> can't do that because /media/disk/ is NOT a partition.

In "grub-install" you have two (important) parameters the --root-directory,
which IS the root directory of the system you're booting.  So if the USB
drive is currently mounted on /media/disk, use /media/disk.  The other is
the location you're going to install the boot block to, the "device".  This
can be a disk MBR or a partition superblock.  

> You might treat 
> the whole hard drive as a partition but how? It isn't /dev/sb4 or like
> that. 

In this case, the MBR is /dev/sb and the partition superblock is /dev/sb4
(or if your device was more normally named /dev/sdb and /dev/sdb4,
respectively)

> In fact I did a df and it calls the USB hard drive /dev/sdb1. now 
> /dev/sdb1 is (hd1,0) which I can work with. 

Sorry, wrong!  The BIOS device you're booting from is HD0!  So menu.lst
needs to respect that, though:

> I will try getting grub running and say:
> 
> grub  root (hd1,0)
> grub  setup (hd1,0)
> grub  quit
> 
> This should work.

It should, but that's why it's easier to use "grub-install" with actual /dev
names, because now you run into the confusion between what is (hd1) _now_
and what will be (hd1) when you boot. 

-- 
derek





More information about the ubuntu-users mailing list