How to check if a disk has filesystem

…and how to identify the filesystem type if there is one.

/dev/sda1 has an ext4 filesystem

file -s /dev/sda1
/dev/sda1: Linux rev 1.0 ext4 filesystem data (needs journal recovery) (extents) (huge files)

If it is a logical volume

file -s /dev/mapper/vg-log_lv
/dev/mapper/vg-log_lv: symbolic link to `../dm-8'
file -s /dev/dm-8
/dev/dm-8: SGI XFS filesystem data (blksz 4096, inosz 256, v2 dirs)

A disk that is fully formatted without partition

file -s /dev/sdd
/dev/sdd: Linux rev 1.0 ext4 filesystem data (needs journal recovery) (extents) (large files) (huge files)

A boot disk which has GRUB installed

file -s /dev/sda
/dev/sda: x86 boot sector; GRand Unified Bootloader, stage1 version 0x3, boot drive 0x80, 1st sector stage2 0x849fc, GRUB version 0.94; partition 1: ID=0x83, active, starthead 32, startsector 2048, 1024000 sectors; partition 2: ID=0x8e, starthead 221, startsector 1026048, 3903268864 sectors, code offset 0x48

A physical disk that is a part of a volume group

file -s /dev/sdb
/dev/sdb: LVM2 (Linux Logical Volume Manager) , UUID: DDYX6fNzlUc9kNIOQy4ThArmcmS1NNN

A raw disk that has nothing on it

file -s /dev/sdg
/dev/sdg: data

For mounted and unmounted filesystems

/dev/sda1: UUID="1903878e-c843-41f0-8c19-d6fcbffe2f7f" TYPE="ext4"
/dev/sda2: UUID="VrW3QZ-UISy-nOs2-YRdF-tqNq-RTf1-TdnINU" TYPE="LVM2_member"
/dev/mapper/appvg-Linuxtest: UUID="f225de69-6515-4b92-b50d-4c050c4450bc" TYPE="ext4"
/dev/sdk: UUID="EIhkCv-NwG2-gKBv-ZzL5-PdZM-ZFce-caM0Jn" TYPE="LVM2_member"
/dev/mapper/test_vg-test_eg: UUID="bdda1d0f-1f80-4469-938a-cb0d6a3faf82" TYPE="ext4"
/dev/sdg: UUID="a99776f2-e6ff-42d5-94ea-19791896fcaa" TYPE="ext4"

Other methods

  lsblk -f 
  df -T  (shows only mounted filesystems)   

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your 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