Partition Type vs Filesystem Type: 6 Proven Linux Checks
"Partition type" and "filesystem type" sound like the same thing, and most guides mix them up. They are not. The partition type is a label in the partition table that says what a partition is meant for (Linux data, EFI system, swap). The filesystem type is what is actually written inside it (ext4, xfs, btrfs, vfat). A partition labelled "Linux filesystem" can hold any of them, or nothing at all. I created four partitions on a spare disk in a Debian 13 VM, formatted them as ext4, xfs, btrfs and vfat, and ran every command from the old version of this post to show which one answers which question.

Contents
The test disk
The spare disk /dev/vdc got a GPT partition table with four partitions, three created with the Linux type and one with the EFI System type, using sfdisk. Then each partition was formatted differently: mkfs.ext4, mkfs.xfs, mkfs.btrfs and mkfs.vfat, with labels data_ext4, data_xfs, data_btrfs and EFIPART. That setup is enough to show every difference that matters.
fdisk -l shows the partition type, not the filesystem
# fdisk -l /dev/vdc | sed -n '/^Device/,$p'
Device Start End Sectors Size Type
/dev/vdc1 2048 1050623 1048576 512M Linux filesystem
/dev/vdc2 1050624 2099199 1048576 512M Linux filesystem
/dev/vdc3 2099200 3147775 1048576 512M Linux filesystem
/dev/vdc4 3147776 3672063 524288 256M EFI System
Three different filesystems, one partition type. If you are asked to "check the partition type" before a reinstall, this column is what the installer and the firmware look at. The Type column comes from the partition table and was set when the partitions were created; formatting does not change it.
So fdisk -l is the right tool to list partition type codes (for example to check that an EFI partition is marked as such), and the wrong tool to find out what is inside. The old post's example of fdisk -l showing "83 Linux" and "82 Linux swap" was an MBR disk; on GPT, which this disk uses, fdisk shows names like "Linux filesystem" and "EFI System" instead of hex codes. See the fdisk manual for listing the full type table.
parted -l shows both
Number Start End Size File system Name Flags
1 1049kB 538MB 537MB ext4
2 538MB 1075MB 537MB xfs
3 1075MB 1612MB 537MB btrfs
4 1612MB 1880MB 268MB fat16 boot, esp
parted -s /dev/vdc print detected the filesystem in each partition, and shows the partition type only as flags (boot, esp for the EFI partition). It also printed Partition Table: gpt and Model: Virtio Block Device (virtblk).
lsblk -f and blkid: the filesystem type of every partition
To check the filesystem type on Linux, these two are the answer. Neither needs the partition to be mounted:
# lsblk -f /dev/vdc
NAME FSTYPE FSVER LABEL UUID FSAVAIL FSUSE% MOUNTPOINTS
vdc
├─vdc1
│ ext4 1.0 data_ext4 54fe8a5e-d726-4655-b19d-b42dfe959086
├─vdc2
│ xfs data_xfs 45ce1045-1e70-42cf-b6e8-b32c4673100e
├─vdc3
│ btrfs data_btrfs cae0e296-cd5a-45a3-8751-d0db94a82c76
└─vdc4
vfat FAT16 EFIPART BBD5-DB70
blkid gives the same information as KEY="value" pairs, including the partition's own ID (PARTUUID), which is different from the filesystem UUID:
/dev/vdc2: LABEL="data_xfs" UUID="45ce1045-1e70-42cf-b6e8-b32c4673100e" BLOCK_SIZE="512" TYPE="xfs" PARTUUID="c0ab3598-3baa-4d69-aeb1-867d71504f5b"
For scripts, ask blkid for one value only: blkid -o value -s TYPE /dev/vdc2 printed just xfs. The blkid manual describes -o and -s. Use UUID in /etc/fstab; it belongs to the filesystem and changes if you reformat, while PARTUUID belongs to the partition.
file -s: a second opinion
file -s reads the first blocks of a device directly and names what it finds, with extra detail:
/dev/vdc2: SGI XFS filesystem data (blksz 4096, inosz 512, v2 dirs)
/dev/vdc3: BTRFS Filesystem label "data_btrfs", sectorsize 4096, nodesize 16384, leafsize 16384, UUID=cae0e296-cd5a-45a3-8751-d0db94a82c76, 147456/536870912 bytes used, 1 devices
It is handy on an image file or a disk from another system, where the other tools may not have the information cached.
Mounted filesystems: df -T, findmnt and a stat trap
Once mounted, df -Th shows the type and the space:
Filesystem Type Size Used Avail Use% Mounted on
/dev/vdc1 ext4 488M 152K 452M 1% /mnt/e
/dev/vdc2 xfs 448M 35M 414M 8% /mnt/x
/dev/vdc3 btrfs 512M 5.8M 431M 2% /mnt/b
/dev/vdc4 vfat 256M 0 256M 0% /mnt/v
findmnt adds the mount options, which matter when you troubleshoot: /mnt/x /dev/vdc2 xfs rw,relatime,attr2,inode64,logbufs=8,logbsize=32k,noquota. The findmnt manual lists the columns.
Avoid stat -f -c %T for this job. It reported the ext4 filesystem, and the root filesystem which is also ext4, as ext2/ext3, and the vfat one as msdos. It reads the kernel's filesystem magic number, which ext2, ext3 and ext4 share.
Empty disks and wrong guesses
The extra hard disk in the VM had never been formatted. lsblk -f /dev/sda showed an empty FSTYPE column and blkid /dev/sda printed nothing and exited with 2. Trying to mount it anyway failed with the generic message:
mount: /mnt/e: wrong fs type, bad option, bad superblock on /dev/sda, missing codepage or helper program, or other error.
When you see that message, check the filesystem type first with blkid. An empty answer means there is no filesystem it recognises; do not run mkfs until you are sure the disk holds nothing you need. The kernel also lists the disk filesystems it can mount in /proc/filesystems; in this VM that was ext2, ext3, ext4, fuseblk, iso9660, vfat, btrfs and xfs.
Which command for which question
When someone asks for the partition type, first find out which of these they really mean:
- What is this partition marked as in the partition table?
fdisk -l(Type column) orparted print(Flags). - What filesystem is inside?
lsblk -f,blkid,file -s. - What is mounted, and how?
df -T,findmnt. - Avoid
stat -fto tell ext4 from ext2/ext3.
The same VM run had disks of different kinds; how to check if a disk is SSD or HDD uses them. For partitions under LVM, where the partition type is "Linux LVM" and filesystems live on logical volumes, see how to create LVM, and for df, du and mkfs basics, 9 essential bash commands.
Comments
Post a Comment