Proxmox + ZFS Cheat Sheet

A handy list of commands for managing VM disks, resizing qcow2s, ballooning memory, guest agents, and ZFS ARC.


VM Disk Management

```bash

Convert VHDX qcow2

qemu-img convert -f vhdx -O qcow2 input.vhdx output.qcow2

Import qcow2 into a VM

qm importdisk /path/to/disk.qcow2 local-zfs

Attach imported disk

qm set --scsi0 local-zfs:vm--disk- qm set --boot order=scsi0

Free an old/unused disk

pvesm free local-zfs:vm--disk-

Show all disks for a VM

pvesm list local-zfs | grep

Show VM config

qm config

Delete a VM device (like scsi1 or unused0)

qm set --delete scsi1 qm set --delete unused0

Remove an ISO from VM config

qm set --delete ide2

Show qcow2 info

qemu-img info /root/win10-600G.qcow2

Shrink qcow2 to 600 GB

qemu-img resize --shrink /root/win10-600G.qcow2 600G

Disk maintenance

diskpart list disk select disk 0 list partition select partition 4 delete partition override select partition 3 extend exit

Fixed memory (no ballooning)

qm set --memory 16384 --balloon 16384

Ballooning range (min=4G, max=8G)

qm set --memory 8192 --balloon 4096

Disable ballooning device completely

qm set --balloon 0

Guest agent

pkg install qemu-guest-agent sysrc qemu_guest_agent_enable="YES" service qemu-guest-agent start service qemu-guest-agent status

ZFS ARC

Set ARC max (example: 8 GB)

echo "options zfs zfs_arc_max=8589934592" > /etc/modprobe.d/zfs.conf

Rebuild initramfs for all kernels

update-initramfs -u -k all

Check ARC max

cat /proc/spl/kstat/zfs/arcstats | grep c_max

Live ARC stats

arcstat 5

ARC summary

arc_summary

ARC Stats Alias

alias arcstats='arcstat 5 | awk "NR==1 {print \$0,\"hit%\",\"miss%\"} NR>1 {ddhits=\$5; ddmiss=(100-ddhits); print \$0,ddhits,ddmiss}"'

Combo Watch (ARC + VM Stats)

watch -n 5 'echo "=== ARC Stats ==="; arcstat 1 1 | tail -1; echo; echo "=== VM Memory/CPU ==="; qm list | egrep "VMID|100|108"'