filesystems: add priority option for swap devices.

Useful for setting up raid0-like load balancing for swap.
By giving multiple swap devices the same prio.
This commit is contained in:
Mathijs Kwik 2013-05-13 23:42:55 +02:00
parent 085ccc8199
commit 4630ad4d26
2 changed files with 14 additions and 1 deletions

View File

@ -58,6 +58,17 @@ with utils;
'';
};
priority = mkOption {
default = null;
example = 2048;
type = types.nullOr types.int;
description = ''
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.
'';
};
};
config = {

View File

@ -7,6 +7,8 @@ let
fileSystems = attrValues config.fileSystems;
prioOption = prio: optionalString (prio !=null) " pri=${toString prio}";
fileSystemOpts = { name, ... }: {
options = {
@ -167,7 +169,7 @@ in
# Swap devices.
${flip concatMapStrings config.swapDevices (sw:
"${sw.device} none swap\n"
"${sw.device} none swap${prioOption sw.priority}\n"
)}
'';