How to find out the file system of a LVM

4.4k views Asked by At

I have a logical volume at /dev/xvdk that I'd like to programmatically detect if it's unformatted. In the past, I've run "file -s" on physical devices and it'll return "data" if device is unformatted.

But because it's a LVM (I think?), it's giving me something like this, which isn't helpful.

sudo file -sL /dev/xvdk

/dev/xvdk: LVM2 PV (Linux Logical Volume Manager), UUID: pmk0C-FABx-LAsZxB, size: 536870912000

I've tried other commands like "fdisk", "lsblk", "parted", "lvdisplay". They all work on physical devices but not for LVM.

Suggestions?

1

There are 1 answers

2
dormi330 On BEST ANSWER

try file -s /dev/volumn-group/lv not the partition, like

[root@182 ~] # file -s /dev/vg1/test
/dev/vg1/test: symbolic link to `../dm-18'
[root@182 ~] # file -s /dev/dm-18
/dev/dm-18: data
[root@182 ~] # file -s /dev/vg1/root
/dev/vg1/root: symbolic link to `../dm-0'
[root@182 ~] # file -s /dev/dm-0
/dev/dm-0: Linux rev 1.0 ext4 filesystem data (needs journal recovery)    (extents) (large files) (huge files)
 # where /dev/vg1/root /dev/vg1/test is the logic volumn
 # /dev/vg1 the volumn group in 
 # /dev/xvdb is a disk