[fstab] Configure tmp on tmpfs
Adds a new option / configuration keys to `fstab.conf` to configure how /tmp is created. The example shows how /tmp is made *tmpfs* on an SSD, or on not-SSD, is just-a-directory. FIXES #1818
This commit is contained in:
parent
4e5078c950
commit
63ee982d36
@ -61,3 +61,26 @@ ssdExtraMountOptions:
|
|||||||
crypttabOptions: luks
|
crypttabOptions: luks
|
||||||
# For Debian and Debian-based distributions, change the above line to:
|
# For Debian and Debian-based distributions, change the above line to:
|
||||||
# crypttabOptions: luks,keyscript=/bin/cat
|
# crypttabOptions: luks,keyscript=/bin/cat
|
||||||
|
|
||||||
|
# Options for handling /tmp in /etc/fstab
|
||||||
|
# Currently default (required) and ssd are supported
|
||||||
|
# The corresponding string can contain the following variables:
|
||||||
|
# tmpfs: true or tmpfs: false to either mount /tmp as tmpfs or not
|
||||||
|
# options: "<mount options>"
|
||||||
|
#
|
||||||
|
# Example:
|
||||||
|
#tmpOptions:
|
||||||
|
# default:
|
||||||
|
# tmpfs: false
|
||||||
|
# options: ""
|
||||||
|
# ssd:
|
||||||
|
# tmpfs: true
|
||||||
|
# options: "defaults,noatime,mode=1777"
|
||||||
|
#
|
||||||
|
tmpOptions:
|
||||||
|
default:
|
||||||
|
tmpfs: false
|
||||||
|
options: ""
|
||||||
|
ssd:
|
||||||
|
tmpfs: true
|
||||||
|
options: "defaults,noatime,mode=1777"
|
||||||
|
@ -25,4 +25,22 @@ properties:
|
|||||||
btrfs_swap: { type: string }
|
btrfs_swap: { type: string }
|
||||||
efiMountOptions: { type: string }
|
efiMountOptions: { type: string }
|
||||||
crypttabOptions: { type: string }
|
crypttabOptions: { type: string }
|
||||||
required: [ mountOptions ]
|
tmpOptions:
|
||||||
|
type: object
|
||||||
|
additionalProperties: false
|
||||||
|
properties:
|
||||||
|
default:
|
||||||
|
type: object
|
||||||
|
additionalProperties: false
|
||||||
|
properties:
|
||||||
|
tmpfs: { type: bool }
|
||||||
|
options: { type: string }
|
||||||
|
ssd:
|
||||||
|
type: object
|
||||||
|
additionalProperties: false
|
||||||
|
properties:
|
||||||
|
tmpfs: { type: bool }
|
||||||
|
options: { type: string }
|
||||||
|
required:
|
||||||
|
- mountOptions
|
||||||
|
- tmpOptions: default
|
||||||
|
@ -106,14 +106,17 @@ class FstabGenerator(object):
|
|||||||
:param root_mount_point:
|
:param root_mount_point:
|
||||||
:param mount_options:
|
:param mount_options:
|
||||||
:param ssd_extra_mount_options:
|
:param ssd_extra_mount_options:
|
||||||
|
:param crypttab_options:
|
||||||
|
:param tmp_options:
|
||||||
"""
|
"""
|
||||||
def __init__(self, partitions, root_mount_point, mount_options,
|
def __init__(self, partitions, root_mount_point, mount_options,
|
||||||
ssd_extra_mount_options, crypttab_options):
|
ssd_extra_mount_options, crypttab_options, tmp_options):
|
||||||
self.partitions = partitions
|
self.partitions = partitions
|
||||||
self.root_mount_point = root_mount_point
|
self.root_mount_point = root_mount_point
|
||||||
self.mount_options = mount_options
|
self.mount_options = mount_options
|
||||||
self.ssd_extra_mount_options = ssd_extra_mount_options
|
self.ssd_extra_mount_options = ssd_extra_mount_options
|
||||||
self.crypttab_options = crypttab_options
|
self.crypttab_options = crypttab_options
|
||||||
|
self.tmp_options = tmp_options
|
||||||
self.ssd_disks = set()
|
self.ssd_disks = set()
|
||||||
self.root_is_ssd = False
|
self.root_is_ssd = False
|
||||||
|
|
||||||
@ -214,21 +217,32 @@ class FstabGenerator(object):
|
|||||||
mount_entry["subvol"] = s["subvolume"]
|
mount_entry["subvol"] = s["subvolume"]
|
||||||
dct = self.generate_fstab_line_info(mount_entry)
|
dct = self.generate_fstab_line_info(mount_entry)
|
||||||
if dct:
|
if dct:
|
||||||
self.print_fstab_line(dct, file=fstab_file)
|
self.print_fstab_line(dct, file=fstab_file)
|
||||||
elif partition["fs"] != "zfs": # zfs partitions don't need an entry in fstab
|
elif partition["fs"] != "zfs": # zfs partitions don't need an entry in fstab
|
||||||
dct = self.generate_fstab_line_info(partition)
|
dct = self.generate_fstab_line_info(partition)
|
||||||
if dct:
|
if dct:
|
||||||
self.print_fstab_line(dct, file=fstab_file)
|
self.print_fstab_line(dct, file=fstab_file)
|
||||||
|
|
||||||
if self.root_is_ssd:
|
if self.root_is_ssd:
|
||||||
# Mount /tmp on a tmpfs
|
# Old behavior was to mount /tmp as tmpfs
|
||||||
dct = dict(device="tmpfs",
|
# New behavior is to use tmpOptions to decide
|
||||||
mount_point="/tmp",
|
# if mounting /tmp as tmpfs and which options to use
|
||||||
fs="tmpfs",
|
ssd = self.tmp_options.get("ssd", {})
|
||||||
options="defaults,noatime,mode=1777",
|
if not ssd:
|
||||||
check=0,
|
ssd = self.tmp_options.get("default", {})
|
||||||
)
|
# Default to True to mimic old behavior
|
||||||
self.print_fstab_line(dct, file=fstab_file)
|
tmpfs = ssd.get("tmpfs", True)
|
||||||
|
|
||||||
|
if tmpfs:
|
||||||
|
options = ssd.get("options", "defaults,noatime,mode=1777")
|
||||||
|
# Mount /tmp on a tmpfs
|
||||||
|
dct = dict(device="tmpfs",
|
||||||
|
mount_point="/tmp",
|
||||||
|
fs="tmpfs",
|
||||||
|
options=options,
|
||||||
|
check=0,
|
||||||
|
)
|
||||||
|
self.print_fstab_line(dct, file=fstab_file)
|
||||||
|
|
||||||
def generate_fstab_line_info(self, partition):
|
def generate_fstab_line_info(self, partition):
|
||||||
"""
|
"""
|
||||||
@ -411,6 +425,7 @@ def run():
|
|||||||
mount_options = conf.get("mountOptions", {})
|
mount_options = conf.get("mountOptions", {})
|
||||||
ssd_extra_mount_options = conf.get("ssdExtraMountOptions", {})
|
ssd_extra_mount_options = conf.get("ssdExtraMountOptions", {})
|
||||||
crypttab_options = conf.get("crypttabOptions", "luks")
|
crypttab_options = conf.get("crypttabOptions", "luks")
|
||||||
|
tmp_options = conf.get("tmpOptions", {})
|
||||||
|
|
||||||
# We rely on mount_options having a default; if there wasn't one,
|
# We rely on mount_options having a default; if there wasn't one,
|
||||||
# bail out with a meaningful error.
|
# bail out with a meaningful error.
|
||||||
@ -423,7 +438,8 @@ def run():
|
|||||||
root_mount_point,
|
root_mount_point,
|
||||||
mount_options,
|
mount_options,
|
||||||
ssd_extra_mount_options,
|
ssd_extra_mount_options,
|
||||||
crypttab_options)
|
crypttab_options,
|
||||||
|
tmp_options)
|
||||||
|
|
||||||
if swap_choice is not None:
|
if swap_choice is not None:
|
||||||
libcalamares.job.setprogress(0.2)
|
libcalamares.job.setprogress(0.2)
|
||||||
|
Loading…
Reference in New Issue
Block a user