Bug 67431

Summary: RFE: swap: support calling 'mkswap' on uninitialized swap units
Product: systemd Reporter: Michał Górny <mgorny>
Component: generalAssignee: systemd-bugs
Status: RESOLVED FIXED QA Contact: systemd-bugs
Severity: enhancement    
Priority: medium CC: radek
Version: unspecified   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:

Description Michał Górny 2013-07-28 08:49:50 UTC
I'm using two zram devices for swap. By design, those devices are created at boot and are uninitialized.

It would be great if systemd had a simple 'Initialize=' boolean that would enable calling 'mkswap' to initialize the swap space. Preferably, with an fstab option to enable it transparently.
Comment 1 Tom Gundersen 2013-08-06 14:59:52 UTC
If we do this, we should make sure to first check that the swap partition does not contain a valid filesystem. This stuff could probably also be used for the encrypted swap stuff in our crypttab generator.
Comment 2 Lennart Poettering 2013-09-12 17:34:28 UTC
This is really dangerous business...
Comment 3 Radek Podgorny 2014-07-01 23:57:09 UTC
agreed, this could really destroy (potentially important) data.
Comment 4 Lennart Poettering 2018-08-08 15:30:47 UTC
We nowadays have this in place. Simply add "x-systemd.makefs" to your fstab mount options (or if you use a .swap unit directly pull in and order it after systemd-makefs@$DEVICE.service).

Closing hence.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.