Autodetect swap partitions and mount them by startup script

Registered by Stefan Güls

The change to UUID based mounting made mounting of swap partitions in /etc/fstab quite fragile on systems which have more than one Linux OS installed. Furthermore a lot of free and commercial backup applications do not consider a swap partition to require an UUID and do not restore them correctly
(One could argue that this is a bug in these backup applications, but it is the real world situation that requires to deal with this behaviour).

As a consequence any installation of another OS which reformats the swap partitions or restoration of a complete harddisk image requires editing the /etc/fstab of any installed *buntu on that system, either correcting the UUID, or (in the case the swap partition did not even get a UUID) the replacement of UUID based entries with traditional /dev/ -style ones.

As many Live CD Distributions show, it seems no major problem to autodetect the presence of swap-partitions and use them for the Live CD session. So the suggestion is to keep swap partition entries out of /etc/fstab and use a separate startup script that detects swap partitions regardless of their /dev node or UUID and performs a swapon.

If autodetecion should slow the boot process too much, it would be possible to have a small cache file (outside of /etc/fstab) that memorizes the latest findings so the autodetection routine only needs to validate that cached settings, which are assumingly correct in the vast majority of cases.

Another possible solution could be the implementation of https://blueprints.launchpad.net/ubuntu/+spec/official-swap-file-support as an installer option, since on modern hardware the performance penalty on using a swap file probably will be negligible and would reduce overall system complexity.

Regarding the server edition this has to be an option which can be switched off.

Blueprint information

Status:
Not started
Approver:
None
Priority:
Undefined
Drafter:
Stefan Güls
Direction:
Needs approval
Assignee:
None
Definition:
New
Series goal:
None
Implementation:
Unknown
Milestone target:
None

Related branches

Sprints

Whiteboard

When looking for a solution, please also have a look at https://blueprints.launchpad.net/ubuntu/+spec/make-swap-optional/ . Having swap at all isn't as essential as it was years ago, so it would be a plausible solution not to require the installation of a swap partition at installation time, but only to detect eventual swap partitions at runtime.

That said, auto-detection is difficult, as there might be more than one OS on the same computer suspended and re-using a swap partition with another, suspended OS on it would result in data loss. --Traumflug

Could an installation UUID be added to the start of the swap partition used to mark a partition as being used for suspend/hibernate so only in the presence of a foreign identifier the swap is not used by another system? --Robert Arkenin

(?)

Work Items

This blueprint contains Public information 
Everyone can see this information.