Skip to content

Latest commit

 

History

History
49 lines (31 loc) · 1.59 KB

LVM.md

File metadata and controls

49 lines (31 loc) · 1.59 KB

Common stuff

  • pvresize --setphysicalvolumesize 40G /dev/md1

Advanced

Move LV within same PV

needed if you need to defragment it (for example when shrinking pv)

pvmove --alloc anywhere -n Swap /dev/md1 /dev/md1:1000-1200

--alloc anywhere allows moving within same device /dev/md1:1000-1200 is extent range to move to (must be free ofc). Source also accepts range which can be helpful if you only need to move one part of it

Recover PV config

  • if you can get /etc/lvm/(archive|backup) from backup use that

  • if not, DD first 2MB of partition, it should contain LVM config like that:

         contents = "Text Format Volume Group"
         version = 1
         description = "Created *after* executing 'pvresize --setphysicalvolumesize 40G /dev/md1'"
         ...
                 }
             }
         }
    

    extract it from it to file

  • if not, grep partition for it and hope for best... sth like grep -a -A 1000 'Generated by LVM' /dev/ice

  • Take PV uid from config. run: pvcreate --uuid "<some_long_string>" --restorefile /etc/lvm/archive/VolumeGroupName_XXXXX.vg <PhysicalVolume>

discard drive

blkdiscard -v /dev/sda - discards drive. Add -s for secure erase. Will err out if not supported by controller/drive

Shrink system LVM

  • pvresize --setphysicalvolumesize 35G /dev/md1
  • mdadm -G -z36G /dev/md1
  • repartition to 40G
  • pvresize /dev/md1

dealing with duplicate VG names

  • get UUID from vgdisplay
  • activate via vgchange -ay --select vg_uuid=Z4INLD-t6Tz-jPF5-Zage-3lav-XoyA-rvlacV
  • if LV names do not collide it is working. if not TBD