* Upstart job to start swapping to the devices or files listed in the
swapDevices option. svn path=/nixos/trunk/; revision=7448
This commit is contained in:
parent
e060b99c52
commit
c78a1d9781
@ -14,7 +14,7 @@
|
||||
description = "
|
||||
Whether to find the root device automatically by searching for a
|
||||
device with the right label. If this option is off, then a root
|
||||
file system must be specified using <option>filesystems</option>.
|
||||
file system must be specified using <option>fileSystems</option>.
|
||||
";
|
||||
}
|
||||
|
||||
@ -141,7 +141,8 @@
|
||||
|
||||
|
||||
{
|
||||
name = ["filesystems"];
|
||||
name = ["fileSystems"];
|
||||
default = [];
|
||||
example = [
|
||||
{ mountPoint = "/";
|
||||
device = "/dev/hda1";
|
||||
@ -155,11 +156,12 @@
|
||||
];
|
||||
description = "
|
||||
The file systems to be mounted. It must include an entry for
|
||||
the root directory (<literal>mountPoint = \"/\"</literal>).
|
||||
Each entry in the list is an attribute set with the following
|
||||
fields: <literal>mountPoint</literal>,
|
||||
<literal>device</literal>, <literal>filesystem</literal> (a file
|
||||
system type recognised by <command>mount</command>; defaults to
|
||||
the root directory (<literal>mountPoint = \"/\"</literal>) if
|
||||
<literal>boot.autoDetectRootDevice</literal> is not set. Each
|
||||
entry in the list is an attribute set with the following fields:
|
||||
<literal>mountPoint</literal>, <literal>device</literal>,
|
||||
<literal>filesystem</literal> (a file system type recognised by
|
||||
<command>mount</command>; defaults to
|
||||
<literal>\"auto\"</literal>), <literal>autoMount</literal> (a
|
||||
boolean indicating whether the file system is mounted
|
||||
automatically; defaults to <literal>true</literal>) and
|
||||
@ -170,6 +172,17 @@
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
name = ["swapDevices"];
|
||||
default = [];
|
||||
example = ["/dev/hda7" "/dev/hdb3" "/var/swapfile"];
|
||||
description = "
|
||||
The swap devices and swap files. These must have been
|
||||
initialised using <command>mkswap</command>.
|
||||
";
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
name = ["services" "extraJobs"];
|
||||
default = [];
|
||||
|
@ -76,7 +76,7 @@ rec {
|
||||
rootDevice =
|
||||
(pkgs.library.findSingle (fs: fs.mountPoint == "/")
|
||||
(abort "No root mount point declared.")
|
||||
(config.get ["filesystems"])).device;
|
||||
(config.get ["fileSystems"])).device;
|
||||
rootLabel = config.get ["boot" "rootLabel"];
|
||||
inherit stage2Init;
|
||||
modulesDir = modulesClosure;
|
||||
|
@ -31,6 +31,12 @@ import ../upstart-jobs/gather.nix {
|
||||
inherit (pkgs) kernel module_init_tools;
|
||||
})
|
||||
|
||||
# Swapping.
|
||||
(import ../upstart-jobs/swap.nix {
|
||||
inherit (pkgs) utillinux;
|
||||
swapDevices = config.get ["swapDevices"];
|
||||
})
|
||||
|
||||
# Network interfaces.
|
||||
(import ../upstart-jobs/network-interfaces.nix {
|
||||
inherit (pkgs) nettools kernel module_init_tools;
|
||||
|
@ -5,11 +5,13 @@
|
||||
grubDevice = "/dev/hda";
|
||||
};
|
||||
|
||||
filesystems = [
|
||||
fileSystems = [
|
||||
{ mountPoint = "/";
|
||||
device = "/dev/hda1";
|
||||
}
|
||||
];
|
||||
|
||||
swapDevices = ["/dev/hdb1"];
|
||||
|
||||
services = {
|
||||
sshd = {
|
||||
|
29
upstart-jobs/swap.nix
Normal file
29
upstart-jobs/swap.nix
Normal file
@ -0,0 +1,29 @@
|
||||
{utillinux, swapDevices}:
|
||||
|
||||
{
|
||||
name = "swap";
|
||||
|
||||
job = "
|
||||
start on startup
|
||||
|
||||
script
|
||||
for device in ${toString swapDevices}; do
|
||||
# !!! Check whether we are already swapping to $device.
|
||||
${utillinux}/sbin/swapon \"$device\" || true
|
||||
done
|
||||
|
||||
# Remove swap devices not listed in swapDevices.
|
||||
for used in $(cat /proc/swaps | grep '^/' | sed 's/ .*//'); do
|
||||
found=
|
||||
for device in ${toString swapDevices}; do
|
||||
if test \"$used\" = \"$device\"; then found=1; fi
|
||||
done
|
||||
if test -z \"$found\"; then
|
||||
${utillinux}/sbin/swapoff \"$used\" || true
|
||||
fi
|
||||
done
|
||||
|
||||
end script
|
||||
";
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user