https://blog.dgprasetya.com/promox-extend-lvm-partition-ofly/
https://pve.proxmox.com/wiki/Resize_disks
at previous tutorial, we've been extended lvm partition vm on promox with Live CD by using add new disk. But now, we can extend lvm partition on the fly without live cd or reboot the system, by resize lvm size only.
Requierement:
1. Use XFS as Filesystem at VM.
As far i know, only XFS filesystem can doing this method.
Configure
Resize Disk VM via qm cli
root@alpha:~# qm list
VMID NAME STATUS MEM(MB) BOOTDISK(GB) PID
201 alpha stopped 8196 32.00 0
root@alpha:~# qm resize 201 scsi0 +168G
Image resized.
root@alpha:~#
root@alpha:~# qm list
VMID NAME STATUS MEM(MB) BOOTDISK(GB) PID
201 alpha stopped 8196 200.00 0
root@alpha:~#
Resize Partition
[root@localhost ~]# parted /dev/sda
GNU Parted 3.1
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print
Model: QEMU QEMU HARDDISK (scsi)
Disk /dev/sda: 215GB
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 34.4GB 33.3GB primary lvm
(parted) resizepart 2 100%
(parted) print
Model: QEMU QEMU HARDDISK (scsi)
Disk /dev/sda: 215GB
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 215GB 214GB primary lvm
(parted) quit
[root@localhost ~]#
Show current disk at VM
[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 30G 1.1G 29G 4% /
devtmpfs 3.9G 0 3.9G 0% /dev
tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs 3.9G 8.5M 3.9G 1% /run
tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
/dev/sda1 1014M 142M 873M 14% /boot
tmpfs 783M 0 783M 0% /run/user/1000
[root@localhost ~]#
show current Phisycal Volume
[root@localhost ~]# pvdisplay
--- Physical volume ---
PV Name /dev/sda2
VG Name centos
PV Size <31.00 GiB / not usable 3.00 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 7935
Free PE 0
Allocated PE 7935
PV UUID dWzC8B-TkO9-hiHN-Oodx-c2d-nzQ-zrJfGN
[root@localhost ~]#
Resize Phisycal Volume
[root@localhost ~]# pvresize /dev/sda2
Physical volume "/dev/sda2" changed
1 physical volume(s) resized / 0 physical volume(s) not resized
[root@localhost ~]#
[root@localhost ~]# pvdisplay
--- Physical volume ---
PV Name /dev/sda2
VG Name centos
PV Size <199.00 GiB / not usable 2.00 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 50943
Free PE 43008
Allocated PE 7935
PV UUID dWzC8B-TkO9-hiHN-Oodx-c2d-nzQ-zrJfGN
[root@localhost ~]#
Resize Logical Volume
[root@localhost ~]# lvresize --extents +100%FREE --resizefs /dev/centos/root
Size of logical volume centos/root changed from <30.00 GiB (7679 extents) to <198.00 GiB (50687 extents).
Logical volume centos/root successfully resized.
meta-data=/dev/mapper/centos-root isize=512 agcount=5, agsize=1965568 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=0 spinodes=0
data = bsize=4096 blocks=7863296, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal bsize=4096 blocks=3839, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 7863296 to 51903488
[root@localhost ~]#
Test
show current disk
[root@localhost ~]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
/dev/mapper/centos-root xfs 198G 1.1G 197G 1% /
devtmpfs devtmpfs 3.9G 0 3.9G 0% /dev
tmpfs tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs tmpfs 3.9G 8.5M 3.9G 1% /run
tmpfs tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
/dev/sda1 xfs 1014M 142M 873M 14% /boot
tmpfs tmpfs 783M 0 783M 0% /run/user/1000
[root@localhost ~]#
disk partition centos-root mapper now changed from 30GB to 198GB. yay !