How to Find the File System Type in Linux
File Systems are systems that are designed to manage, organize, store and retrieve persistent data on data storage devices. Data storage devices such as hard drives, flash drives and optical discs need to have a file system that is identified and recognized by your computer so that the operating system can perform operations such read and write to the stored data.
There are several different file system types that you can use or are used in Linux. Some of the most popular ones are ext3, ext4, ReiserFS, JFS and XFS. Many times you want to find out what the file system type is that is used on one of the data storage devices like the hard drive. Remember that it is possible to have different file system types within the same device if you have multiple partitions on the device.
There are various different ways for you to find out what particular file system is currently being used for a device. In order to query the device, the device needs to be mounted by the operating system and you should have access to the device. Also, having root or super user access to the system is desirable in most cases.
If a file system has been configured to be auto mounted, then the /etc/fstab will contain the information about the filesystem of the device. Remember that this information has been configured by somebody with prior knowledge of the device and the file system it uses. If the device is mounted correctly without any issues and performs I/O, then this information is correct. Otherwise, you might want to try one of the other methods to identify the file system type being used.
The file system type is the third column in the line that specifies the mount information. The first two are the partition or device name and the mount point. In the following example, the file system type of sda1 is ext2 while that of sda3 is resierfs.
bash$ cat /etc/fstab
/dev/sda1 /boot ext2 defaults 1 2
/dev/sda3 / reiserfs defaults 0 1
Disk Free (df) command
Another command you can use is the df (Disk Free) command that is usually used to find the available disk space on a Linux system. This command has a command line option (-T) that will print out the type along with other device information.
bash$ df -T
The -T option prints out the file system type as the second column in the output (header name: Type). Using the -a option will allow you to see all the devices including the dummy file systems that Linux uses.
The mount command, when used without any command line options will print out the information about all the mounted/known devices and partitions. The file system type is one of the information that you can find from this output, it is usually printed after the word type.
rootfs on / type rootfs (rw)
/dev/root on / type reiserfs (rw,relatime)
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
/dev/sda1 on /boot type ext2 (rw)
Mounts file in proc
You can also check the mounts file in the /proc to find out the type of all the devices and partitions. This provides a similar output to the previous mount command. The third column in each of the output lines is the file system type of that particular partition.
bash$ cat /proc/mounts
rootfs / rootfs rw 0 0
/dev/root / reiserfs rw,relatime 0 0
sysfs /sys sysfs rw,nosuid,nodev,noexec,relatime 0 0
/dev/sda1 /boot ext2 rw,relatime,errors=continue 0 0
Yet another command is blkid, which prints out various file system and partition specific information including the type.
/dev/sda1: UUID="094fd527-87fe-4dd8-8939-48f44f7d52f5" SEC_TYPE="ext2" TYPE="ext3"
/dev/sda2: UUID="2efe3fe0-2cc0-4d92-bfe4-825425ef6c9d" TYPE="swap"
/dev/sda3: UUID="feaaa9c1-b250-4524-922d-aa792481615d" TYPE="reiserfs"
/dev/sdb1: UUID="f2dc0afe-2047-43d4-bf14-ec268139e579" TYPE="ext3"
You can also do a low level probing of the device by specifying the partition name, which will print out more information regarding the partition itself
bash$ blkid -p /dev/sda3
/dev/sda3: UUID="feaaa9c1-b250-4524-922d-aa792481615d" VERSION="3.6" TYPE="reiserfs" USAGE="filesystem" PART_ENTRY_SCHEME="dos" PART_ENTRY_TYPE="0x83" PART_ENTRY_NUMBER="3" PART_ENTRY_OFFSET="5237190" PART_ENTRY_SIZE="307339515" PART_ENTRY_DISK="8:0"
The advantage of blkid over other command is that you can use it to probe the type of a partition which has not been mounted.
You can also use the GNU partition editor command, parted. Using the -l command line option will list all the partitions on all known block devices. Be careful, when you use this tool as you can inadvertently ruin or corrupt your partition if not careful.
bash$ parted -l
There are also a couple GUI options that are based on the underlying library that is used by parted. In Gnome, you can use Gparted or Kde Partition Manager in Kde. There are some more such as partitionmanager, diskman, and kvpm.
The following commands are useful when you already know the device name (or partition name).
The file command can treat the mounted devices as special files and print out the file system information. The command line option -s is used to specify that the file path is a special file.
bash$ file -s /dev/sda1 /dev/sda2 /dev/sda3
/dev/sda1: Linux rev 1.0 ext3 filesystem data, UUID=094fd527-87fe-4dd8-8939-48f44f7d52f5
/dev/sda2: Linux/i386 swap file (new style), version 1 (4K pages), size 524119 pages, no label, UUID=2efe3fe0-2cc0-4d92-bfe4-825425ef6c9d
/dev/sda3: ReiserFS V3.6
The advantage of the file command as with the blkid is that it will show the file system type even if the device has not been mounted, as long as there is an assigned device node.
Another command that can print out this information is the File System Check (fsck) command. The command line option -N will print out the type of the file system along with other information such as the device name and mount point.
bash$ fsck -N /dev/sda1 /dev/sda3
[/sbin/fsck.ext2 (1) -- /boot] fsck.ext2 /dev/sda1
[/sbin/fsck.reiserfs (2) -- /] fsck.reiserfs /dev/sda3
Here the file system type appears as the extension to the fsck command. So, in this sample output reiserfs is the file system type of /dev/sda3 and is written out as fsck.resierfs.