Extending LVM on VM

Tomas Kucera

Active Member
Jun 13, 2018
8
1
43
Hi there, I would like to extend xxx-root LVM, that is mounted on /.

I had extended the physical volume using the PVE UI, so the sda shows size of 450GB, so there is 200GB available, which I want to allocate to sda2 and then use to extend the xxx-root to use all of the available free space.

Any way to achieve it safely without deleting and re-creating the partition (from obivous reason - data loss)?

Thanks in advance!

tom.+

Bash:
NAME         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda            8:0    0   450G  0 disk
├─sda1         8:1    0     1G  0 part /boot
└─sda2         8:2    0   249G  0 part
  ├─xxx-root 253:0    0    50G  0 lvm  /
  ├─xxx-swap 253:1    0   3.9G  0 lvm  [SWAP]
  └─xxx-home 253:2    0 195.1G  0 lvm  /home
 
Change correctly to your dm name !!
1) lvextend -l +100%FREE /dev/mapper/xxx-root
2a) resize2fs -p /dev/mapper/xxx-root # for ext*
2b) xfs_growfs /dev/mapper/xxx-root # for xfs
or as all-in-one
3) lvextend --resizefs -l +100%FREE /dev/mapper/xxx-root

Check new size with df :)
 
  • Like
Reactions: Kingneutron
Hi, sorry, missed your response.

I've tried this but it does nothing.

> lvextend -l +100%FREE /dev/mapper/xxx-root says:
New size (12801 extents) matches existing size (12801 extents).

> lvextend --resizefs -l +100%FREE /dev/mapper/xxx-root says:
Size of logical volume cl_sail/root unchanged from 50.00 GiB (12801 extents).

So, I am a but stuck here. :/
 
Output below. It confirms that the /dev/mapper/xxx-root has not been extended. :confused:



Bash:
Model: QEMU QEMU HARDDISK (scsi)
Disk /dev/sda: 483GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:

Number  Start   End     Size    Type     File system  Flags
 1      1049kB  1075MB  1074MB  primary  xfs          boot
 2      1075MB  268GB   267GB   primary               lvm

Model: Linux device-mapper (linear) (dm)
Disk /dev/mapper/xxx-home: 210GB
Sector size (logical/physical): 512B/512B
Partition Table: loop
Disk Flags:

Number  Start  End    Size   File system  Flags
 1      0.00B  210GB  210GB  xfs

Model: Linux device-mapper (linear) (dm)
Disk /dev/mapper/xxx-swap: 4161MB
Sector size (logical/physical): 512B/512B
Partition Table: loop
Disk Flags:

Number  Start  End     Size    File system     Flags
 1      0.00B  4161MB  4161MB  linux-swap(v1)

Model: Linux device-mapper (linear) (dm)
Disk /dev/mapper/xxx-root: 53.7GB
Sector size (logical/physical): 512B/512B
Partition Table: loop

Disk Flags:
Number  Start  End     Size    File system  Flags
 1      0.00B  53.7GB  53.7GB  xfs
 
Your problem is your partitioning as you just gave 267 GB in part-2 to lvm and so lvm cannot extend further to it's volumes than that.
You could try to resize your part-2 to full size of the disk or do a part-3 on sda and give that additional space over tp lvm.
 
I am somewhat noob in this. Would you, please, check this for me, if this is correct and that it will not cause data loss (of course backup before doing it)?

- to extend the sda2 to use 100% of the available disk space:
Bash:
parted /dev/sda resizepart 2 100%

- assign the space to the xxx-root:
Bash:
lvextend -l +100%FREE /dev/mapper/xxx-root
resize2fs /dev/mapper/xxx-root

Thanks in advance!
 
Ufff ... I am running somewhat ancient CentOS Linux 7 (Core) ... but found a solution:

Bash:
yum install cloud-utils-growpart
growpart /dev/sda 2
pvresize /dev/sda2
lvextend -l +100%FREE /dev/mapper/xxx-root
lvresize --extents +100%FREE --resizefs /dev/mapper/xxx-root

Thanks @waltar for hinting. ;)
 
  • Like
Reactions: waltar

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!