Stupid lvm "tricks"

home | blog | Teh Internet | guest blog |rants | placeholder | political | projects | Gwen and Liam | Citadel patched | Tools | Scouts


- Careful Chrome users, this search box might be "Not secure"



I am getting older, so here is a spot for lvm, forgot how to remember stuff:

What physical (or raid) device(s) is / are the lvm associated with?
  # pvs
    PV         VG   Fmt  Attr PSize PFree  
    /dev/md2   vg0  lvm2 a-   1.77t 372.53g

So that would be vg0 on md device 2
Check cat /proc/mdstat for the physical disks in the md raid


If you want to see where it goes from there:

 # lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
vda    253:0    0   100G  0 disk 
├─vda1 253:1    0    96G  0 part /
├─vda2 253:2    0     1K  0 part 
└─vda5 253:5    0     4G  0 part [SWAP]
sr0     11:0    1  1024M  0 rom  


Whats a whozit volume group of the logical volume thingie?
# vgdisplay 
  --- Volume group ---
  VG Name               vg0
  System ID             
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  2
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                1
  Open LV               1
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               1.77 TiB
  PE Size               4.00 MiB
  Total PE              462726
  Alloc PE / Size       367358 / 1.40 TiB
  Free  PE / Size       95368 / 372.53 GiB
  VG UUID               Mwa-ha-ha


# lvdisplay
  --- Logical volume ---
  LV Name                /dev/vg0/lv0
  VG Name                vg0
  LV UUID                Tra-La-La-UuId
  LV Write Access        read/write
  LV Status              available
  # open                 1
  LV Size                1.40 TiB
  Current LE             367358
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     256
  Block device           252:0

So that would be volume group vg0 with the logical volume lv0 carved out of it
And look ma, extra physical extents. Can someone say snapshot?

Shrink it (WARNING- BACKUP FIRST AS YOU WILL PROBABLY LOOSE EVERYTHING)
e2fsck -f /dev/mapper/lvmtoshrink-part
resize2fs /dev/mapper/lvmtoshrink-part XXXG (reduce underlying fs - ext2-4)
lvreduce -L XXX+(something)G /dev/mapper/lvmtoshrink-part

You can re-run resize2fs again without params to get it to expand to the logical volume by skipping the size, but I like having wiggle room for snapshots.



[æ]