Doesn't allow forcing file systems to 255 heads

Bug #615873 reported by Loïc Minier
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
dosfstools (Ubuntu)
New
Undecided
Unassigned

Bug Description

Binary package hint: dosfstools

Hi

Very old OMAP3 (e.g. BeagleBoard) boot ROMs and the QEMU emulation thereof don't support anything else than 255 heads in the boot partition from which the first bootloader is read (x-loader / MLO).

Apparently, using a mapper loop device (major 252 here) causes mkdosfs to select a different default (255 heads) than the default when writing to a plain file (63 heads).

15:20 < lool> for files, it checks the size and defaults to 32 sectors and 64
              heads
15:21 < lool> for unknown devices, it assumes hard disk and checks the
              geometry, but fails and so uses 63 sectors per track and 255 heads

Running file -s on the loop-mounted device before and after the change results in:
Current images:
/dev/mapper/loop0p1: x86 boot sector, mkdosfs boot message display, code offset 0x58, OEM-ID " mkdosfs", Media descriptor 0xf8, heads 64, sectors 144522 (volumes > 32 MB) , FAT (32 bit), sectors/FAT 1112, serial number 0x4c5f659b, label: " "

After mkdosfs on a loop device:
/dev/mapper/loop0p1: x86 boot sector, mkdosfs boot message display, code offset 0x58, OEM-ID " mkdosfs", Media descriptor 0xf8, heads 255, sectors 144522 (volumes > 32 MB) , FAT (32 bit), sectors/FAT 1112, serial number 0xcafca2f1, label: " "

which clearly indicates the difference in number of heads.

When creating the fs on the mapper device, I see:
unable to get drive geometry, using default 255/63

So I think there are some dosfstools issues here:
a) I think dosfstools tries to be a bit too clever about what the size of the FS means, if the FS is on a loop device or in a regular file, and if the size is one of a standard floppy, dosfstools will assume the geometry of the corresponding floppy
b) dosfstools fails to identify loop devices from the device mapper devices as loop devices
c) dosfstools doesn't allow for any override in sectors/heads

I'd personally rather see a) and b) go away by removing the tests altogether and just doing something clever when on real devices with a geometry (either a real floppy devices with a size which means something in this case, or a hard disk drive with a reported disk geometry; all other cases are guesses). But I guess it's too late to strip that away, as scripts and such might rely on this (well, perhaps nobody uses floppies anymore, but who knows).

So there are two ways to fix this for Ubuntu OMAP(3) images, either by patching the dosfstools defaults, or by allowing overrides and passing these.

Cheers,

ProblemType: Bug
DistroRelease: Ubuntu 10.10
Package: dosfstools 3.0.9-1
ProcVersionSignature: Ubuntu 2.6.35-14.20-generic 2.6.35
Uname: Linux 2.6.35-14-generic x86_64
Architecture: amd64
Date: Tue Aug 10 15:59:50 2010
ProcEnviron:
 LANGUAGE=fr_FR:fr:en_GB:en
 PATH=(custom, user)
 LANG=fr_FR.UTF-8
 SHELL=/bin/zsh
SourcePackage: dosfstools

Revision history for this message
Loïc Minier (lool) wrote :
Revision history for this message
Loïc Minier (lool) wrote :
Revision history for this message
Loïc Minier (lool) wrote :

Updated patch which tweaks the manpage slightly and adds the new flags to usage() output.

Revision history for this message
Loïc Minier (lool) wrote :

Hmm actually it seems to be more complex than just heads and sectors per track; creating a FS with random heads and sectors per track values still work in QEMU.

(See also bug #609706.)

summary: - Doesn't allow creating filesystems with 255 heads
+ Doesn't allow forcing file systems to 255 heads
Revision history for this message
Loïc Minier (lool) wrote :

So with Ubuntu's image losetup-ed and kpart -ax-ed:
sudo file -s /dev/mapper/loop0p1

/dev/mapper/loop0p1: x86 boot sector, mkdosfs boot message display, code offset 0x58, OEM-ID " mkdosfs", Media descriptor 0xf8, heads 64, sectors 144522 (volumes > 32 MB) , FAT (32 bit), sectors/FAT 1112, serial number 0x4c5f659b, label: " "

after mkdosfs -F 32 -H 64 -v /dev/mapper/loop0p1 and copying over the same files:
/dev/mapper/loop0p1: x86 boot sector, mkdosfs boot message display, code offset 0x58, OEM-ID " mkdosfs", Media descriptor 0xf8, heads 64, sectors 144522 (volumes > 32 MB) , FAT (32 bit), sectors/FAT 1112, serial number 0xf049b263, label: " "

If I don't recreate the FS, but just copy over the files, it doesn't work.

Revision history for this message
Loïc Minier (lool) wrote :

Ok, this doesn't work:
sudo mount /dev/mapper/loop0p1 /mnt; sudo cp -a /mnt2/* /mnt; sudo umount /mnt

but this does:
sudo mount /dev/mapper/loop0p1 /mnt; sudo rm /mnt/*; sudo cp -a /mnt2/* /mnt; sudo umount /mnt

The files are created by mcopy, so I suspect it's the true culprit.

Revision history for this message
Loïc Minier (lool) wrote :

and this doesn't work:
sudo mount /dev/mapper/loop0p1 /mnt; for f in /mnt2/*; do j=`basename $f`; sudo rm /mnt/$j; sudo cp -a /mnt2/$j /mnt; done; sudo umount /mnt

gah

Revision history for this message
Loïc Minier (lool) wrote :

This doesn't work either:
sudo mount /dev/mapper/loop0p1 /mnt; for f in /mnt2/*; do j=`basename $f`; sudo mcopy -o -i /dev/mapper/loop0p1 /mnt2/$j ::$j; done; sudo umount /mnt

but this does:
sudo mount /dev/mapper/loop0p1 /mnt; sudo rm /mnt/*; for f in /mnt2/*; do j=`basename $f`; sudo mcopy -o -i /dev/mapper/loop0p1 /mnt2/$j ::$j; done; sudo umount /mnt

tags: added: patch
Revision history for this message
Loïc Minier (lool) wrote :

So I fixed the issue I was seeing without these patches and I don't care for them anymore, however they do implement a missing feature to force the number of heads and sectors per track, which might be useful to someone.

We can keep this bug open or close it and reopen if it turns out to be useful to someone.

Revision history for this message
Pali (pali) wrote :

Specifying custom number of heads and sectors per track is now possible via new mkfs.fat's -g option available since dosfstools 4.2.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.