FAT32 and GRUB

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
singerng
Posts: 21
Joined: Sun Jan 20, 2013 6:27 pm

FAT32 and GRUB

Post 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
User avatar
iansjack
Member
Member
Posts: 4711
Joined: Sat Mar 31, 2012 3:07 am
Location: Chichester, UK

Re: FAT32 and GRUB

Post by iansjack »

singerng
Posts: 21
Joined: Sun Jan 20, 2013 6:27 pm

Re: FAT32 and GRUB

Post 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.
Post Reply