MoonPoint Support Logo

 


Shop Amazon Warehouse Deals - Deep Discounts on Open-box and Used ProductsAmazon Warehouse Deals



Advanced Search
October
Sun Mon Tue Wed Thu Fri Sat
   
14
   
2013
Months
Oct


Mon, Oct 14, 2013 10:52 pm

Determining the file system type

If you need to determine the file system type for a mounted drive on a linux system, one method you can use is to use the command df -T.
$ df -T
Filesystem         Type     1K-blocks    Used Available Use% Mounted on
/dev/sda1          ext4     306643128 4768956 286297596   2% /
udev               devtmpfs    497680       4    497676   1% /dev
tmpfs              tmpfs       203152     812    202340   1% /run
none               tmpfs         5120       0      5120   0% /run/lock
none               tmpfs       507880     288    507592   1% /run/shm
/home/joe/.Private ecryptfs 306643128 4768956 286297596   2% /home/joe

df displays the amount of disk space available on the file system containing each file name argument. If no file name is given, the space available on all currently mounted file systems is shown. Disk space is shown in 1K blocks by default, unless the environment variable POSIXLY_CORRECT is set, in which case 512-byte blocks are used. The -T parameter results in the file system type being printed as will using --print-type.

If you know the device name, e.g., /dev/sda1, you can specify it on the command line to eliminate extraneous information.

$ df -T /dev/sda1
Filesystem     Type 1K-blocks    Used Available Use% Mounted on
/dev/sda1      ext4 306643128 4776944 286289608   2% /

You can eliminate additional extraneous information, such as the 1K-blocks, used, available, and use% fields by piping the output into awk. E.g., the following command would print only the information for columns 1, 2 and the last column, which is "mounted on".

df -T /dev/sda1 | awk '{print $1,$2,$NF}'
Filesystem Type on
/dev/sda1 ext4 /

For awk, NF represents the number of fields on a line and $NF prints the last one. For just the filesystem type, you could print only the information from column 2 and eliminate any results for the first header line by using grep -v "Type":

$ df -T /dev/sda1 | awk '{print $2}' | grep -v "Type"
ext4

References:

  1. 5 Methods to Identify Your Linux File System Type (Ext2 or Ext3 or Ext4) By Ramesh Natarajan
    Date: April 18, 2011
    The Geek Stuff

[/os/unix/linux] permanent link

Once You Know, You Newegg AliExpress by Alibaba.com

Shop Amazon Local - Subscribe to Deals in Your Neighborhood

Valid HTML 4.01 Transitional

Privacy Policy   Contact

Blosxom logo