Is there any commandline tools to determine filesystem type on a block device before mounting it？and how is that achieved?
I believe it is possible since I usually mount external disks with
$ mount /dev/sdXX /mnt
mount automatically determines the filesystem for you. modern GUI tools even probe for disk usage and other info without mounting the filesystem if the driver for that fs is present.
the scenario here is that
- the partition type and filesystem type may mismatch.
- most linux filesystem use partition type "83", which doesn't offer much info about the fs it contains.
- the corresponding drive may be absent, missing xfsprogs, hfsprogs, etc.
when auto-mounting fails, with an arbitrary partition or disk image in hand, it's simply not feasible to try each fs type candidate until you find the right one. or what if the filesystem is corrupt. you can't diagnose it with the designate tool as it's fs type is unknown.
i think superblock is where most filesystem stores its identifier. but different fs write superblock at different places.
is the raw dump of data of XXX bytes in the beginning sufficient to determine the fs type? is there a standard on where and in what format one should store such info?
any insight on this issue is much appreciated.
thanx for philag's answer.
so the usual
file approach is actually the best approach.
my problem was just that i encountered a weird filesystem, whose
file output is rather useless.
digging deeper into
file's documentation (maybe the system calls it utilizes as well) should help me understand this issue better.