MNAIO: Move to using SCSI controller for TRIM support

When using file-backed storage, or SSD storage, any erasing
done in the VM does not actually clear up the space. By using
the virtio-scsi controller the VM is able to use TRIM to clear
any blocks which are deleted.

This also allows us to use fstrim to reduce the size of the
qemu files before we save them for later re-use.

Change-Id: Ia9001522ce054ee9f8a6dd38270da3e3fd039813
This commit is contained in:
Jesse Pretorius 2018-08-23 13:20:25 +01:00
parent c556bea0d7
commit f3575be76a
7 changed files with 17 additions and 13 deletions

View File

@ -40,16 +40,20 @@
<source dev='/dev/{{ default_vm_disk_vg }}/{{ hostvars[item]["server_hostname"] }}'/> <source dev='/dev/{{ default_vm_disk_vg }}/{{ hostvars[item]["server_hostname"] }}'/>
{% elif default_vm_disk_mode == "file" %} {% elif default_vm_disk_mode == "file" %}
<disk type='file' device='disk'> <disk type='file' device='disk'>
<driver name='qemu' type='qcow2' cache='none' io='native'/> <driver name='qemu' type='qcow2' discard='unmap' cache='none' io='native'/>
<source file='{{ _virt_pools.pools.default.path | default('/data/images') }}/{{ hostvars[item]["server_hostname"] }}.img'/> <source file='{{ _virt_pools.pools.default.path | default('/data/images') }}/{{ hostvars[item]["server_hostname"] }}.img'/>
{% endif %} {% endif %}
<target dev='vda' bus='virtio'/> <target dev='sda' bus='scsi'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x09' function='0x0'/> <alias name='scsi0-0-0-0'/>
<address type='drive' controller='0' bus='0' target='0' unit='0'/>
<boot order='1'/> <boot order='1'/>
</disk> </disk>
<controller type='pci' index='0' model='pci-root'> <controller type='pci' index='0' model='pci-root'>
<alias name='pci.0'/> <alias name='pci.0'/>
</controller> </controller>
<controller type='scsi' index='0' model='virtio-scsi'>
<address type='pci' domain='0x0000' bus='0x00' slot='0x08' function='0x0'/>
</controller>
<controller type='virtio-serial' index='0'> <controller type='virtio-serial' index='0'>
<alias name='virtio-serial0'/> <alias name='virtio-serial0'/>
<address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/> <address type='pci' domain='0x0000' bus='0x00' slot='0x0a' function='0x0'/>

View File

@ -30,7 +30,7 @@ d-i netcfg/wireless_wep string
# Pre Install # Pre Install
# Command Line 1: This is necessary otherwise you will be prompted to umount /dev/vda. See Ubuntu bug #1347726. # Command Line 1: This is necessary otherwise you will be prompted to umount /dev/sda. See Ubuntu bug #1347726.
d-i preseed/early_command string \ d-i preseed/early_command string \
umount /media || true umount /media || true

View File

@ -30,7 +30,7 @@ d-i netcfg/wireless_wep string
# Pre Install # Pre Install
# Command Line 1: This is necessary otherwise you will be prompted to umount /dev/vda. See Ubuntu bug #1347726. # Command Line 1: This is necessary otherwise you will be prompted to umount /dev/sda. See Ubuntu bug #1347726.
d-i preseed/early_command string \ d-i preseed/early_command string \
umount /media || true umount /media || true

View File

@ -30,7 +30,7 @@ d-i netcfg/wireless_wep string
# Pre Install # Pre Install
# Command Line 1: This is necessary otherwise you will be prompted to umount /dev/vda. See Ubuntu bug #1347726. # Command Line 1: This is necessary otherwise you will be prompted to umount /dev/sda. See Ubuntu bug #1347726.
d-i preseed/early_command string \ d-i preseed/early_command string \
umount /media || true umount /media || true
@ -90,7 +90,7 @@ d-i partman-lvm/confirm boolean true
d-i partman-lvm/confirm_nooverwrite boolean true d-i partman-lvm/confirm_nooverwrite boolean true
d-i partman-auto/method string lvm d-i partman-auto/method string lvm
d-i partman-auto/disk string /dev/vda d-i partman-auto/disk string /dev/sda
# For LVM partitioning, you can select how much of the volume group to use # For LVM partitioning, you can select how much of the volume group to use
# for logical volumes. # for logical volumes.
@ -111,7 +111,7 @@ d-i partman-auto/expert_recipe string \
1024 1 100% ext4 \ 1024 1 100% ext4 \
$primary{ } \ $primary{ } \
method{ lvm } \ method{ lvm } \
device{ /dev/vda2 } \ device{ /dev/sda2 } \
vg_name{ vmvg00 } \ vg_name{ vmvg00 } \
. \ . \
2048 1 4096 linux-swap \ 2048 1 4096 linux-swap \

View File

@ -30,7 +30,7 @@ d-i netcfg/wireless_wep string
# Pre Install # Pre Install
# Command Line 1: This is necessary otherwise you will be prompted to umount /dev/vda. See Ubuntu bug #1347726. # Command Line 1: This is necessary otherwise you will be prompted to umount /dev/sda. See Ubuntu bug #1347726.
d-i preseed/early_command string \ d-i preseed/early_command string \
umount /media || true umount /media || true
@ -90,7 +90,7 @@ d-i partman-lvm/confirm boolean true
d-i partman-lvm/confirm_nooverwrite boolean true d-i partman-lvm/confirm_nooverwrite boolean true
d-i partman-auto/method string lvm d-i partman-auto/method string lvm
d-i partman-auto/disk string /dev/vda d-i partman-auto/disk string /dev/sda
# For LVM partitioning, you can select how much of the volume group to use # For LVM partitioning, you can select how much of the volume group to use
# for logical volumes. # for logical volumes.
@ -111,7 +111,7 @@ d-i partman-auto/expert_recipe string \
1024 1 100% ext4 \ 1024 1 100% ext4 \
$primary{ } \ $primary{ } \
method{ lvm } \ method{ lvm } \
device{ /dev/vda2 } \ device{ /dev/sda2 } \
vg_name{ vmvg00 } \ vg_name{ vmvg00 } \
. \ . \
2048 1 4096 linux-swap \ 2048 1 4096 linux-swap \

View File

@ -9,7 +9,7 @@ selinux --disabled
firewall --disabled firewall --disabled
services --enabled=NetworkManager,sshd services --enabled=NetworkManager,sshd
eula --agreed eula --agreed
ignoredisk --only-use=vda ignoredisk --only-use=sda
reboot reboot
bootloader --location=mbr bootloader --location=mbr

View File

@ -9,7 +9,7 @@ selinux --disabled
firewall --disabled firewall --disabled
services --enabled=NetworkManager,sshd services --enabled=NetworkManager,sshd
eula --agreed eula --agreed
ignoredisk --only-use=vda ignoredisk --only-use=sda
reboot reboot
bootloader --location=mbr bootloader --location=mbr