Because Windows does not recognize the ext4 filesystem, you have to make sure that your USB or external HDD is formatted in the NTFS or FAT32 format. And if you insert that drive into your Linux PC, and you’re not sure which format you used while formatting it, you can use several methods to determine its filesystem.
In this tutorial, we will look at different methods through which we can determine the filesystem of different drives and partitions.
Using the Parted command
The parted command has various uses, such as formatting a drive. You can also use it to detect the filesystems of any mounted or unmounted drive.
First, let’s see all the plugged partitions on our system using the lsblk command.
As you can see, sdb drive is not mounted anywhere currently, let’s check its filesystem type.
sudo parted -l
As you can see, my /dev/sdb drive has two partitions and one of them is FAT16. This is correct because the USB has Ventoy installed on it.
The fdisk command
The fdisk command can be used to get a basic idea of the filesystem type of any drive or partition. You have to specify the drive (sdX) in order to get the results successfully, but you can get the location of the drive using the lsblk command. Here, I’m looking for the details of /dev/sdb, but in your case, it can be different.
sudo fdisk /dev/sdb -l
The blkid command
If you use this command with the root privileges, its output will give you information regarding all the plugged drives and partitions such as its mount point, Label, UUID and filesystem type. You can use this command as follows :
The df command
The df command can also be used to determine the filesystem of only the mounted drives on your PC. You can use the command as mentioned below :
As you can see, it lists only the mounted partitions and lists everything in a neat and clean manner.
Using the file command
The file command along with the -sL option can also give you the details of a specific partiton. This does not work with the whole block drive, so you have to specify the individual partition (sdYZ) while using the command.
file -sL /dev/sdb1 # and file -sL /dev/sdb2
All of the above commands also give their output to stdout, you can use them in a shell script if you need to. We hope you have learned a new method of figuring out the filesystem of an unknown partition from this tutorial.