I needed a way for testing buildroot kernel. For this, I'd put my build on a flashdrive.
I started by preparing a flashdrive (I happen to have a spare 2 GB one) with a new MBR partition table and an ext2 filesystem. Then I installed grub on it.
# mkfs -t ext2 /dev/sdb1
# mount /dev/sdb1 /mnt/sys
# grub-install /dev/sdb --boot-directory=/mnt/sys
I then created a directory in it called images
to put all my built bzImages in.
Directory structure:
-- grub/
|-- fonts/
|-- i386-pc/
|-- locale/
|-- grub.cfg
|-- grubenv
-- images
|-- bzImage
|-- bzImage_0
|-- bzImage_1
|-- bzImage_2
Finally, I created grub/grub.cfg
with:
insmod ext2
insmod gfxterm
insmod regexp
set root='hd0,msdos1'
set menu_color_normal=cyan/blue
set menu_color_highlight=white/blue
set gfxmode=1280x1024
set bootparam=''
for entry in /images/*
do
menuentry $entry $entry {
echo 'Loading Linux'
linux $2 $bootparam
}
done
Tada!