Page 1 of 1

FAT32 and GRUB

Posted: Sun Jan 20, 2013 6:33 pm
by singerng
I'm trying to create a bootable GRUB image with FAT32 on it. For some reason, Ubuntu can mount the image but GRUB can't. This is the process I used to create it:

Code: Select all

sudo dd if=/dev/zero of=kernel.img bs=1M count=100
sudo fdisk kernel.img
o
n
a
p
w
sudo losetup -o1048576 /dev/loop0 kernel.img
sudo mkdosfs -F32 /dev/loop0
sudo mount /dev/loop0 /mnt/hdd
sudo mkdir /mnt/hdd/boot
sudo mkdir /mnt/hdd/boot/grub
cp ~/Downloads/fat* ~/Downloads/stage* /mnt/hdd/boot/grub
sudo umount /dev/loop0
sudo losetup -d /dev/loop0
This all runs flawlessly. The issue is when I get to this part:

Code: Select all

grub --device-map=/dev/null
>device (hd0) kernel.img

>root (hd0,0)

>setup (hd0)

Error 17: Cannot mount selected partition

Re: FAT32 and GRUB

Posted: Mon Jan 21, 2013 2:01 am
by iansjack

Re: FAT32 and GRUB

Posted: Thu Jan 31, 2013 7:28 am
by singerng
OK, it seems to be working now. I forgot to change the partition's system ID, so I think that that was the problem, although many tutorials I read didn't tell me to do that. I also used the -c=dos flag for fdisk, so that partition one would start at sector 63, not 2048. Finally, I included argument specifying the cylinders, heads, and sectors per track to fdisk.

Thanks.