antony@notes:~/virtualization$ cat "Shrink-the-VM-Disk-File-on-Proxmox.md"
Shrink the VM Disk File on Proxmox
Shrink the VM Disk File on Proxmox
1. Get Volume ID
$ pvesm list local-lvm --vmid 534
Volid Format Type Size VMID
local-lvm:vm-534-cloudinit raw images 4194304 534
local-lvm:vm-534-disk-0 raw images 107374182400 5342. Get the path to the disk
$ pvesm path local-lvm:vm-534-disk-0
/dev/pve/vm-534-disk-03. Create a Folder
$ mkdir ub22043. Shrink the Disk File
$ qemu-img convert -p -f raw -O qcow2 /dev/pve/vm-534-disk-0 /root/ub2204/ub2204.qcow2
(100.00/100%)4. Check
$ ls -lh ub2204/
total 12G
-rw-r--r-- 1 root root 12G May 19 13:14 ub2204.qcow2
$ qm create 535 --name ubtest2 --memory 12288 --cores 4 --net0 virtio,bridge=vmbr0
$ qm importdisk 535 ~/ub2204/ub2204.qcow2 local-lvm
$ qm set 535 --scsihw virtio-scsi-pci --scsi0 local-lvm:vm-535-disk-0
$ qm set 535 --ide2 local-lvm:cloudinit
$ pvesm list local-lvm --vmid 535
Volid Format Type Size VMID
local-lvm:vm-535-cloudinit raw images 4194304 535
local-lvm:vm-535-disk-0 raw images 107374182400 535
$ qm set 535 --boot c --bootdisk scsi0
$ nano /var/lib/vz/snippets/user535.yml
#cloud-config
hostname: ub2204
package_update: true
packages:
- nano
write_files:
- path: /etc/resolv.conf
permissions: 0644
owner: root
content: |
nameserver 8.8.8.8
system_info:
default_user:
name: bigred
groups: bigred
lock_passwd: false
sudo: ALL=(ALL) NOPASSWD:ALL
plain_text_passwd: 'bigred'
homedir: /home/bigred
shell: /bin/bash
ssh_pwauth: True
# - bootcmd will run on every boot
#bootcmd:
# - echo "hi andy" > /home/andy/test
$ nano /var/lib/vz/snippets/network535.yml
version: 1
config:
- type: physical
name: ens18
subnets:
- type: static
address: '192.168.33.99'
netmask: '255.255.255.0'
gateway: '192.168.33.254'
$ qm set 535 --cicustom "user=local:snippets/user535.yml,network=local:snippets/network535.yml"
update VM 535: -cicustom user=local:snippets/user535.yml,network=local:snippets/network535.yml
$ qm start 535