swapDevices
Swapdevices
swapDevices
The swap devices and swap files. These must have been
initialised using {command}mkswap
. Each element
should be an attribute set specifying either the path of the
swap device or file (device
) or the label
of the swap device (label
, see
{command}mkswap -L
). Using a label is
recommended.
Type: list of (submodule)
Default
[ ]
Example
[{device = "/dev/hda7";}{device = "/var/swapfile";}{label = "bigswap";}]
Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/tasks/encrypted-devices.nix
swapDevices.*.device
Path of the device or swap file.
Type: non-empty string
Example
"/dev/sda3"
Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/config/swap.nix
swapDevices.*.discardPolicy
Specify the discard policy for the swap device. If "once", then the whole swap space is discarded at swapon invocation. If "pages", asynchronous discard on freed pages is performed, before returning to the available pages pool. With "both", both policies are activated. See swapon(8) for more information.
Type: null or one of "once", "pages", "both"
Default
null
Example
"once"
Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/config/swap.nix
swapDevices.*.encrypted.blkDev
Location of the backing encrypted device.
Type: null or string
Default
null
Example
"/dev/sda1"
Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/tasks/encrypted-devices.nix
swapDevices.*.encrypted.enable
The block device is backed by an encrypted one, adds this device as a initrd luks entry.
Type: boolean
Default
false
Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/tasks/encrypted-devices.nix
swapDevices.*.encrypted.keyFile
Path to a keyfile used to unlock the backing encrypted
device. When systemd stage 1 is not enabled, at the time
this keyfile is accessed, the neededForBoot
filesystems
(see utils.fsNeededForBoot
) will have been mounted under
/mnt-root
, so the keyfile path should usually start with
"/mnt-root/". When systemd stage 1 is enabled,
fsNeededForBoot
file systems will be mounted as needed
under /sysroot
, and the keyfile will not be accessed until
its requisite mounts are done.
Type: null or string
Default
null
Example
"/mnt-root/root/.swapkey"
Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/tasks/encrypted-devices.nix
swapDevices.*.encrypted.label
Label of the unlocked encrypted device. Set fileSystems.<name?>.device
to /dev/mapper/<label>
to mount the unlocked device.
Type: null or string
Default
null
Example
"rootfs"
Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/tasks/encrypted-devices.nix
swapDevices.*.label
Label of the device. Can be used instead of {var}device
.
Type: string
Example
"swap"
Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/config/swap.nix
swapDevices.*.options
Options used to mount the swap.
Type: list of non-empty string
Default
["defaults"]
Example
["nofail"]
Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/config/swap.nix
swapDevices.*.priority
Specify the priority of the swap device. Priority is a value between 0 and 32767. Higher numbers indicate higher priority. null lets the kernel choose a priority, which will show up as a negative value.
Type: null or signed integer
Default
null
Example
2048
Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/config/swap.nix
swapDevices.*.randomEncryption
Encrypt swap device with a random key. This way you won't have a persistent swap device.
HINT: run "cryptsetup benchmark" to test cipher performance on your machine.
WARNING: Don't try to hibernate when you have at least one swap partition with this option enabled! We have no way to set the partition into which hibernation image is saved, so if your image ends up on an encrypted one you would lose it!
WARNING #2: Do not use /dev/disk/by-uuid/… or /dev/disk/by-label/… as your swap device when using randomEncryption as the UUIDs and labels will get erased on every boot when the partition is encrypted. Best to use /dev/disk/by-partuuid/…
Type: (submodule) or boolean convertible to it
Default
false
Example
{cipher = "serpent-xts-plain64";enable = true;source = "/dev/random";}
Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/config/swap.nix
swapDevices.*.randomEncryption.allowDiscards
Whether to allow TRIM requests to the underlying device. This option has security implications; please read the LUKS documentation before activating it.
Type: boolean
Default
false
Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/config/swap.nix
swapDevices.*.randomEncryption.cipher
Use specified cipher for randomEncryption.
Hint: Run "cryptsetup benchmark" to see which one is fastest on your machine.
Type: string
Default
"aes-xts-plain64"
Example
"serpent-xts-plain64"
Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/config/swap.nix
swapDevices.*.randomEncryption.enable
Encrypt swap device with a random key. This way you won't have a persistent swap device.
WARNING: Don't try to hibernate when you have at least one swap partition with this option enabled! We have no way to set the partition into which hibernation image is saved, so if your image ends up on an encrypted one you would lose it!
WARNING #2: Do not use /dev/disk/by-uuid/… or /dev/disk/by-label/… as your swap device when using randomEncryption as the UUIDs and labels will get erased on every boot when the partition is encrypted. Best to use /dev/disk/by-partuuid/…
Type: boolean
Default
false
Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/config/swap.nix
swapDevices.*.randomEncryption.keySize
Set the encryption key size for the plain device.
If not specified, the amount of data to read from source
will be
determined by cryptsetup.
See cryptsetup-open(8)
for details.
Type: null or signed integer
Default
null
Example
"512"
Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/config/swap.nix
swapDevices.*.randomEncryption.sectorSize
Set the sector size for the plain encrypted device type.
If not specified, the default sector size is determined from the underlying block device.
See cryptsetup-open(8)
for details.
Type: null or signed integer
Default
null
Example
"4096"
Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/config/swap.nix
swapDevices.*.randomEncryption.source
Define the source of randomness to obtain a random key for encryption.
Type: string
Default
"/dev/urandom"
Example
"/dev/random"
Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/config/swap.nix
swapDevices.*.size
If this option is set, ‘device’ is interpreted as the path of a swapfile that will be created automatically with the indicated size (in megabytes).
Type: null or signed integer
Default
null
Example
2048
Declared by: https://github.com/nixos/nixpkgs/blob/master/nixos/modules/config/swap.nix