MNAIO: Use discard option for all mount points

Using the discard option for all mount points ensures
that the deletes actually release the blocks on the disk.
This ensures that SSD performance is optimised and that
file-backed images are kept as small as possible.

Change-Id: I648cbaca56d75e355cf6c8af01e2e3ad20dfc398
This commit is contained in:
Jesse Pretorius 2018-08-23 14:59:06 +01:00
parent f3575be76a
commit 42189e272f
3 changed files with 20 additions and 6 deletions

View File

@ -315,6 +315,7 @@
src: /dev/mapper/vmvg00-machines00 src: /dev/mapper/vmvg00-machines00
state: mounted state: mounted
fstype: btrfs fstype: btrfs
opts: defaults,discard
- name: Setup cinder host volume - name: Setup cinder host volume
@ -381,6 +382,7 @@
src: "/dev/mapper/vmvg00-{{ item }}" src: "/dev/mapper/vmvg00-{{ item }}"
fstype: xfs fstype: xfs
state: mounted state: mounted
opts: defaults,discard
with_items: with_items:
- disk1 - disk1
- disk2 - disk2

View File

@ -107,6 +107,8 @@ d-i partman-auto/expert_recipe string \
use_filesystem{ } filesystem{ ext2 } \ use_filesystem{ } filesystem{ ext2 } \
label{ boot } \ label{ boot } \
mountpoint{ /boot } \ mountpoint{ /boot } \
options/defaults{ defaults } \
options/discard{ discard } \
. \ . \
1024 1 100% ext4 \ 1024 1 100% ext4 \
$primary{ } \ $primary{ } \
@ -126,6 +128,8 @@ d-i partman-auto/expert_recipe string \
use_filesystem{ } filesystem{ ext4 } \ use_filesystem{ } filesystem{ ext4 } \
label{ root } \ label{ root } \
mountpoint{ / } \ mountpoint{ / } \
options/defaults{ defaults } \
options/discard{ discard } \
. \ . \
16384 1 16384 ext4 \ 16384 1 16384 ext4 \
$lvmok{ } in_vg{ vmvg00 } \ $lvmok{ } in_vg{ vmvg00 } \
@ -134,6 +138,8 @@ d-i partman-auto/expert_recipe string \
use_filesystem{ } filesystem{ ext4 } \ use_filesystem{ } filesystem{ ext4 } \
label{ openstack } \ label{ openstack } \
mountpoint{ /openstack } \ mountpoint{ /openstack } \
options/defaults{ defaults } \
options/discard{ discard } \
. \ . \
{% if default_container_tech == 'nspawn' %} {% if default_container_tech == 'nspawn' %}
8192 1 24576 btrfs \ 8192 1 24576 btrfs \
@ -143,6 +149,8 @@ d-i partman-auto/expert_recipe string \
use_filesystem{ } filesystem{ btrfs } \ use_filesystem{ } filesystem{ btrfs } \
label{ machines } \ label{ machines } \
mountpoint{ /var/lib/machines } \ mountpoint{ /var/lib/machines } \
options/defaults{ defaults } \
options/discard{ discard } \
. \ . \
{% elif default_container_tech == 'lxc' %} {% elif default_container_tech == 'lxc' %}
4096 1 8192 btrfs \ 4096 1 8192 btrfs \
@ -152,6 +160,8 @@ d-i partman-auto/expert_recipe string \
use_filesystem{ } filesystem{ btrfs } \ use_filesystem{ } filesystem{ btrfs } \
label{ machines } \ label{ machines } \
mountpoint{ /var/lib/machines } \ mountpoint{ /var/lib/machines } \
options/defaults{ defaults } \
options/discard{ discard } \
. \ . \
8192 1 10240000 ext4 \ 8192 1 10240000 ext4 \
$lvmok{ } in_vg{ vmvg00 } \ $lvmok{ } in_vg{ vmvg00 } \
@ -160,6 +170,8 @@ d-i partman-auto/expert_recipe string \
use_filesystem{ } filesystem{ ext4 } \ use_filesystem{ } filesystem{ ext4 } \
label{ lxc } \ label{ lxc } \
mountpoint{ /var/lib/lxc } \ mountpoint{ /var/lib/lxc } \
options/defaults{ defaults } \
options/discard{ discard } \
. \ . \
{% endif %} {% endif %}

View File

@ -18,14 +18,14 @@ clearpart --all --initlabel
part /boot --fstype ext3 --size=512 part /boot --fstype ext3 --size=512
part pv.01 --size=1 --grow part pv.01 --size=1 --grow
volgroup vmvg00 pv.01 volgroup vmvg00 pv.01
logvol / --fstype ext4 --name=root00 --vgname=vmvg00 --size=8192 logvol / --fstype ext4 --name=root00 --vgname=vmvg00 --size=8192 --fsoptions=defaults,discard
logvol swap --fstype swap --name=swap00 --vgname=vmvg00 --size=2048 logvol swap --fstype swap --name=swap00 --vgname=vmvg00 --size=2048
logvol /openstack --fstype ext4 --name=openstack00 --vgname=vmvg00 --size=16384 logvol /openstack --fstype ext4 --name=openstack00 --vgname=vmvg00 --size=16384 --fsoptions=defaults,discard
{% if default_container_tech == 'nspawn' %} {% if default_container_tech == 'nspawn' %}
logvol /var/lib/machines --fstype ext4 --name=machines00 --vgname=vmvg00 --size=8192 --grow logvol /var/lib/machines --fstype ext4 --name=machines00 --vgname=vmvg00 --size=8192 --grow --fsoptions=defaults,discard
{% elif default_container_tech == 'lxc' %} {% elif default_container_tech == 'lxc' %}
logvol /var/lib/machines --fstype ext4 --name=machines00 --vgname=vmvg00 --size=4096 logvol /var/lib/machines --fstype ext4 --name=machines00 --vgname=vmvg00 --size=4096 --fsoptions=defaults,discard
logvol /var/lib/lxc --fstype ext4 --name=lxc00 --vgname=vmvg00 --size=8192 --grow logvol /var/lib/lxc --fstype ext4 --name=lxc00 --vgname=vmvg00 --size=8192 --grow --fsoptions=defaults,discard
{% endif %} {% endif %}
rootpw secrete rootpw secrete
repo --name=base --baseurl={{ images[default_vm_image]['image_repo_base_url'] }}/os/x86_64/ repo --name=base --baseurl={{ images[default_vm_image]['image_repo_base_url'] }}/os/x86_64/
@ -67,7 +67,7 @@ modprobe btrfs
umount /dev/vmvg00/machines00 umount /dev/vmvg00/machines00
btrfs-convert /dev/vmvg00/machines00 btrfs-convert /dev/vmvg00/machines00
sed -i '/vmvg00-machines00/d' /etc/fstab sed -i '/vmvg00-machines00/d' /etc/fstab
echo "/dev/mapper/vmvg00-machines00 /var/lib/machines btrfs defaults 1 2" >> /etc/fstab echo "/dev/mapper/vmvg00-machines00 /var/lib/machines btrfs defaults,discard 1 2" >> /etc/fstab
wget --no-proxy http://{{ tftp_server }}/scripts/vm-post-install-redhat-script.sh -O /opt/vm-post-install-script.sh wget --no-proxy http://{{ tftp_server }}/scripts/vm-post-install-redhat-script.sh -O /opt/vm-post-install-script.sh
chmod +x /opt/vm-post-install-script.sh chmod +x /opt/vm-post-install-script.sh