Page 1 of 1

HELP! FAT32 image not recognized.

Posted: Mon Sep 15, 2014 11:06 am
by HyperAssembler
Hello guys,

I made a FAT32 image file with grub2 in Linux and tried to run it on bochs.
As soon as it boots, grub2 enters the rescue mode.

"ls" gives "(hd0)"
And "ls (hd0)" gives "error: unknown filesystem."

The weird thing is that the image file can be correctly mounted in linux but cannot be opened on Windows using disk tools.

The script I used to generate the image is:
==========================================
KERNELIMG=$1
sudo umount /mnt
sudo losetup -d /dev/loop0
sudo losetup -d /dev/loop1
sudo rm $KERNELIMG
sudo dd if=/dev/zero of=$KERNELIMG bs=512 count=131072
echo "n
p
1
2048

a
1
w
" | sudo fdisk $KERNELIMG
sudo losetup /dev/loop0 $KERNELIMG -o 1048576
sudo losetup /dev/loop1 $KERNELIMG
sudo mkdosfs -v -F 32 /dev/loop0
sudo mount /dev/loop0 /mnt
sudo grub-install --root-directory=/mnt --no-floppy /dev/loop1
sudo umount /mnt
sudo losetup -d /dev/loop0
sudo losetup -d /dev/loop1
echo "p
" | sudo fdisk $KERNELIMG
==========================================

Anyone has any ideas?

Re: HELP! FAT32 image not recognized.

Posted: Mon Sep 15, 2014 1:09 pm
by Combuster
Don't force a FAT size. That's illegal.

Re: HELP! FAT32 image not recognized.

Posted: Mon Sep 15, 2014 1:30 pm
by HyperAssembler
Combuster wrote:Don't force a FAT size. That's illegal.
Thanks for your response but I don't know what you mean.
if you are talking about mkdosfs then the command would be
mkdosfs -f [fat size]. I'm using -F(capital) to specify filesystem.

Re: HELP! FAT32 image not recognized.

Posted: Mon Sep 15, 2014 5:11 pm
by Octocontrabass
HyperAssembler wrote:
Combuster wrote:Don't force a FAT size. That's illegal.
Thanks for your response but I don't know what you mean.
Microsoft wrote:The FAT type—one of FAT12, FAT16, or FAT32—is determined by the count of clusters on the volume and nothing else.
If you want a valid FAT32 filesystem, you must tell mkdosfs to generate a filesystem with at least 65525 clusters. Using -F to override that limit will create an invalid filesystem.

Re: HELP! FAT32 image not recognized.

Posted: Mon Sep 15, 2014 5:32 pm
by HyperAssembler
Octocontrabass wrote:
HyperAssembler wrote:
Combuster wrote:Don't force a FAT size. That's illegal.
Thanks for your response but I don't know what you mean.
Microsoft wrote:The FAT type—one of FAT12, FAT16, or FAT32—is determined by the count of clusters on the volume and nothing else.
If you want a valid FAT32 filesystem, you must tell mkdosfs to generate a filesystem with at least 65525 clusters. Using -F to override that limit will create an invalid filesystem.
Thanks for your response.

According to mkdosfs usage:
-F FAT-size
Specifies the type of file allocation tables used (12, 16 or 32 bit). If nothing is specified, mkdosfs will automatically select between 12 and 16 bit, whatever fits better for the filesystem size. 32 bit FAT (FAT32 format) must (still) be selected explicitly if you want it.
If I get rid of -F 32 then it will by default create a FAT16 partition which is not what i want.
Also "file <ImageName>.img" command only shows kernel.img is a x86 boot loader with no info for partition.

In grub rescue, type "ls" and I can only see "(hd0)" without any partitions.

So I'm thinking the way that I partition the image is wrong.

Aside:
I also tried FAT 16 version. Grub2 still complains unknown file system.

Re: HELP! FAT32 image not recognized.

Posted: Mon Sep 15, 2014 10:47 pm
by Octocontrabass
HyperAssembler wrote:Aside:
I also tried FAT 16 version. Grub2 still complains unknown file system.
FAT16 requires a minimum of 4085 clusters (and no more than 65524 clusters) and your filesystem does not meet those limits either.