- Delete any extraneous files, like package archives, cache, etc.
- Zero out the virtual disk:
- Use BleachBit with the 'Free disk space' option checked, or
- Pipe from /dev/zero to a file. (Be sure to delete it after!)
- Shut down the VM and pass the qcow2 file to the
shrink-vm
script.
- Switch the Video mode from 'QXL' to 'Virtio,' and be sure to check the 3D acceleration option.
- Switch the SPICE display server listen type to 'None', and check the OpenGL box.
- Enable
cgroup_device_acl
in /etc/livbirt/qemu.conf and add '/dev/dri/renderD128' to the list. Restartlibvirtd.service
afterwards.
To view available snapshots for a particular domain, run:
virsh -c qemu:///system snapshot-list --domain <DOMAIN_ID>
Delete any of the listed images by:
virsh -c qemu:///system snapshot-delete --domain <DOMAIN_ID> <SNAPSHOT_ID>
virsh -c qemu:///system undefine <DOMAIN_ID>
In the event that non-stock emulation of NVRAM, pass the --nvram
flag, too.
This is relevant for OSX-KVM.
virsh -c qemu:///system undefine --nvram <DOMAIN_ID>
To convert a VirtualBox image in OVA format to a QCOW2 image compatible with QEMU, run:
tar xf <input>
qemu-img convert -O qcow2 <input> <output>
To share the host directory <hostdir>
and mount it within a VM at the
directory <guestdir>
, do the following:
- From the Virt-Manager GUI, select the 'Show virtual hardware details' icon.
- In the 'Memory' section, check the 'Enable shared memory' box.
- Select 'Add Hardware' at the bottom of the UI.
- In the pop-up, select 'Filesystem.'
- Select the 'virtiofs' driver (the default).
- Enter the absolute path of
<hostdir>
in the 'Source path' text box. - Enter the target string (e.g.
share
) in 'Target path.' This value is not the<guestdir>
path. - Confirm the changes (i.e. click 'Finish') and boot the VM.
- From within the guest, run:
For clarity,
sudo mount -t virtiofs <share> <guestdir>
<share>
is the target string, and<guestdir>
is the absolute path for the mountpoint of the shared directory in the guest.
Additionally, create mount rules in /etc/fstab
to avoid having to manually
mount the shared filesystem at each boot. Add a rule as follows:
<share> <guestdir> virtiofs defaults 0 0