How to check the filesystem type of a logical volume using lvm or any other utility?

For example, if my logical volume is /dev/vg1/lv1 then how to check its filesystem type?

I have made a ext4 filesystem in the logical volume using mkfs -t ext4 /dev/vg1/lv1. But don't know how to verify it. I could not see any option for thin is lvm?

  • Does anyone know how this is done on C/C++ level ?
    – Lothar
    Commented May 14, 2019 at 12:22
  • Is your question where is the LVM source code? Commented Mar 21, 2022 at 15:05

4 Answers 4


Same as you would with any other block device. e.g.

file -s /dev/vg1/lv1

If /dev/vg1/lv1 is a symbolic link, you'll also need file's -L (aka --dereference) option to de-reference it (i.e. follow it to the real device node it's pointing to):

file -L -s /dev/vg1/lv1

BTW, it's OK to use -L on a regular file.

If it's ext4, it'll say something like:

/dev/vg1/lv1: Linux rev 1.0 ext4 filesystem data, UUID=xxxx, volume name "yyyy" (needs journal recovery) (extents) (large files) (huge files)

Alternatively, you could run blkid /dev/vg1/lv1. That would report something like:

/dev/vg1/lv1: LABEL="yyyy" UUID="xxxx" TYPE="ext4"

From man file:

-s, --special-files

Normally, file only attempts to read and determine the type of argument files which stat(2) reports are ordinary files. This prevents problems, because reading special files may have peculiar consequences. Specifying the -s option causes file to also read argument files which are block or character special files.

This is useful for determining the filesystem types of the data in raw disk partitions, which are block special files. This option also causes file to disregard the file size as reported by stat(2) since on some systems it reports a zero size for raw disk partitions.

  • above commmands worked. Just wondering , there is no lvm command for this ?
    – sps
    Commented Oct 10, 2015 at 14:26
  • Doing this on my /dev/sdb1,2,5 - which are LVM partitions outputs /dev/sdb#: block special
    – Adeerlike
    Commented Dec 18, 2016 at 13:47
  • did you run just file, or file -s? -s (or --special-files) tells file to identify block or character special files. see man file and search for --special-files.
    – cas
    Commented Dec 19, 2016 at 0:10
  • my file needed --dereference so it could see through the symbolic link of /dev/vg0/lv0 Commented Jan 31, 2017 at 5:46

Use lsblk -f.

$ lsblk -f
    NAME            FSTYPE      LABEL          UUID                                   FSAVAIL FSUSE% MOUNTPOINT
    ├─sda1          ext4                       d2123fec-6c94-426f-b505-8cf3441122cf    742,6M    17% /boot
    └─sda2          LVM2_member                BLt1F3-S5E3-hBRX-Eqya-AUOx-wyxc-a5Yaf4                
      ├─fedora-root xfs                        59935050-8e89-4f7f-bf0f-2f448c4c680b     12,8G    15% /
      └─fedora-swap swap                       5fbca8c7-fd22-4acf-a411-d96a100c8ab2                  [SWAP]
    sr0             iso9660     VBox_GAs_6.0.8 2019-05-13-13-58-35-65  
  • it doesn't always show the logical volumes...
    – None
    Commented Sep 26, 2021 at 15:01

If the logical volume has multiple partitions, knowing the partition offsets can be helpful.

Use fdisk to read the volume's partition info:

linux1:~ # fdisk -l /dev/vg01/lv001
Disk /dev/vg01/lv001: 80 GiB, 85899345920 bytes, 167772160 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x000825ab

Device           Boot   Start       End   Sectors  Size Id Type
/dev/vg01/lv0011           63   3132674   3132612  1.5G 82 Linux swap / Solaris
/dev/vg01/lv0012 *    3132675 167734664 164601990 78.5G 83 Linux

Then use blkid to determine the filesystem type. The -p option performs a deep probe bypassing the local blkid cache file, and capital -O determines the byte offset to inspect. The offset is determined by multiplying the start sector by the sector size; e.g.,

 `expr 3132675 \* 512`

where the backticks are for inlining the expression, and the backslash \* prevents bash from eating the asterisk.

Here's the blkid command used to determine the target filesystem:

linux1:~ # blkid -pO `expr 3132675 \* 512`   /dev/vg01/lv001
/dev/vg01/lv001: UUID="..." VERSION="1.0" TYPE="ext3" USAGE="filesystem" PTTYPE="dos"

which in this example is: ext3.

To access the filesystem, mount the offset:

mount -o offset=`expr 3132675 \* 512`  /dev/vg01/lv001 /mnt/lv001

The above operations performed on SLES 12.4:

linux1:~ # uname -a
Linux linux1 4.12.14-95.6-default #1 SMP Thu Jan 17 06:04:39 UTC 2019 (6af4ef8) x86_64 x86_64 x86_64 GNU/Linux

wipefs ( with no options ) will do it too...

[root@localhost backup]# wipefs /dev/mapper/d2-vmStorage
DEVICE       OFFSET TYPE UUID                                 LABEL
d2-vmStorage 0x0    xfs  141c43c0-ebdb-414a-aa8a-1a23871b9052 

same output from file -s :

[root@localhost backup]# file -L -s /dev/mapper/d2-vmStorage
/dev/mapper/d2-vmStorage: SGI XFS filesystem data (blksz 4096, inosz 512, v2 dirs)

To actually wipe the fs :

[root@localhost backup]# wipefs -a /dev/mapper/d2-vmStorage
/dev/mapper/d2-vmStorage: 4 bytes were erased at offset 0x00000000 (xfs): 58 46 53 42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .