anaconda: enable discard option for dom0 filesystems by default

This may have performance impact on some older SSD, but on the other
hand, without this option it's pretty easy to fill the whole LVM thin
pool even if there is plenty free space in dom0.
Note that this doesn't enable it on LUKS layer, this is still disabled
by default.

Fixes QubesOS/qubes-issues#3226
This commit is contained in:
Marek Marczykowski-Górecki 2018-03-20 22:29:18 +01:00
parent 38fdf4bbe3
commit f466747949
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724
2 changed files with 23 additions and 0 deletions

View File

@ -211,6 +211,17 @@ def doInstall(storage, payload, ksdata, instClass):
wait_for_entropy=entropy_wait_clbk)
turn_on_filesystems(storage, mount_only=flags.flags.dirInstall, callbacks=callbacks_reg)
# For autopart, actual partition related objects (especially
# blivet.format.FS objects) are created by the above call. And autopart
# does not provide any way to specify default mount options (unlike manual
# partitioning). Because of this, patch it now to add 'discard' option.
if storage.root_device.format.options and \
'discard' not in storage.root_device.format.options:
storage.root_device.format.options += ',discard'
else:
storage.root_device.format.options = 'defaults,discard'
payload.writeStorageEarly()
# Run %pre-install scripts with the filesystem mounted and no packages

View File

@ -885,6 +885,10 @@ class LogVolData(commands.logvol.F23_LogVolData):
self.mountpoint = ""
ty = None
if self.mountpoint.startswith('/') and not self.fsopts:
# enable discard for normal filesystems in dom0
self.fsopts = "defaults,discard"
# Sanity check mountpoint
if self.mountpoint != "" and self.mountpoint[0] != '/':
raise KickstartParseError(formatErrorMsg(self.lineno,
@ -1245,6 +1249,10 @@ class PartitionData(commands.partition.F23_PartData):
else:
ty = storage.default_fstype
if self.mountpoint.startswith('/') and not self.fsopts:
# enable discard for normal filesystems in dom0
self.fsopts = "defaults,discard"
if not size and self.size:
try:
size = Size("%d MiB" % self.size)
@ -1490,6 +1498,10 @@ class RaidData(commands.raid.F25_RaidData):
else:
ty = storage.default_fstype
if self.mountpoint.startswith('/') and not self.fsopts:
# enable discard for normal filesystems in dom0
self.fsopts = "defaults,discard"
# Sanity check mountpoint
if self.mountpoint != "" and self.mountpoint[0] != '/':
raise KickstartParseError(formatErrorMsg(self.lineno,