HELP! FAT32 image not recognized.

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
HyperAssembler
Member
Member
Posts: 36
Joined: Thu Sep 04, 2014 5:24 pm
Location: !SIGSEGV

HELP! FAT32 image not recognized.

Post 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?
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Re: HELP! FAT32 image not recognized.

Post by Combuster »

Don't force a FAT size. That's illegal.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
HyperAssembler
Member
Member
Posts: 36
Joined: Thu Sep 04, 2014 5:24 pm
Location: !SIGSEGV

Re: HELP! FAT32 image not recognized.

Post 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.
Octocontrabass
Member
Member
Posts: 6299
Joined: Mon Mar 25, 2013 7:01 pm

Re: HELP! FAT32 image not recognized.

Post 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.
HyperAssembler
Member
Member
Posts: 36
Joined: Thu Sep 04, 2014 5:24 pm
Location: !SIGSEGV

Re: HELP! FAT32 image not recognized.

Post 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.
Octocontrabass
Member
Member
Posts: 6299
Joined: Mon Mar 25, 2013 7:01 pm

Re: HELP! FAT32 image not recognized.

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