* 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 = "
|
description = "
|
||||||
Whether to find the root device automatically by searching for a
|
Whether to find the root device automatically by searching for a
|
||||||
device with the right label. If this option is off, then a root
|
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 = [
|
example = [
|
||||||
{ mountPoint = "/";
|
{ mountPoint = "/";
|
||||||
device = "/dev/hda1";
|
device = "/dev/hda1";
|
||||||
@ -155,11 +156,12 @@
|
|||||||
];
|
];
|
||||||
description = "
|
description = "
|
||||||
The file systems to be mounted. It must include an entry for
|
The file systems to be mounted. It must include an entry for
|
||||||
the root directory (<literal>mountPoint = \"/\"</literal>).
|
the root directory (<literal>mountPoint = \"/\"</literal>) if
|
||||||
Each entry in the list is an attribute set with the following
|
<literal>boot.autoDetectRootDevice</literal> is not set. Each
|
||||||
fields: <literal>mountPoint</literal>,
|
entry in the list is an attribute set with the following fields:
|
||||||
<literal>device</literal>, <literal>filesystem</literal> (a file
|
<literal>mountPoint</literal>, <literal>device</literal>,
|
||||||
system type recognised by <command>mount</command>; defaults to
|
<literal>filesystem</literal> (a file system type recognised by
|
||||||
|
<command>mount</command>; defaults to
|
||||||
<literal>\"auto\"</literal>), <literal>autoMount</literal> (a
|
<literal>\"auto\"</literal>), <literal>autoMount</literal> (a
|
||||||
boolean indicating whether the file system is mounted
|
boolean indicating whether the file system is mounted
|
||||||
automatically; defaults to <literal>true</literal>) and
|
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"];
|
name = ["services" "extraJobs"];
|
||||||
default = [];
|
default = [];
|
||||||
|
@ -76,7 +76,7 @@ rec {
|
|||||||
rootDevice =
|
rootDevice =
|
||||||
(pkgs.library.findSingle (fs: fs.mountPoint == "/")
|
(pkgs.library.findSingle (fs: fs.mountPoint == "/")
|
||||||
(abort "No root mount point declared.")
|
(abort "No root mount point declared.")
|
||||||
(config.get ["filesystems"])).device;
|
(config.get ["fileSystems"])).device;
|
||||||
rootLabel = config.get ["boot" "rootLabel"];
|
rootLabel = config.get ["boot" "rootLabel"];
|
||||||
inherit stage2Init;
|
inherit stage2Init;
|
||||||
modulesDir = modulesClosure;
|
modulesDir = modulesClosure;
|
||||||
|
@ -31,6 +31,12 @@ import ../upstart-jobs/gather.nix {
|
|||||||
inherit (pkgs) kernel module_init_tools;
|
inherit (pkgs) kernel module_init_tools;
|
||||||
})
|
})
|
||||||
|
|
||||||
|
# Swapping.
|
||||||
|
(import ../upstart-jobs/swap.nix {
|
||||||
|
inherit (pkgs) utillinux;
|
||||||
|
swapDevices = config.get ["swapDevices"];
|
||||||
|
})
|
||||||
|
|
||||||
# Network interfaces.
|
# Network interfaces.
|
||||||
(import ../upstart-jobs/network-interfaces.nix {
|
(import ../upstart-jobs/network-interfaces.nix {
|
||||||
inherit (pkgs) nettools kernel module_init_tools;
|
inherit (pkgs) nettools kernel module_init_tools;
|
||||||
|
@ -5,11 +5,13 @@
|
|||||||
grubDevice = "/dev/hda";
|
grubDevice = "/dev/hda";
|
||||||
};
|
};
|
||||||
|
|
||||||
filesystems = [
|
fileSystems = [
|
||||||
{ mountPoint = "/";
|
{ mountPoint = "/";
|
||||||
device = "/dev/hda1";
|
device = "/dev/hda1";
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
swapDevices = ["/dev/hdb1"];
|
||||||
|
|
||||||
services = {
|
services = {
|
||||||
sshd = {
|
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…
x
Reference in New Issue
Block a user