Skip to content

Commit

Permalink
units: use /var/swapfile if found
Browse files Browse the repository at this point in the history
New unit to automatically make use of a swapfile if
it exists, not a symlink, and /var is writable.

Signed-off-by: Mark D Horn <mark.d.horn@intel.com>
  • Loading branch information
mdhorn authored and insilications committed Jun 9, 2021
1 parent b19f727 commit 13258ac
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
2 changes: 2 additions & 0 deletions units/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ units = [
['user.slice', ''],
['var-lib-machines.mount', 'ENABLE_MACHINED',
'remote-fs.target.wants/ machines.target.wants/'],
['var-swapfile.swap', '',
'swap.target.wants/'],
]

in_units = [
Expand Down
19 changes: 19 additions & 0 deletions units/var-swapfile.swap
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# SPDX-License-Identifier: LGPL-2.1+
#
# This file is part of systemd.
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation; either version 2.1 of the License, or
# (at your option) any later version.

[Unit]
Description=Default Swap File (/var/swapfile)
Documentation=man:systemd.swap(5)
ConditionPathExists=/var/swapfile
ConditionPathIsSymbolicLink=!/var/swapfile
ConditionPathIsReadWrite=/var/swapfile

[Swap]
What=/var/swapfile
Options=discard,fixpgsz

0 comments on commit 13258ac

Please sign in to comment.