Resize a partition

  1. lvextend –size +15g /dev/vg-name/vol-name - increase a volume by 15GB
  2. resize2fs /dev/vg-name/vol-name - resize the filesystem to the same size as the volume

Extending a filesystem using a new LUN - (Linux VM example)

  1. Format the disk with fdisk as a linux VM fstype
  2. vgextend vgname /dev/sdxx - add the newdisk to a volume group
  3. Check the volume group by running vgdisplay -v vgname
  4. Move the disk: pvmove /dev/old-disk /dev/new-disk
  5. Now extend the volume: lvextend -l +nnnnn /dev/vg-name/lv-name
  6. Extend the filesystem: resize2fs /dev/vg-name/lv-name
  7. Remove the old disk: vgreduce vg-name /dev/sdxx
  8. Delete the device: echo “1” > /sys/block/device-namedevice/delete
  9. In the vSphere client, for the VM, edit settings → select drive → remove

Creating a logical volume that will use all available space in a volume group

  1. lvcreate -n vol-name -L 1m /dev/vg-name - create a 1MB volume
  2. lvextend -l +100%FREE /dev/vg-name/vol-name - extend the volume using all available space
  3. mkfs -t ext3 /dev/vg-name/vol-name - create the filesystem

Importing a LVM Volume

  1. vgscan - make sure the volume group is visible to the target server
  2. vgchange -a y my-vg - activate the volume group my-vg
  3. ls /dev/mapper - LVM devices in the volume group should now be present
  4. mount /dev/mapper/my-vg-lv /mnt - mount the logical volume

Importing a volume with a conflicting volume group name (the VG name already exists on target server)

  1. Present the volume containing the VG to the server
  2. Run lvmdiskscan to check the disk is visible
  3. vgdisplay -v - make a note of the conflicting VG UUID
  4. Rename the VG by using the UUID e.g. vgrename VG-UUID vg00-import
  5. Activate the renamed VG: vgchange -a y vg00-import
  6. You can now mount the logical volume(s)

Recent Changes

Contribute to this wiki

Why not help others by sharing your knowledge? Contribute something to this wiki and join out hall of fame!
Contact us for a user name and password