7

We are making extensive use of the logical volume manager (LVM) on our Debian servers. But I find it hard to get a good overview on which partitions (LVM as well as native) I have mounted where, from which LV (logical volume) from which VG (volume group) and from which PV (physical volume). There are console tools like "lvdisplay -v" and "lvs" but those always just give me a partial view of everything. What I'd wish for is a textual representation something like:

 Volume group "vgmain" ======================= consists of physical volumes: - /dev/sda1 (300 GB, 50 GB unused) - /dev/sdb1 (300 GB, 120 GB unused) - /dev/sdc1 (300 GB, nothing unused) provides logical volumes: - lvroot (EXT3 mounted on /, 4 GB, 0.5 GB free) - lvmysql (XFS mounted on /var/lib/mysql, 8 GB used, 2 GB free) Volume group "vghuge" ======================= consists of physical volumes: - /dev/sdc2 (800 GB, 250 GB unused) provides logical volumes: - lvhome (XFS mounted on /home, 300 GB, 90 GB free) - lvbackup (XFS mounted on /mnt/backup, 300 GB, 20 GB free) 

Just as an idea how that might look. Is there such a tool? If nothing like that exists yet I think I'll have to script something myself which queries "df", "lvdisplay", "vgdisplay" and "pvdisplay" and creates such an overview.

Thanks in advance.

4 Answers 4

5

This didn't take long to write.

8
  • +1 Beats my cheesy script for completeness, although when I run it, I noticed it's missing volume groups? Commented Jun 19, 2009 at 16:30
  • Hmm, it finds all (both) of my volume groups. Commented Jun 19, 2009 at 16:34
  • Do you have names like vgdata and vgdata2, and vgdata is not displayed (and vgdata2 maybe displayed twice)? If so, try changing 'grep $vgname' to 'grep -w $vgname'. Commented Jun 20, 2009 at 3:00
  • pgs, your script is awesome. Thanks for your contribution. It was even new to me that lvdisplay can show which physical volumes a certain logical volume is living upon. I'll surely deploy this script on my servers. Commented Jun 21, 2009 at 12:09
  • Noticed the script just yet. Nice work. RHEL-like fstabs have entries like /dev/VG/LV though, not /dev/mapper/VG-LV. That is even though the mount command shows the latter mounted, not the former. Commented Jun 26, 2009 at 12:58
2

GNU Parted can give you most of the information you need with

parted -l 

It seems It only fails to effectively link lvm parttion to device mapper devices. I am sure they will welcome your patch. ;-)

1

Cheesy, but it shows everything (except where the filesystems are mounted). Save it as /usr/sbin/lvms

#!/bin/sh #lvms command - consolidates all LVM views into a single command pvscan 1>/dev/null 2>/dev/null vgscan 1>/dev/null 2>/dev/null lvscan 1>/dev/null 2>/dev/null echo "Available Physical Volumes - - - - - - -" pvs echo echo "Active Volume Groups - - - - - - - - - -" vgs echo echo "Active Logical Volumes - - - - - - - - -" lvs 

Follow-up: Pgs (on this page) has provided a much nicer script.

0

No, I don't think such a script exists. Would be a pretty cool thing to script though. I might actually look into that myself, the next time I have my weekly day-of-scripting ;-)

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.