Re: how to identify filesystem type

From: Theodore Ts'o
Date: Fri Aug 20 2004 - 22:26:39 EST


On Fri, Aug 20, 2004 at 11:58:58PM +0200, Andries Brouwer wrote:
>
> I suppose this code started as part of mount(8). For example,
>
> # mount --guess-fstype /dev/hdb2
> reiserfs

Actually, it was fsck's filesystem type detection code, and it's since
been completely rewritten.

> However, I cannot stress often enough that these are unreliable guesses.
> It is really undesirable when standard infrastructure starts depending
> on 99.7% guesses.

It's certainly possible for mistakes to be made, but it is really
quite reliable at this point --- escpecially since various
filesystem's mkfs programs and various lvm partition initialization
progams are pretty good about erasing other filesystems' signatures as
part of the mkfs/partition init process.

Everything is really a "guess" at some level; there is no guarantee
that /etc/fstab is 100% accurate, or that the partition table's type
fields are accurate. I will say that the ID code in the blkid library
is pretty paranoid about sanity checks, although of course it could be
better.

> Consequently, "blkid" is a really bad name. It gives no indication
> of the guessed nature of its results.
>
> (I see that my current version is also broken:
> # blkid -v
> blkid 1.0.0 (12-Feb-2003)
> # blkid
> ...
> /dev/sda4: LABEL="ZIP-100" UUID="34D8-1C07" TYPE="msdos"
> /dev/sda1: UUID="1ac5969c-8fdf-4f69-934a-c6103d93c05d" TYPE="ext2"
> /dev/sdb4: LABEL="ZIP-100" UUID="34D8-1C07" TYPE="msdos"
> /dev/sdb1: LABEL="CF_CARD032M" UUID="2001-1207" TYPE="msdos"
> ...
> Here no /dev/sda1 and no /dev/sdb4 exist.)

Blkid deliberately doesn't revalidate devices without any command-line
arguments, because certain devices might timeout or block for a
long-time. If you use "blkid /dev/sdb4", or use the library
interfaces, it will revalidate any entries found in the cache file
before returning them.

- Ted
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/