Änderungsstand: 2024-06-07
Bsp.: Ein erstellter Container wurde mit 8GB Speicherplatz erstellt. Am Ende sind allerdings 6GB ausreichend.

.
Folgende Befehle in der entsprechenden Node (pve1) verwende ich dafür:
pct stop 107
vzdump 107 -storage local -compress lzo
Folgende Ausgabe erhalte ich:
root@pve:~# vzdump 107 -storage local -compress lzo
INFO: starting new backup job: vzdump 107 --storage local --compress lzo
INFO: Starting Backup of VM 107 (lxc)
INFO: Backup started at 2024-06-07 19:16:06
INFO: status = stopped
INFO: backup mode: stop
INFO: ionice priority: 7
INFO: CT Name: alpine-nextcloud-docker
INFO: including mount point rootfs ('/') in backup
INFO: creating vzdump archive '/var/lib/vz/dump/vzdump-lxc-107-2024_06_07-19_16_06.tar.lzo'
INFO: Total bytes written: 2805934080 (2.7GiB, 72MiB/s)
INFO: archive file size: 1.16GB
INFO: Finished Backup of VM 107 (00:00:38)
INFO: Backup finished at 2024-06-07 19:16:44
INFO: Backup job finished successfully
INFO: notified via target `mail-to-root`
root@pve:~#
Das Backup des Containers wurde im „local (pve)“ angelegt. Nun kann ich den vorhandenen Container Löschen.
Achtung! CT 107 wird gelöscht! Im Zweifelsfall diesen folgenden Schritt überspringen und unter anderer ID wiederherstellen!
pct destroy 107
Jetzt stelle ich meinen Container wieder her, mit der Option, nur 6GB Speicherplatz zur Verfügung zu stellen:
pct restore 107 /var/lib/vz/dump/vzdump-lxc-107-2024_06_07-19_16_06.tar.lzo --rootfs local-lvm:6
Folgende Ausgabe erhalte ich:
root@pve:~# pct restore 107 /var/lib/vz/dump/vzdump-lxc-107-2024_06_07-19_16_06.tar.lzo --rootfs local-lvm:6
recovering backed-up configuration from '/var/lib/vz/dump/vzdump-lxc-107-2024_06_07-19_16_06.tar.lzo'
Logical volume "vm-107-disk-0" created.
Creating filesystem with 1572864 4k blocks and 393216 inodes
Filesystem UUID: d08f5984-e206-4ac7-afa3-53bc06cde5ff
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736
restoring '/var/lib/vz/dump/vzdump-lxc-107-2024_06_07-19_16_06.tar.lzo' now..
extracting archive '/var/lib/vz/dump/vzdump-lxc-107-2024_06_07-19_16_06.tar.lzo'
Total bytes read: 2805934080 (2.7GiB, 126MiB/s)
merging backed-up and given configuration..
root@pve:~#

.
Fertig…
Quelle: