Jul				13
                2024
				
					
					Create a new VM in the web interface (leave other settings as default)
copy VM disk to proxmox (ex. using terminal) and import it to newly created VM machine
qm importdisk machine_id_number /var/lib/vz/images/file.qcow local-zfs
qm rescan
Go to your new created VM in the proxmox web interface.
Go to the Hardware section of the newly created VM in the Proxmox web interface
Look for the Unused Disk and select it.
Then you have to add the disk by clicking on Edit on the top.
					
                    				
				 
			 
					
                
				Aug				27
                2023
				
					
					Shut down VM and then
Listing
qemu-img snapshot -l <file>.qcow2
Create
qemu-img snapshot -c <snap-name> <file>.qcow2
Revert to 
qemu-img snapshot -a <snap-name> <file>.qcow2
Delete
qemu-img snapshot -d <snap-name> <file>.qcow2
 
					
                    				
				 
			 
					
                
				Mar				25
                2023
				
					
					virsh snapshot-create-as --domain ${VM}
--name "backup-${VM}" \
--atomic \
--disk-only \
--no-metadata \
--diskspec vda,file=${SNAP}/backup-snapshot-${VM} \
--diskspec vdb,snapshot=no
					
                    				
				 
			 
					
                
				Jan				31
                2023
				
					
					Add hostdev for VF in <devices>. In <source>/<address> use physical address for VF
<hostdev mode='subsystem' type='pci' managed='yes'>
     <source>        
         <address domain='0x0000' bus='0x5e' slot='0x0e' function='0x0'/>
    </source>      
    <address type='pci' domain='0x0000' bus='0x07' slot='0x01' function='0x0'/>  
</hostdev>
					
                    				
				 
			 
					
                
				Jan				31
                2023
				
					
					Install from img file (with disk size 15G and bridge name inner)
virt-install \
--name=bull \
--vcpus=8 \
--memory=24576 \
--disk path=/var/lib/libvirt/images/bull.qcow2,size=15 \
--cdrom /var/lib/libvirt/iso/debian-11.6.0-amd64-netinst.iso \
--network bridge=inner,mac=52:54:00:40:4a:5e \
--boot hd,uefi \
--machine q35 \
--osinfo detect=on,require=off \
--graphics vnc,listen=<IP_HOST_TO_LISTEN_TO>,password=<SECRET>
Install from PXE
virt-install \
--name=rhpxe \
--vcpus=4 \
--memory=2048 \
--network bridge=br0,mac=52:54:00:0e:27:FF \
--pxe \
--disk none \
--boot uefi \
--osinfo detect=on,require=off \
--graphics vnc,listen=<IP_HOST_TO_LISTEN_TO>,password=<SECRET> 
					
                    				
				 
			 
					
                
				Oct				18
                2021
				
					
					<graphics type=”vnc” port=”5900″ autoport=”yes” listen=”SERVER_IP” passwd=”SECRET_PASSWORD”>
<listen type=”address” address=”SERVER_IP”/>
</graphics>
					
                    				
				 
			 
					
                
				Sep				25
                2021
				
					
					Dump
virsh dumpxml debian11 > test.xml
virt-xml-validate test.xml
					
                    				
				 
			 
					
                
				Jun				25
                2021
				
					
					Convert snapshot to standalone image
qemu-img convert -O qcow2 <snapshot.img> <new-image.img>
Create
virsh snapshot-create-as --domain debian11 --name debian11_snapshot01
List
virsh snapshot-create-as --domain debian11 --name debian11_snapshot01
Restore
virsh snapshot-revert debian11 debian11_snapshot01
Delete
virsh snapshot-delete --domain debian11 --snapshotname debian11_snapshot01
Info
virsh snapshot-info --domain debian11 --snapshotname debian11_snapshot01
					
                    				
				 
			 
					
                
				May				26
                2021
				
					
					sudo virsh detach-disk --domain test --persistent --live --target vdb
					
                    				
				 
			 
					
                
				May				12
                2021
				
					
					Create disk:
qemu-img create \
-f qcow2 \
-o lazy_refcounts=on,preallocation=falloc  \
$FILEPATH \
[size]G
qemu-img comes with various options for setting the allocation when creating new disk images.
preallocation=metadata – allocates the space required by the metadata but doesn’t allocate any space for the data. This is the quickest to provision but the slowest for guest writes.
preallocation=falloc – allocates space for the metadata and data but marks the blocks as unallocated. This will provision slower than metadata but quicker than full. Guest write performance will be much quicker than metadata and similar to full.
preallocation=full – allocates space for the metadata and data and will therefore consume all the physical space that you allocate (not sparse). All empty allocated space will be set as a zero. This is the slowest to provision and will give similar guest write performance to falloc.
Convert disk:
mv disk.qcow2 disk.qcow2.bak
qemu-img convert -O qcow2 -o lazy_refcounts=on,preallocation=falloc disk.qcow2.bak disk.qcow2
 
Attach disk:
virsh attach-disk [vm ID] \
--source /path/to/disk.qcow2 \
--target vd[x] \
--persistent \
--subdriver qcow2