From Electron Cloud
A common problem is not being able to install GRUB because the medium is not a "system" drive: could be a CompactFlash card in a PCMCIA slot, or a USB thumb drive or some such. The trick is to tell grub which device is going to be hd0 on the target system. (Be sure to substitute hdX with the actual "target image" drive.)
grub> device (hd0) /dev/hdX grub> root (hd0,0) root (hd0,0) Filesystem type is ext2fs, partition type 0x83 grub> setup (hd0) Checking if "/boot/grub/stage1" exists... yes Checking if "/boot/grub/stage2" exists... yes Checking if "/boot/grub/e2fs_stage1_5" exists... yes Running "embed /boot/grub/e2fs_stage1_5 (hd0)"... 17 sectors are embedded. succeeded Running "install /boot/grub/stage1 (hd0) (hd0)1+17 p (hd0,0)/boot/grub/stage2 /boot/grub/menu.lst"... succeeded Done.
(Thanks to Joe Pfeiffer for the hint.)
E.g. I ran into this using buildroot/uclibc: it generates an ext2 partition, not an entire CF image. Then I copied the files from the ext2 image to an ext3 partition on CF. The grub files are in place in /boot/grub, but I still have to install the MBR. So just chroot and do the above steps, and it's OK even if the CF card is not actually (hd0) at the time (e.g. in a PCMCIA slot, it shows up as hde or some such).