I'm looking for a command that yields the filesystem type as mount would use/detect it, without actually mounting it. It should also work e.g. for LUKS encrypted devices (where file -s yields "LUKS encrypted file" instead of "crypto_LUKS"). Surely there is a more convenient way than parsing fsck -N /dev/whatever's output (which may use stderr depending on the existence of a corresponding fsck.TYPE)?

Another command that can come handy is # file -sL /dev/sdXY. This has one downside in that it does not work with the full block device. Requires the exact device to be passed. The output is quite neat though:

df -T will claim tmpfs for any loopdevice it seems, and fdisk -l doesn't appear to list a type when applied to a partition itself, while parted ignores the device for me and file -s yields the wrong format for a luks encrypted device. But blkid works perfectly, even for a loop device or the image file itself
–
Tobias KienzlerNov 1 '12 at 16:42

That behavior is expected out of df -T and fdisk -l. However, I don't understand how parted ignores the complete block device.
–
darnirNov 1 '12 at 16:48