Linux – File System – Listing File Systems

Background

What is the File System on our disks?

Outline

  1. Commands
    • df ( Disk Free )
    • lsblk ( List Information on the block devices )
    • lshw ( List Hardware )
    • file ( File Command )
    • mount ( List Mount Points )
    • blkid ( List Information on Available Block Devices )
  2. System Configuration File
    • /etc/fstab

Commands

df ( Disk Free )

Outline

Lists available free space per each fileSystem.

Options

  1. -H
    • Human Readable
  2. -T
    • Include File System Type

Syntax


df

Sample


df -H -T

Output

Output – Image

df.01.20200527.0813AM

Output – Textual


>df -H -T
Filesystem          Type      Size  Used Avail Use% Mounted on
devtmpfs            devtmpfs  2.0G     0  2.0G   0% /dev
tmpfs               tmpfs     2.0G     0  2.0G   0% /dev/shm
tmpfs               tmpfs     2.0G   35M  2.0G   2% /run
tmpfs               tmpfs     2.0G     0  2.0G   0% /sys/fs/cgroup
/dev/mapper/cl-root xfs        54G  6.6G   48G  13% /
/dev/mapper/cl-home xfs       441G  9.4G  432G   3% /home
/dev/sda1           ext4      1.1G  218M  736M  23% /boot
tmpfs               tmpfs     392M   17k  392M   1% /run/user/42
tmpfs               tmpfs     392M  4.1k  392M   1% /run/user/545260630
>

Explanation

Informative

  1. Type
    • xfs
    • tmpfs
      • temp file system
  2. Lists Size Information
    • Size
    • Used
    • Avail
    • Use%

lsblk ( List Block Devices )

Outline

Lists information for block devices.

Options

  1. Columns
    • NAME
      • Device Name
    • KNAME
      • Internal Kernel Device Name
    • TYPE
      • Device Type
    • FSTYPE
      • File System Type
    • SIZE
      • Size of the Device
    • RA
      • Read Ahead of the Device
    • mountpoint
      • Where the device is mounted
    • Label
      • File System Label

Syntax


lsblk

Sample


lsblk --output NAME,KNAME,TYPE,FSTYPE,SIZE,RA,MOUNTPOINT,LABEL

Output

Output – Image

df.01.20200527.0813AM

Output – Textual


>df -H -T
Filesystem          Type      Size  Used Avail Use% Mounted on
devtmpfs            devtmpfs  2.0G     0  2.0G   0% /dev
tmpfs               tmpfs     2.0G     0  2.0G   0% /dev/shm
tmpfs               tmpfs     2.0G   35M  2.0G   2% /run
tmpfs               tmpfs     2.0G     0  2.0G   0% /sys/fs/cgroup
/dev/mapper/cl-root xfs        54G  6.6G   48G  13% /
/dev/mapper/cl-home xfs       441G  9.4G  432G   3% /home
/dev/sda1           ext4      1.1G  218M  736M  23% /boot
tmpfs               tmpfs     392M   17k  392M   1% /run/user/42
tmpfs               tmpfs     392M  4.1k  392M   1% /run/user/545260630
>

Explanation

Informative

  1. Type
    • xfs
    • tmpfs
      • temp file system
  2. Lists Size Information
    • Size
    • Used
    • Avail
    • Use%

lshw ( List Hardware )

Outline

Lists Hardware

Options

  1. Columns
    • Hardware Path
    • Device
    • Class
    • Description

Syntax


lshw

Sample


sudo lshw -short | egrep 'disk|volume'

Output

Output – Image

lshw.01.20200527.0938AM

Output – Textual


>sudo lshw -short | egrep 'disk|volume'
/0/100/1f.2/0.0.0    /dev/sda    disk           500GB CT500MX500SSD1
/0/100/1f.2/0.0.0/1  /dev/sda1   volume         1GiB EXT4 volume
/0/100/1f.2/0.0.0/2  /dev/sda2   volume         464GiB Linux LVM Physical Volume partition
/0/100/1f.2/0.1.0    /dev/cdrom  disk           DVD+-RW SH-216AB
>
>
>

Explanation

Informative

  1. Class
    • disk
      • /dev/sda
      • /dev/cdrom
    • volume
      • /dev/sda1
        • 1 GB => EX4 Volume
      • /dev/sda2
        • 464 GB => Linux LVM Physical Volume Partition

File ( List File Attributes )

Outline

Lists File Information

Options

  1. Filename
  2. Device Name

Syntax


sudo file -sL /dev/sda{,1,2}

Sample


sudo file -sL /dev/sda{,1,2}

Output

Output – Image

file.01.20200527.1148AM

Output – Textual


>sudo file -sL /dev/sda{,1,2}
/dev/sda:  DOS/MBR boot sector
/dev/sda1: Linux rev 1.0 ext4 filesystem data, UUID=3b0d8074-d527-4c92-9e07-f0b2a67826ce (needs journal recovery) (extents) (64bit) (large files) (huge files)
/dev/sda2: LVM2 PV (Linux Logical Volume Manager), UUID: 6pGhc4-MQBs-053D-3rxR-wAYh-DIkd-b6KM9D, size: 499033047040
>

Explanation

Informative

  1. Device
  2. File System
  3. UUID
  4. Size

blkid ( List Block Devices )

Outline

List Block Devices

Basic

Syntax


blkid

Sample


blkid

Output

Output – Image

blkid.01.20200527.0254PM

Output – Textual


>sudo blkid
/dev/sda1: UUID="3b0d8074-d527-4c92-9e07-f0b2a67826ce" TYPE="ext4" PARTUUID="fa74f74f-01"
/dev/sda2: UUID="6pGhc4-MQBs-053D-3rxR-wAYh-DIkd-b6KM9D" TYPE="LVM2_member" PARTUUID="fa74f74f-02"
/dev/mapper/cl-root: UUID="ff7f0df5-41ed-4647-ad5f-9fa701f06d22" TYPE="xfs"
/dev/mapper/cl-swap: UUID="af997147-1621-4bdc-89fd-5eeb7346b25e" TYPE="swap"
/dev/mapper/cl-home: UUID="15a8cce6-a202-48eb-a98e-fb0ac08f8619" TYPE="xfs"

Explanation

  1. /dev/sda1
    • ext4
  2. /dev/sda2
    • LVM2_member

 

Detail

Syntax


sudo blkid -po udev [device]

Sample

Device – 01
Code

sudo blkid -po udev /dev/sda1

Output – Image

blkid.device-01.01.20200527.0319PM

Device – 02
Code

sudo blkid -po udev /dev/sda2

Output – Image

blkid.device-02.01.20200527.0327PM

Output – Textual

>sudo blkid -po udev /dev/sda2
ID_FS_UUID=6pGhc4-MQBs-053D-3rxR-wAYh-DIkd-b6KM9D
ID_FS_UUID_ENC=6pGhc4-MQBs-053D-3rxR-wAYh-DIkd-b6KM9D
ID_FS_VERSION=LVM2\x20001
ID_FS_TYPE=LVM2_member
ID_FS_USAGE=raid
ID_PART_ENTRY_SCHEME=dos
ID_PART_ENTRY_UUID=fa74f74f-02
ID_PART_ENTRY_TYPE=0x8e
ID_PART_ENTRY_NUMBER=2
ID_PART_ENTRY_OFFSET=2099200
ID_PART_ENTRY_SIZE=974673920
ID_PART_ENTRY_DISK=8:0

Explanation

  1. /dev/sda2
    • ID_FS_VERSION
      • LVM2\x20001
    •  ID_FS_TYPE
      • LVM2_member
    • ID_FS_USAGE
      • raid
    • ID_PART_ENTRY_SIZE
      • 974673920

 

Mount ( List Mount Points )

Outline

Lists Mount Points

Syntax


mount

Sample


mount | column -t | grep -v 'nodev' | grep 'dev'

Output

Output – Image

mount.01.20200527.0108PM

Output – Textual


>mount | column -t | grep -v 'nodev' | grep 'dev'
devtmpfs on /dev type devtmpfs (rw,nosuid,seclabel,size=1894180k,nr_inodes=473545,mode=755)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,seclabel,gid=5,mode=620,ptmxmode=000)
/dev/mapper/cl-root on / type xfs (rw,relatime,seclabel,attr2,inode64,noquota)
mqueue on /dev/mqueue type mqueue (rw,relatime,seclabel)
hugetlbfs on /dev/hugepages type hugetlbfs (rw,relatime,seclabel,pagesize=2M)
/dev/mapper/cl-home on /home type xfs (rw,relatime,seclabel,attr2,inode64,noquota)
/dev/sda1 on /boot type ext4 (rw,relatime,seclabel)
>

Explanation

Informative

  1. Device
  2. When mounted/Mounted On
  3. type:- File System
  4. Options
    • rw ( readwrite)
    • noexec ( Execute Rights not granted )
    • relatime
    • seclabel
    • attr
      • attr2
    • inode
      • inode64
    • size
    • mode
      • 755
      • 620

 

System Configuration File

/etc/fstab

Outline

List information about disk partitions.

Syntax


cat /etc/fstab

Sample


cat /etc/fstab

Output

Output – Image

etc.fstab.01.20200527.0755AM

Output – Textual


>cat /etc/fstab

#
# /etc/fstab
# Created by anaconda on Mon Feb 17 16:55:59 2020
#
# Accessible filesystems, by reference, are maintained under '/dev/disk/'.
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info.
#
# After editing this file, run 'systemctl daemon-reload' to update systemd
# units generated from this file.
#
/dev/mapper/cl-root     /                       xfs     defaults        0 0
UUID=3b0d8074-d527-4c92-9e07-f0b2a67826ce /boot                   ext4    defaults        1 2
/dev/mapper/cl-home     /home                   xfs     defaults        0 0
/dev/mapper/cl-swap     swap                    swap    defaults        0 0
>

Explanation

Negative

  1. High-level information
  2. Does not show the amount of storage allocated to the device

Summary

A Linux system offers various utilities towards getting one comfortable with its file system.

The most direct approaches are through:-

  1. df
  2. lsblk
  3. lshw
  4. file

 

References

  1. Redhat
    • Products & Services > Product Documentation > Red Hat Enterprise Linux6 > Deployment Guide
      • Using the blkid Command
        Link
  2.  FibreVillage
    • lsblk command examples
      Link
  3.  TecMint
    • Find Linux File System Type
      Link
  4. Die.Net
    • file(1) – Linux man page
      Link
  5. Linuxize
    • Linux File Command
      Link
  6. Man7.Org
  7. The Open Group
  8. HowToForge
    • Linux lsblk Command Tutorial for Beginners (8 Examples)
      Link
  9.  Linuxaria
    • Linux Shell – lsblk
      Link

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s