Skip to content

Instantly share code, notes, and snippets.

@indriApollo
Last active February 8, 2018 09:03
Show Gist options
  • Save indriApollo/fbae66bf7964439436eee239b2db439e to your computer and use it in GitHub Desktop.
Save indriApollo/fbae66bf7964439436eee239b2db439e to your computer and use it in GitHub Desktop.
# list lvm partitions
sudo lvmdiskscan
sudo lvdisplay
# mount lvmgroup/lvmvol
sudo mount /dev/<VolGroup00?>/<LogVol00?> /mnt # /dev/VG_Name/LV_Name
# check if lvm used by vm
virsh list
virsh edit <vm name> # look for device='disk'
# lvm resize example
# 200G hdd
resize2fs /dev/vg0/foo 180G # resize filesystem
lvreduce --size 180G /dev/vg0/foo # resize logical volume
lvcreate --size 20G -n bar vg0 # create new volume
mkfs.ext4 /dev/vg0/bar
# create mountpoint
mkdir /mnt/vg0
# add to fstab
/dev/vg0/bar /mnt/vg0 ext4 defaults 0 2
# convert
qemu-img convert -O qcow2 /dev/mapper/lv_name <destination_file>.qcow2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment