On Sun, 30 Dec 2007 10:36:41 -0400
Derek Broughton <email@example.com> wrote:
> Peter Garrett wrote:
> > On Sat, 29 Dec 2007 09:27:49 -0400
> > Derek Broughton <firstname.lastname@example.org> wrote:
> >> If I go into grub:
> >> grub> root (<TAB>
> >> the tab-completion shows only hd0 as an option - so grub doesn't see the
> >> drive (the light is on, but apparently nobody's home :-))
> > Grub is a finicky little beast
[snipped contents of /boot/grub/ etc.]
> That's all there, and device.map =
> (hd0) /dev/sda
> (hd1) /dev/sdb
This could be the problem ? Does the USB drive install even need to know
about other drives? Surely udev, hal etc. pick this up on boot?
> > In my case I needed to do:
> > echo "(hd0) $DRIVE" > /mnt/boot/grub/device.map
> > ( DRIVE being the whole target drive of course, ā la /dev/hda, /dev/sda
> > etc. and the /mnt is the mountpoint of my chroot, that is, the file
> > system we are installing to.)
> Now, part of the problem (for me at least) is that I'm never sure what that
> drive should be - right now, while running off my hard drive (/dev/sda)
> it's /dev/sdc, but on a fresh boot it would be /dev/sdb
Right - I have to confess that I have not done this with a detachable
drive, so I may be off base. As I sent my reply I remember thinking "Wait
a minute, what happens if you have two drives attached?" and so on...
> > chroot to the relevant file system, ( sudo chroot /mnt ) and run grub:
> > grub> root (hd0,1)
> > # ( substitute according to your device/partition. Note that hd0 refers
> > # to the $DRIVE that grub is *on* i.e. it doesn't care that the drive
> > # might actually be /dev/sdb from your viewpoint, or whatever)
> That's never made any sense to me. Surely, hd0 points to whatever drive the
> device.map file calls hd0 - and if we are actually booting direct from the
> USB (rather than chaining to the USB from the grub on the internal drive),
> I have no idea what the device map should contain - should the external
> drive be /dev/sda?
This is the thorny question... I don't know. I think, as you say, that if
you are chain loading you can just put grub on the root partition and off
you go - but for a direct boot the device would need grub on its MBR,
wouldn't it? Hence the device map is relative to the chroot - the chroot
has no idea that the internal drive exists, at least until it boots, at
which point I would expect /dev/ to be populated, and to show the internal
drive(s) with, for example, fdisk -l from the booted USB drive ( in a
similar manner to the way a live CD works).
Assumption: on boot, the system sees the USB device as the first (and only)
USB device, thus /dev/sda
Hence, if you run grub from a chroot *in* the USB device, the only entry in
device.map would be the (hd0) entry. Another example: I am testing my
install script using a qemu image. My device.map in that image contains
only (hd0) /dev/hda . Grub finds the root partition, specified in
this case as (hd0,1) during the setup of grub. So, I'm guessing that
(hd0) /dev/sda should be the only entry in yours....
in /boot/grub/menu.lst on the USB device's root partition. (note that I
say "I'm guessing" )
Snippets from my script, with wry comments, are attached
[ snippets.grub.derek.txt ]
Actually, all this would probably be easier with isolinux instead of
> > grub> setup (hd0) # this blats the MBR on $DRIVE - you have been
> > warned. Adjust as needed. grub> quit
> > Hopefully, now that grub has a device.map that makes sense, this will
> > work... you may see some "non-fatal" errors.
> Ah well, off to try another boot...
> > If the above incantations work, you should now have a working grub, and it
> > should boot... I suggest sacrificing a goat and a chicken at the full moon
> > at about this point...
> Damn, Peter, I should have asked this a week ago - it's going to be a while
> to the next full moon!
Alternatively, you could sacrifice a couple of virgins - but they are
increasingly hard to find ;p
"INX Is Not X" based on Ubuntu 7.04 Live CD: http://inx.maincontent.net
Screenshots slideshow: http://inx.maincontent.net/album/1.png.html
# $DRIVE is the whole target drive to which we are installing. ( e.g. /dev/hda, /dev/sda )
# Grub can't find what it needs, so we give it a kick in the pants. P.G.
echo -e "
Creating necessary files for the grub bootloader.
cp -a /mnt/usr/lib/grub/i386-pc/* /mnt/boot/grub/
# We apparently need to make a device.map too.
echo "(hd0) $DRIVE" > /mnt/boot/grub/device.map
# Not certain this is necessary, but it ain't broke, so... P.G.
echo -e "
Mounting /dev/ and /proc... mount --bind
mount --bind /proc /mnt/proc
mount --bind /dev /mnt/dev
echo -e "
Installing the grub bootloader... Please wait... This can take a few seconds...
# grub-install /dev/?da <-- doesn't work. We need to dump stuff on the MBR ... and grub can't find it.
# So we give grub another heartfelt kick...
grub --batch << EOF 2> /dev/null
root (hd0,1) # The root of system happens to be on /dev/?da2 in this case - for /dev/?da1 it would of course read (hd0,0)
# The above grub setup steps probably need to be run from a chroot to the system on the USB in your case, Derek
# i.e. chroot /mnt first, assuming that's where it's mounted.
# [snipped some irrelevant stuff]
echo -e "
Creating bootloader menu file..."
chroot /mnt update-grub -y > /dev/null 2>&1
# Work around the "savedefault" not working (error 15 is the result when it craps out)
echo -e "
Setting default... "
chroot /mnt grub-set-default default > /dev/null 2>&1
# [more snips, including setting up pretty colours
# Lots more of course, above and below this, but all irrelevant to the problem at hand!
ubuntu-users mailing list
Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-users