increase disk spave local lvm

dejhost

Member
Dec 13, 2020
64
1
13
45
Hi.
One of my VM's (OPNsense) is desperate for more diskspace. Could you please guide me through the process?

Code:
root@proxmox03:~# lsblk
NAME                         MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
rbd0                         252:0    0     8G  0 disk
nvme0n1                      259:0    0 476.9G  0 disk
├─nvme0n1p1                  259:1    0  1007K  0 part
├─nvme0n1p2                  259:2    0   512M  0 part /boot/efi
└─nvme0n1p3                  259:3    0 476.4G  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   3.6G  0 lvm 
  │ └─pve-data-tpool         253:4    0 349.3G  0 lvm 
  │   ├─pve-data             253:5    0 349.3G  1 lvm 
  │   ├─pve-vm--107--disk--0 253:6    0   128G  0 lvm 
  │   ├─pve-vm--102--disk--0 253:7    0    32G  0 lvm 
  │   ├─pve-vm--105--disk--0 253:8    0    32G  0 lvm 
  │   └─pve-vm--104--disk--0 253:9    0     8G  0 lvm 
  └─pve-data_tdata           253:3    0 349.3G  0 lvm 
    └─pve-data-tpool         253:4    0 349.3G  0 lvm 
      ├─pve-data             253:5    0 349.3G  1 lvm 
      ├─pve-vm--107--disk--0 253:6    0   128G  0 lvm 
      ├─pve-vm--102--disk--0 253:7    0    32G  0 lvm 
      ├─pve-vm--105--disk--0 253:8    0    32G  0 lvm 
      └─pve-vm--104--disk--0 253:9    0     8G  0 lvm

It's the "pve-vm--102--disk--0", that should get increase by 20GB. I believe that "resize2fs" is the correct command? How do I address the target disk?

I am running PVE 7.0.11 on a HP Elitedesk G4. Thanks for helping.
 
Depending on your VM type (LXC container or KVM full VM), you can use either pct resize or qm resize command. In the case of a KVM machine, you'll also need to manually resize the partition and then the filesystem manually.
 
Hello iBug,

It's a full VM. So the command to use is:

qm resize <vmid> <disk> <size>

Retreiving the ID:
Code:
root@proxmox03:~# cat /etc/pve/.vmlist
{
"version": 135,
"ids": {
"105": { "node": "proxmox03", "type": "qemu", "version": 84 },
"107": { "node": "proxmox03", "type": "qemu", "version": 108 },
"102": { "node": "proxmox03", "type": "qemu", "version": 69 },
"104": { "node": "proxmox03", "type": "lxc", "version": 128 },
"100": { "node": "proxmox03", "type": "qemu", "version": 139 },
"101": { "node": "proxmox03", "type": "qemu", "version": 138 },
"103": { "node": "proxmox03", "type": "qemu", "version": 72 }}
}

Which leads to:
qm resize 102 ide0 +20G

That seems to have worked. Next step is to increase the partition and filesystem, which I struggle with:
Code:
root@OPNsense:/home/dejhost # gpart show
=>      63  67108801  ada0  MBR  (32G)
        63  67108545     1  freebsd  [active]  (32G)
  67108608       256        - free -  (128K)

=>       0  67108545  ada0s1  BSD  (32G)
         0        16          - free -  (8.0K)
        16  58719921       1  freebsd-ufs  (28G)
  58719937   8388608       2  freebsd-swap  (4.0G)
root@OPNsense:/home/dejhost # df -h
Filesystem           Size    Used   Avail Capacity  Mounted on
/dev/ufs/OPNsense     27G     27G   -1.7G   107%    /
devfs                1.0K    1.0K      0B   100%    /dev
devfs                1.0K    1.0K      0B   100%    /var/dhcpd/dev

Shouldn't it tell me here about available space? Didn't I just add 20GB?
 
Well it's FreeBSD and it's beyond my knowledge. I thought it was a typical Linux system with ext4 because you mentioned resize2fs, which is for the ext filesystem family (ext2 / ext3 / ext4).

You can consult guidances found online via Google-ing, like this one. The general idea is:
  • Run any necessary integrity checks to ensure disk and filesystem is in a good state
  • "Delete" the partition you want to grow. With most CLI tools (including fdisk, parted and gpart), this only deletes the entry in the partition table and doesn't touch the data.
  • Recreate the partition with the same "start sector" and an extended "end sector". This effectively extends the partition in-place. Watch out for any warnings (some may tell you there's a filesystem signature - make sure you don't wipe it).
  • Use filesystem-specific tools to grow the filesystem to the new size of the partition. For example, resize2fs for ext2/3/4 and xfs_grow for XFS. I don't know about FreeBSD so you'll have to find the right command by yourself.
Oh, and as well, you need to shutdown-and-start the VM for the new disk size to take effect. A simple reboot from inside may not always work.
 
Last edited:

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!