Thursday, March 28, 2024
Google search engine
HomeLinux TutorialsHow to resize VPS with LVM Partition

How to resize VPS with LVM Partition

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

root@server:~# qm list
  VMID NAME                 STATUS     MEM(MB)    BOOTDISK(GB) PID
   201 devninja                stopped    8196              800.00 0

run this command below for resize

root@server:~# qm resize 201 scsi0 +500G
Image resized.

verify the result

root@server:~# 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

[root@devninja ~]# 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

[root@devninja ~]#

Show current disk on VM

[root@devninja ~]# df -TH

How to resize VPS with LVM Partition01

show current Phisycal Volume

[root@devninja ~]# pvdisplay

How to resize VPS with LVM Partition

Resize Phisycal Volume

[root@devninja ~]# pvresize /dev/vda2

and then verify again with pvdisplay

Resize Logical Volume

[root@devninja ~]# lvresize -l +100%FREE /dev/mapper/centos-home

and then run resize2fs as that only applies to EXT2/3/4 partitions

[root@devninja ~]# resize2fs /dev/mapper/centos-home

or using xfs_growfs if you using xfs partition

[root@devninja ~]# xfs_growfs /dev/centos/root

show current disk

[root@devninja ~]# df -TH

How to resize VPS with LVM Partition03

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

[root@devninja ~]# 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 🙂

YOU CAN SUPPORT DEVNINJA WITH A CUP OF COFFEE

As we continue to grow, we would wish to reach and impact more people who visit and take advantage of the guides we have on our blog. This is a big task for us and we are so far extremely grateful for the kind people who have shown amazing support for our work over the time we have been online. to search or browse the published articles available FREELY to all.

If you like what you are reading, please consider buying us a coffee ( or more ) as a token of appreciation.

Support Us

DevNinja
DevNinja
System & Network Administrator Ninja
RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

18 − seven =

- Advertisment -
Google search engine

Most Popular

Recent Comments