[SOLVED] Increase local-lvm and VM disk size

bond347

Member
Oct 21, 2022
61
0
6
Hi All,

I'm sure you all have done and tested what I'm trying to achieve here!

I wanted to test/simulate the following:
My Scenario:
1. My Windows VM disk size is almost full and wanted to increase the disk size.
2. I have no available space on my local-lvm disk.
3. The only way to increase the disk's capacity is to add 1 new physical disk to the server's RAID. <--- This part I know what to do (Dell server).

Questions:
1. Once the server RAID disk is increased, what are the steps to check and increase the local-lvm disk?
2. Steps to increase VM disk?

I am also familiar to increase Windows C drive via the Disk Management tool.

Hope the expert can show me the way, thanks.
 
There is no built-in tool to increase lvm size in proxmox, so you will have to do it manually, see, for example this tutorial or this and this forum post for resources on how to do that. If you are scared of breaking your proxmox install you could set up a proxmox vm, try increasing the lvm size there, and then doing it on your server. And making backups is always recommended

Increasing vm disk size is easy, though. in the web interface click on your windows vm -> hardware -> select the hard disk and click disk actions. From there you can resize the disk.

PS: when I resized my windows vm I had the recovery partition to the right of the C drive, which made it a pain to resize the C drive. I just deleted the recovery partition and back up frequently. So far this has worked for me, but no guarantees.
 
  • Like
Reactions: bond347
Hi Noel and members,

Thanks for sharing the links.

As mentioned, i wanted to extend local-lvm disk.

1. Do my commands/steps below correct?
2. Do i need to run resize2fs pve/data command?
3. Do i need to run extend metadata lvm or others? What is the command?
4. Do i missed any steps?

Hope the expert can lead me.

# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 838.4G 0 disk
└─sda1 8:1 0 838.4G 0 part
sdb 8:16 0 1.6T 0 disk
├─sdb1 8:17 0 1007K 0 part
├─sdb2 8:18 0 512M 0 part /boot/efi
└─sdb3 8:19 0 1.6T 0 part
├─pve-swap 253:0 0 8G 0 lvm [SWAP]
├─pve-root 253:1 0 96G 0 lvm /
├─pve-data_tmeta 253:2 0 15.6G 0 lvm
│ └─pve-data-tpool 253:4 0 1.5T 0 lvm
│ ├─pve-data 253:5 0 1.5T 1 lvm
│ ├─pve-vm--901--disk--0 253:6 0 48G 0 lvm
│ └─pve-vm--902--disk--0 253:7 0 32G 0 lvm
└─pve-data_tdata 253:3 0 1.5T 0 lvm
└─pve-data-tpool 253:4 0 1.5T 0 lvm
├─pve-data 253:5 0 1.5T 1 lvm
├─pve-vm--901--disk--0 253:6 0 48G 0 lvm
└─pve-vm--902--disk--0 253:7 0 32G 0 lvm


# vgs
VG #PV #LV #SN Attr VSize VFree
pve 2 5 0 wz--n- 2.45t <854.36g



# lvsdisplay pve/data
LV Name data
VG Name pve
LV UUID VSw16D-4jjY-A9ei-tKhI-0eaa-9SeS-mTZIFR
LV Write Access read/write (activated read only)
LV Creation host, time proxmox, 2023-01-19 00:45:53 +0800
LV Pool metadata data_tmeta
LV Pool data data_tdata
LV Status available
# open 0
LV Size <1.49 TiB
Allocated pool data 0.81%
Allocated metadata 0.17%
Current LE 390117
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 2048
Block device 253:5


# lvextend -L +80G pve/data
Size of logical volume pve/data_tdata changed from <1.49 TiB (390117 extents) to <1.57 TiB (410597 extents).
Logical volume pve/data_tdata successfully resized.
#

# lvdisplay pve/data
--- Logical volume ---
LV Name data
VG Name pve
LV UUID VSw16D-4jjY-A9ei-tKhI-0eaa-9SeS-mTZIFR
LV Write Access read/write (activated read only)
LV Creation host, time proxmox, 2023-01-19 00:45:53 +0800
LV Pool metadata data_tmeta
LV Pool data data_tdata
LV Status available
# open 0
LV Size <1.57 TiB
Allocated pool data 0.77%
Allocated metadata 0.17%
Current LE 410597
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 2048
Block device 253:5
 
  • Like
Reactions: bond347
Hi Noel and members,

Thanks for verifying the steps.

I successfully the tested expanding Windows VM disk on the OS itself.

1. As in my previous exercise, i used 80G from sda1 and expanded VG "pve". Will VG "pve" stripe the data across sda1 and sdb3 OR will it make sure sdb3 fully occupied the disk space before writing onto sda1?

2. How do you expand Linux (Ubuntu) VM disk?
- I'm sure i need to do this "Linux vm -> hardware -> select the hard disk and click disk actions. From there i need to resize the disk, i.e., 10G.
- What are the steps to perform on Ubuntu OS to reflect the 10G expansion?

3. How do you expand containers?

Thanks in advance.
 
1. As in my previous exercise, i used 80G from sda1 and expanded VG "pve". Will VG "pve" stripe the data across sda1 and sdb3 OR will it make sure sdb3 fully occupied the disk space before writing onto sda1?
I don't know, sorry. You'll have to look that up. But if you find out, let me know.
2. How do you expand Linux (Ubuntu) VM disk?
- I'm sure i need to do this "Linux vm -> hardware -> select the hard disk and click disk actions. From there i need to resize the disk, i.e., 10G.
- What are the steps to perform on Ubuntu OS to reflect the 10G expansion?
Once you resized the harddiks, you will need to expand the partition. You can do this by booting into a live image and resizing from there:
  1. make a backup
  2. in the hardware tab of the proxmox web interface, add a disk with a Linux iso (e.g. gparted live, ubuntu, etc. Ubuntu is nice because it comes with gparted and the gnome gui)
  3. in the options tab of the proxmox web interface, double-click on boot order and drag your linux iso to the top
  4. boot the vm, you should be in your linux iso
  5. resize the disk with gparted
  6. remove the iso, reboot and check if it worked
3. How do you expand containers?

using pct resize. See man pct for infos on how
 
  • Like
Reactions: bond347
Hi Noel and team,

Let's go back to my original forum query.

I wanted to test/simulate the following:
My Scenario:
1. My Windows VM disk size is almost full and wanted to increase the disk size.
2. I have no available space on my local-lvm disk.
3. The only way to increase the disk's capacity is to add 1 new physical disk to the server's RAID. <--- In this part, I know what to do (Dell server).

BEFORE:
root@:~# fdisk -l /dev/sda
Disk /dev/sda: 1.64 TiB, 1799054426112 bytes, 3513778176 sectors
Disk model: PERC H755 Front
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 262144 bytes / 524288 bytes
Disklabel type: gpt
Disk identifier: 3D9D2579-2CA8-475D-9398-4DCEE8E26D5B

Device Start End Sectors Size Type
/dev/sda1 34 2047 2014 1007K BIOS boot
/dev/sda2 2048 1050623 1048576 512M EFI System
/dev/sda3 1050624 3513778142 3512727519 1.6T Linux LVM

Partition 1 does not start on physical sector boundary.


root@:~# pvs
PV VG Fmt Attr PSize PFree
/dev/sda3 pve lvm2 a-- <1.64t 16.00g



root@:~# pvscan
PV /dev/sda3 VG pve lvm2 [<1.64 TiB / 16.00 GiB free]
Total: 1 [<1.64 TiB] / in use: 1 [<1.64 TiB] / in no VG: 0 [0 ]



root@:~# vgs
VG #PV #LV #SN Attr VSize VFree
pve 1 4 0 wz--n- <1.64t 16.00g


Actions:
1. Inserted one 900GB HDD on the server.
2. Added newly inserted hdd into RAID group and rebuilt the RAID5 from 1.6TB to 2.4TB.
1676818013583.png

3. fdisk detected new HDD size
root@:~# fdisk -l /dev/sda |more
GPT PMBR size mismatch (3513778175 != 5270667263) will be corrected by write.
The backup GPT table is not on the end of the device.
Partition 1 does not start on physical sector boundary.
Disk /dev/sda: 2.45 TiB, 2698581639168 bytes, 5270667264 sectors
Disk model: PERC H755 Front
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 262144 bytes / 786432 bytes
Disklabel type: gpt
Disk identifier: 3D9D2579-2CA8-475D-9398-4DCEE8E26D5B

Device Start End Sectors Size Type
/dev/sda1 34 2047 2014 1007K BIOS boot
/dev/sda2 2048 1050623 1048576 512M EFI System
/dev/sda3 1050624 3513778142 3512727519 1.6T Linux LVM

4. Unfortunately, PVE and VG did not increment the new disk size
root@:~# pvs
PV VG Fmt Attr PSize PFree
/dev/sda3 pve lvm2 a-- <1.64t 16.00g


root@:~# pvscan
PV /dev/sda3 VG pve lvm2 [<1.64 TiB / 16.00 GiB free]
Total: 1 [<1.64 TiB] / in use: 1 [<1.64 TiB] / in no VG: 0 [0 ]


root@:~# vgs
VG #PV #LV #SN Attr VSize VFree
pve 1 4 0 wz--n- <1.64t 16.00g


Questions:
1. What was wrong?
2. What are the steps from the server OS side to detect and update the new hdd size?

Thanks in advance!
 
  • Like
Reactions: bond347
Hi,
There is a forum thread on exactly this [1]. You still need to increase the size of the physical volume on the lvm. `pvresize /dev/sda3` should expand your physical volume to the full size. See also [2].

[1]: https://forum.proxmox.com/threads/increase-lvm-storage-after-expanded-raid5-by-4tb.61623/
[2]: https://pve.proxmox.com/wiki/Resize_disks

Hi Noel,

Thanks for your help. I'm confused and need some pointers!


root@:~# pvresize /dev/sda3
Physical volume "/dev/sda3" changed
1 physical volume(s) resized or updated / 0 physical volume(s) not resized


I did the #pvresize but my physical volume is still the same 1.6T instead of 2.45TB. What is the issue or missing command?
root@:~# fdisk -l /dev/sda
GPT PMBR size mismatch (3513778175 != 5270667263) will be corrected by write.
The backup GPT table is not on the end of the device.
Disk /dev/sda: 2.45 TiB, 2698581639168 bytes, 5270667264 sectors
Disk model: PERC H755 Front
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 262144 bytes / 786432 bytes
Disklabel type: gpt
Disk identifier: 3D9D2579-2CA8-475D-9398-4DCEE8E26D5B

Device Start End Sectors Size Type
/dev/sda1 34 2047 2014 1007K BIOS boot
/dev/sda2 2048 1050623 1048576 512M EFI System
/dev/sda3 1050624 3513778142 3512727519 1.6T Linux LVM

Partition 1 does not start on physical sector boundary.


root@:~# pvs
PV VG Fmt Attr PSize PFree
/dev/sda3 pve lvm2 a-- <1.64t 16.00g


root@:~# pvscan
PV /dev/sda3 VG pve lvm2 [<1.64 TiB / 16.00 GiB free]
Total: 1 [<1.64 TiB] / in use: 1 [<1.64 TiB] / in no VG: 0 [0 ]


1. Increased RAID5 capacity from 1.6T to 2.4T - DONE
2. Increase PV /dev/sda3 to fully use the new capacity - NOT DONE
3. Increase VG "pve" to reflect new capacity - NOT DONE
4. Increase Windows vDisk PMX GUI > VM > Hardware - NOT DONE
5. Windows OS Disk Management, expand disk - NOT DONE
 
Last edited:
Sorry, forgot that you need to extend the GPT. The easiest way to extend the Table and resize the LVM is using gparted [1]. Download the gparted iso and create a bootable medium (usb stick, cd, whatever...) and boot into gparted. On launch, it will give you a warning that your table doesn't extend to the end and give you a button to fix it. Click that. While you are in gparted, you can also directly extend your /dev/sda3 lvm. Also make sure you have a backup. While nothing should break (and I just tested it with a recreation of your setup) I take no responsibility if something does break. These things can happen, especially when resizing disks.


[1]: https://gparted.org/
 
  • Like
Reactions: bond347
Hi Noel,

Thanks for reply.

I'm not really familiar in Linux.
Noted on your advice "make sure you have a backup". For my system assurance, could you guide me, prior to running gparted tool, how could i perform the backup?
 
Backups are a big subject and somewhat out of the scope of a forum response, so here a quick summary:

You can use proxmox backup server [1] to easily make a backup of the containers and virtual machines on your proxmox instance. If you have a spare computer and a harddrive with enough space, just install proxmox backup server on it, add it to your proxmox and make backups.

Alternatively, if you have an external usb drive or (unused drive in your server) you mount it and add it in to your proxmox (via `sotrage`->`add`->`directory`) and make backups of your containers and vms.

However, both these methods only make backups of your containers and vms, not your root system (i.e. the proxmox instance itself). This is not really problematic, since you probably have nothing important on the root system (except for some network configs or something which you can copy via ssh or onto a usb stick), so you can just set up a new proxmox instance and restore your containers and vms. If you want to backup your root system as well, have a look at some debian resources [2][3]. On my personal machine i use `timeshift` [4].

make sure your backups actually are usable (i.e. restoring backups to a new vm to test if everything worked).

Hope this gives you a rough overview of your options.


[1]: https://pbs.proxmox.com/docs/
[2]: https://www.debian.org/doc/manuals/debian-handbook/sect.backup.en.html
[3]: https://wiki.debian.org/BackupAndRecovery
[4]: https://github.com/teejee2008/timeshift
 
  • Like
Reactions: bond347
Hi Noel,

Thanks for very helpful information.

BTW, i'm interested with one of your suggestion above, backup to external USB/unused disk. Can elaborate more.

I had inserted a disk on my server. What are the steps to make this disk usebale to perform VM backups?

1. Insert unused disk
2. #fdisk -l and # lsblk detected disk as sda
Disk /dev/sda: 838.36 GiB

What should i do next?
3. Delete and recreate the partition?
4. Create a filesystem or format?
5. Mount the disk to /mnt?
6. sotrage`->`add`->`directory

Hope you can help me out with this.
 
Last edited:
Hi Noel,

Again thanks for providing the useful URL link.

Questions:
1. What should i use to create a disk partition, "#fdisk -c /dev/sda" or "#cfdisk /dev/sda"?
2. Is there any command to scan the newly inserted HDD? Like in Windows server, on Disk Management GUI, we click "Refresh Disk".
 
1. What should i use to create a disk partition, "#fdisk -c /dev/sda" or "#cfdisk /dev/sda"?
Doesn't really matter for your usecase. cfdisk is a little user-friendlier. After you created your partition table, you need to initalize a filesystem. Run mkfs -t ext4 /dev/sdX1 (replace the X with the letter of your disk) for that. When you are done you can check if everything worked with lsblk -f which will tell you what filesystem your disk is formatted as and how much space is available. And then you can mount the disk.
2. Is there any command to scan the newly inserted HDD? Like in Windows server, on Disk Management GUI, we click "Refresh Disk".
No need to do that. When you plug in your disk it will show up when you run lsblk
 
  • Like
Reactions: bond347
Hi Noel,

I really appreciate your patience and effort in helping me to resolve my queries, starting from expanding my server's physical RAID disk size to pv -> vg -> lv.

Again salute!
 
Hi Noel,

How can i mark this thread as SOLVED?
FYI, i don't see "Edit Thread" button at the top.
 
Glad to have helped :) Usually there should be an option to Edit thread on the top right above your first message in the thread. You might have to click the three vertical dots "⋮" to get the option, I don't quite remember.

Edit: apparently you can only edit threads within 30 days of creating them for whatever reason ¯\_(ツ)_/¯
 
Last edited:
  • Like
Reactions: bond347

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 your own in 60 seconds.

Buy now!