Topic: tech myref prev next

tech myref > Proxmox

Proxmox

Here are some notes on setting up the Proxmox virtualisation environment.

Edit the following file;

/etc/apt/sources.list.d/pve-enterprise.list

It will contain the following line;

deb https://enterprise.proxmox.com/debian/pve bullseye pve-enterprise

Change the content of the file to;

#deb https://enterprise.proxmox.com/debian/pve bullseye pve-enterprise
deb http://download.proxmox.com/debian/pve bullseye pve-no-subscription

Resize a Disk

qm resize 100 scsi1 +1T

If the volume was created with an MBR partition table and is later resized to a size greater than two terabytes, it will have to be converted to a GPT partition table. Use gdisk, delviered in the apt package of the same name, to accomplish this.

apt install gdisk
gdisk /dev/sdX

Press w to write a GPT partition table to the disk, copying the partitions in the extant MBR partition table. This shouldn’t destroy any data in any of the partitions.

Hypervisor Command Line

It’s possible to do a lot of tasks from the qm CLI.

qm list |
    grep running |
    awk -F'[^0-9]*' '$0=$2' |
    while read -r vm_id
        do qm suspend $vm_id --todisk 1
    done

Shrinking a Volume

This is a bit tricky and, done incorrectly, will result in loss of data!

From within the virtual machine, shrink the filesystem.

root@vale:~# /sbin/resize2fs -pM /dev/sdb1

This does not shrink the partition that the filesystem resides on; for this, use gdisk.

resize2fs can be used a second time, to increase the size of the filesystem to fill the partition. Just omit the -M option.

root@vale:~# /sbin/resize2fs -p /dev/sdb1

Next, resize the ZFS volume.

zfs list

zfs get volsize,reservation tank/vm-102-disk-1

root@star:~# zfs get volsize,reservation tank/vm-102-disk-1
NAME                PROPERTY     VALUE    SOURCE
tank/vm-102-disk-1  volsize      3.54T    local
tank/vm-102-disk-1  reservation  none     default

root@star:~# zfs set volsize=3T tank/vm-102-disk-1

root@star:~# zfs get volsize,reservation tank/vm-102-disk-1
NAME                PROPERTY     VALUE    SOURCE
tank/vm-102-disk-1  volsize      3T       local
tank/vm-102-disk-1  reservation  none     default
root@star:~# qm rescan
rescan volumes...

Shrinking the volume will have deleted the GPT backup partition table, which resides at the end of the disk and is a copy of the primary table, which resides at the start. gdisk has an option for recreating the backup partition table in the correct place on the disk. Run /sbin/gdisk and access the expert menu with the ‘x’ command. Reallocate the backup partition table to the end of the disk with the ‘e’ command. Simply hitting ‘w’ to re-write the partition table won’t work, as the backup table now lives beyond the end of the disk. Attempting to write beyond the end of the disk should cause the hypervisor to immediately stop the virtual machine.