This procedure about How to resize VPS with LVM Partition it’s works for any linux filesystem that has been formatted with LVM, and has also been tested resize lvm vps on a VM in the Proxmox server.
The guide is quite specific to linux with LVM and running an actual Virtual Machine guest.
How to resize VPS with LVM Partition
Requirement:
– backup or snapshot your vm
– good knowledge about LVM
– backup lvm metadata with vgcfgbackup
if need it
– You must know and make sure what partition type you’re using. usually linux using xfs
or EXT2/3/4
partitions
Resize Disk VM via qm cli
make sure the vm is stopped or shutdown
[email protected]:~# qm list VMID NAME STATUS MEM(MB) BOOTDISK(GB) PID 201 devninja stopped 8196 800.00 0
run this command below for resize
[email protected]:~# qm resize 201 scsi0 +500G Image resized.
verify the result
[email protected]:~# qm list VMID NAME STATUS MEM(MB) BOOTDISK(GB) PID 201 devninja stopped 8196 200.00 0
the command above can you skip if you’re using GUI from proxmox host
Resize Partition
resize to increase lvm partition, make sure you have choose right partition
[[email protected] ~]# parted /dev/vda GNU Parted 3.1 Using /dev/vda Welcome to GNU Parted! Type 'help' to view a list of commands. (parted) print Model: QEMU QEMU HARDDISK (scsi) Disk /dev/vda: 800GB Sector size (logical/physical): 512B/512B Partition Table: msdos Disk Flags: Number Start End Size Type File system Flags 1 1049kB 1075MB 1074MB primary ext boot 2 1075MB 800GB 800GB primary lvm (parted) resizepart 2 100% (parted) print Model: QEMU QEMU HARDDISK (scsi) Disk /dev/vda: 1396GB Sector size (logical/physical): 512B/512B Partition Table: msdos Disk Flags: Number Start End Size Type File system Flags 1 1049kB 1075MB 1074MB primary ext4 boot 2 1075MB 1396GB 1395GB primary lvm (parted) quit [[email protected] ~]#
Show current disk on VM
[[email protected] ~]# df -TH
show current Phisycal Volume
[[email protected] ~]# pvdisplay
Resize Phisycal Volume
[[email protected] ~]# pvresize /dev/vda2
and then verify again with pvdisplay
Resize Logical Volume
[[email protected] ~]# lvresize -l +100%FREE /dev/mapper/centos-home
and then run resize2fs
as that only applies to EXT2/3/4
partitions
[[email protected] ~]# resize2fs /dev/mapper/centos-home
or using xfs_growfs
if you using xfs partition
[[email protected] ~]# xfs_growfs /dev/centos/root
show current disk
[[email protected] ~]# df -TH
Troubleshoot
sometimes you will get wrong partition for resize. for example you want extend the /home
but you release command for root
partition. just decrease that with command
[[email protected] ~]# lvresize --resizefs -L -500G /dev/mapper/centos-root
and then run again the lvresize
command for increase /home
folder. if you need increase root from /home disk space. you can follow this link
and happy resize 🙂