How to Find a Linux Partition’s Filesystem Type

Certainly this is a most basic task, but I am a most basic Linux user. There will come a time when you want to find out what filesystem a partition has on it. There are two types of partitions. Those that are mounted and those that are not. I’ll deal with those two main categories and the different ways you can handle them.

Mounted Filesystems and the ‘df’ Command

To find the filesystem type of a mounted partition, use the GNU df command with the -T option. Why did I specifically mention that the command has to be the GNU variety? Because the granddaddy UNIX version  doesn’t have the -T option which outputs the filesystem of the partitions. If you’re running HP-UX you’re most likely out of luck with the df command. Here’s the output on a CentOS VPS I tinker with:

root@myserver [/]: df -T
Filesystem    Type   1K-blocks      Used Available Use% Mounted on
/dev/sda1     ext3    30963708   6571772  22819072  23% /
none         tmpfs      393216         0    393216   0% /dev/shm
/usr/tmpDSK   ext3      495844     13065    457179   3% /tmp

Mounted Filesystems and the ‘mount’ Command

You can also simply run the “mount” command without any options (which is in reality running the -l option to list all mounted filesystems). Here’s the output of the “mount” command from the same VPS as above:

root@myserver [/]: mount
/dev/sda1 on / type ext3 (rw,usrquota)
proc on /proc type proc (rw)
none on /dev/pts type devpts (rw,gid=5,mode=620)
none on /dev/shm type tmpfs (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
/usr/tmpDSK on /tmp type ext3 (rw,noexec,nosuid,loop=/dev/loop0)
/tmp on /var/tmp type none (rw,noexec,nosuid,bind)

Furthermore you can choose to list out only those mounted filesystems of a certain filesystem type using the -t option. For example:

root@myserver [/]: mount -t ext3,tmpfs
/dev/sda1 on / type ext3 (rw,usrquota)
none on /dev/shm type tmpfs (rw)
/usr/tmpDSK on /tmp type ext3 (rw,noexec,nosuid,loop=/dev/loop0)

The above is the same as performing mount | egrep “ext3|tmpfs”

Mounted Filesystems and the fdisk Command

fdisk is a scary thing to wield when you realize the power that lies within. However, the -l option puts a ring in its nose so you can lead it around harmlessly. The -l option lists out a ton of informatoin about the partitions that are mounted. So much so that it can become a bit overwhelming to parse through. You’ll be happy if you know a bit about how to use grep. Fortunately, the server I’m using in this example doesn’t have many partitions:

Disk /dev/sda1: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sda1 doesnt contain a valid partition table
Disk /dev/sda2: 1073 MB, 1073741824 bytes
255 heads, 63 sectors/track, 130 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sda2 doesnt contain a valid partition table

Mounted Filesystems and the ‘mtab’ File

You could cat out the contents of the mtab file to see the status of currently mounted filesystems including their filesystem.

root@myserver [/]: cat /etc/mtab
/dev/sda1 / ext3 rw,usrquota 0 0
proc /proc proc rw 0 0
none /dev/pts devpts rw,gid=5,mode=620 0 0
none /dev/shm tmpfs rw 0 0
none /proc/sys/fs/binfmt_misc binfmt_misc rw 0 0
/usr/tmpDSK /tmp ext3 rw,noexec,nosuid,loop=/dev/loop0 0 0
/tmp /var/tmp none rw,noexec,nosuid,bind 0 0

Mounted Filesystems and the ‘/proc/mounts’ file

The /proc/mounts file is very similar to the ‘mtab’ file, but is supposedly more up to date. In fact, some people symlink /etc/mtab to /proc/mounts. Cat it out and compare it to the mtab file if you’d like.

Unmounted Filesystems and the ‘mount’ Command

If you have a drive that is not mounted, and want to know what the filesystem is, short of using some forensic analysis tools, you’ll need to actually mount the device. When given a block device and not passed any filesystem types, mount is run in ‘auto’ mode and will attempt to discern what filesystem is on the device. Apparently it will first try to mount it as one of the filesystems in /etc/filesystems. If that fails, it then tries all filesystems that are located in /proc/filesystems (quite an array!). The /proc/filesystems file is all of the filesystems that the kernel knows about including any modules that are loaded.

Once the drive is mounted, you can then run any of the above commands to find its exact filesystem. If mount wasn’t able to discern what filesystem was on the drive, you’ll need to perform some kind of offline analysis of the drive which that is beyond the scope of this post.

Unmounted Filesystems and the ‘fstab’ file

If you have a disk that usually auto-mounts but is not currently connected, you can still check to see what the filesystem is at least expected to be when it is available to mount. Look in the fstab file:

root@myserver [/]# cat /etc/fstab
/dev/sda1        /             ext3     defaults,usrquota       1 1
/dev/sda2        swap          swap     defaults       0 0
none             /dev/pts      devpts   gid=5,mode=620 0 0
none             /dev/shm      tmpfs    defaults       0 0
proc             /proc         proc     defaults       0 0
/usr/tmpDSK             /tmp                    ext3    defaults,noauto        0 0
/tmp             /var/tmp                    ext3    defaults,usrquota,bind,noauto        0 0

Notice that this only works if the disk that you are interested in is set to auto-mount when your Linux machine boots. If you look above at my example, my sda2 partition is in the fstab file but not the mtab file. Sda2 is not connected but I can still tell what the filesystem is expected to be when it is available to mount; the swap filesystem.


That’s all of the ways that I’ve been using to find out a partition’s filesystem type. I’m still a bit skittish about using fdisk and cfdisk to check filesystems, but I tend to shy away from using potentially destructive commands for information gathering. =) I also heard it was possible to use ‘blkid’ to find a block device’s filesystem, but was not able to get that to work. What other ways do you know? Add your preferred methods in the comments below and I’ll periodically update the blog post with the information.


  1. Vasil Kolev

    October 11, 2011 at 11:24 am

    Actually, the easiest way I use is the following:

    dd if=/dev/DEVICE of=tmpf bs=1024 count=20
    file tmpf

    which should be able to recognize everything. Count can be probably even less, but that requires some experiments.


    [email protected]:~$ sudo dd if=/dev/sda5 of=tmpf bs=1024 count=20
    20+0 records in
    20+0 records out
    20480 bytes (20 kB) copied, 0.000760921 s, 26.9 MB/s
    [email protected]:~$ file tmpf
    tmpf: Linux rev 1.0 ext2 filesystem data (mounted or unclean), UUID=aa581185-b88c-411a-a2e9-2a7377172d1f

    This can also handle all kinds of crap, like what bootsector or partition table is there at the beginning of the device.


    • Wesley David

      October 11, 2011 at 11:35 am

      Wow, that’s an awesome tip. In all of my searching, I never saw that method. Thanks!


    • John Carroll

      October 11, 2011 at 12:03 pm

      ‘file -sL /dev/sda1’ allows you to check it directly.


      • Wesley David

        October 11, 2011 at 4:20 pm

        I never even considered using the file command. Thanks!


  2. Thomas James

    October 11, 2011 at 3:07 pm

    You can use blkid to guess as well. Doesn’t work too well for lvm though


    • Wesley David

      October 11, 2011 at 4:19 pm

      In my last paragraph I mentioned that I had heard of people using blkid to find the filesystem type, but was never able to get it to work like others did. I’m using lvm so that probably explains the problems I was having.


      • Thomas James

        October 11, 2011 at 4:55 pm

        Oops sorry, yep i missed the last bit about blkid, i’ll blame reading the post on the iphone on a bus :p

        You post was well timed for me, I was just trying to do this on Monday. I really wish i had been able see the comment about using “file” then.

        Now i have a real keyboard i can type properly :)

        I found that blkid works fine for both linux software raid and lvm, but with lvm it really depends on how the logical volumes are arranged. For example i found that blkid was reporting my lvm partition as “swap”.

        That said if you suspect the partition is an lvm physical volume you can run the lvm scan & lvm change commands to bring it online then use blkid or the file method to determine the filesystem.



        • Wesley David

          October 11, 2011 at 7:33 pm

          Ahh, gotcha. I might have to revisit this post and add the file and lvm information. Oh, and not be mucking about with my laptop’s lvm. Nothing says ‘fun’ like tweaking a mounted lvm partition. =)


Leave a Reply

Follow TheNubbyAdmin!

follow us in feedly

Raw RSS Feed:

Contact Me!

Want to hire me as a consultant? Have a job you think I might be interested in? Drop me a line:

Contact Me!

Subscribe via Email

Your email address is handled by Google FeedBurner and never spammed!

The Nubby Archives

Circle Me on Google+!

Photos from Flickr

Me on StackExchange

The IT Crowd Strava Group

%d bloggers like this: