Defaults: Switch default disk from virtio-blk-pci to virtio-scsi-pci

Currently, the virtio specification does not include provision for the TRIM (aka DISCARD) command that allows a guest operating system to signal the disk hardware that blocks have become unused so that the underlying device may clear the physical data.

The TRIM/DISCARD command was introduced for SSD disks as an extension to the AHCI specification that is used in SATA systems.

With Virtual Machines we can use this command to tell QEMU's Qcow2 driver to reclaim unused space in the disk image. This ensures the disk image file is kept to the smallest size possible where without the TRIM/DISCARD command it grows to it's maximum configured size and never shrinks again when data is deleted.

Let's swap our default disk driver from `virtio-blk-pci` which does not support TRIM to `virtio-scsi-pci` which does.
This commit is contained in:
Dani Llewellyn 2022-10-17 20:22:46 +01:00 committed by Martin Wimpress
parent bfd7a05ff1
commit fb8deb10e8
1 changed files with 3 additions and 2 deletions

View File

@ -1103,8 +1103,9 @@ function vm_boot() {
else
# shellcheck disable=SC2054,SC2206
args+=(-device virtio-blk-pci,drive=SystemDisk
-drive id=SystemDisk,if=none,format=qcow2,file="${disk_img}" ${STATUS_QUO})
args+=(-device virtio-scsi-pci,id=scsi0
-device scsi-hd,drive=SystemDisk,bus=scsi0.0,lun=0,rotation_rate=1
-drive id=SystemDisk,if=none,format=qcow2,discard=unmap,file="${disk_img}" ${STATUS_QUO})
fi
# https://wiki.qemu.org/Documentation/9psetup