1

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?

propheci
  • 97
  • 1
  • 7
  • The Disks app (`gnome-disks-utility` front end) on Linux Mint also does not show this information. All it shows is LVM. Interestingly, the Timeshift app (system restore utility) will peer into the LVM partition and reveal the inner file system. Mint uses ext4 by default. – Ryan Oct 16 '19 at 00:52

1 Answers1

1

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
dormi330
  • 1,273
  • 11
  • 18
  • Thanks! This was the right direction. Turns out you can do `file -sL`. The `-L` dereferences the symlink. That worked for me. – propheci Dec 30 '16 at 22:12
  • This instruction does not help. I have LVM on Linux Mint. There are no devices listed with "vg1" or similar name. The Disks app also does not report what is inside the LVM (`gnome-disk-utility` front end). How do you know what the volume group is? – Ryan Oct 16 '19 at 00:44