[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#663540: finds MSDOS when there is none



On 12.03.2012 08:57, Harald Dunkel wrote:
> Package: os-prober
> Version: 1.49
> 
> os-prober finds some MSDOS partition on my laptop:

[os-prober says /dev/sda2 is MSDOS,
 while parted and blkid identifies it as ext4]

I understand that, due to the fact that other utils correctly identifies
this filesystem as ext4, there's a bug in os-prober which can be corrected.

But anyway, this is a very minor situation which can be corrected on
your side once and forever.  I've no idea about level of your system
and technology knowlege, so I assume a beginner level, -- please
forgive me if you're not a beginner :)

All utils examine first few sectors of a filesystem to determine its
type based on some heuristics.

Ext* family (ext2, ext3, ext4) on purpose never, ever, touch first
512 bytes of the filesystem, these bytes are unused.  This place is
reserved for a bootloader.  So in order to detect ext* filesystem,
any tool should inspect subsequent sectors.

But MSDOS (FAT) filesystem, on the other hand, does use first 512
bytes and puts its "signature" there.

So a more naive approach at determining the filesystem type is to
check first 512 bytes, and if MS-DOS signature is found there,
report that it is MS-DOS.  This is, apparently, what os-prober is
currently doing.

I suspect you actually had ms-dos filesystem in this partition
before, but later installed linux and ext4 filesystem on it.
If this is the case, just zero out the first 512 bytes and no
tool, ever, even the ones who does not know anything about ext*,
will detect it as ms-dos filesystem.

How:

 dd if=/dev/zero bs=512 count=1 of=/dev/sda2

This will zero-out first 512 bytes on your sda2.  If you're
unsure, you may save it before doing so, to a file on _another_
filesystem, eg sda1 (root fs), like this:

 dd if=/dev/sda2 bs=512 count=1 of=/sda2-beginning.bin

It will create file named /sda2-beginning.bin, of length
512 bytes, and will save the start of your sda2 in it.
You can restore it back by doing

 dd if=/sda2-beginning.bin of=/dev/sda2

(or, in case you booted a rescue CD or something like that,
mount your regular root fs and specify corresponding path
there).

This may sound/smell/etc very dangerous, but if it really
_is_ ext4 (it appears to be) and if it is not a boot partition
(it is not), it is safe thing to do.

Thanks,

/mjt



Reply to: