nixpkgs/modules/system/boot/stage-2.nix
Lluís Batlle i Rossell 33ed225a84 Making the /dev and /dev/shm tmpfs sizes configurable.
By default, they take the usual value of "50% of physical RAM".

As /dev/shm can be filled by anyone, and tmpfs does not trigger the OOM killer (and
can hang the machine due to a lack of RAM), I need to configure that down
in order to avoid crashes.

There is still left the /var/run/nscd tmpfs filesystem, also created with 50%
of the RAM, but at least not writeable by anyone. We could find a reasonable
low value for that, or allow configuration.


svn path=/nixos/trunk/; revision=21140
2010-04-17 15:20:13 +00:00

69 lines
1.5 KiB
Nix

{pkgs, config, ...}:
let
options = {
boot = {
postBootCommands = pkgs.lib.mkOption {
default = "";
example = "rm -f /var/log/messages";
merge = pkgs.lib.mergeStringOption;
description = ''
Shell commands to be executed just before Upstart is started.
'';
};
devSize = pkgs.lib.mkOption {
default = "50%";
example = "32m";
description = ''
Size limit for the /dev tmpfs. Look at mount(8), tmpfs size option,
for the accepted syntax.
'';
};
devShmSize = pkgs.lib.mkOption {
default = "50%";
example = "256m";
description = ''
Size limit for the /dev/shm tmpfs. Look at mount(8), tmpfs size option,
for the accepted syntax.
'';
};
};
};
inherit (pkgs) substituteAll writeText coreutils utillinux udev;
kernel = config.boot.kernelPackages.kernel;
activateConfiguration = config.system.activationScripts.script;
bootStage2 = substituteAll {
src = ./stage-2-init.sh;
isExecutable = true;
inherit kernel activateConfiguration;
inherit (config.boot) devSize devShmSize;
ttyGid = config.ids.gids.tty;
upstart = config.system.build.upstart;
path =
[ coreutils
utillinux
udev
];
postBootCommands = writeText "local-cmds"
''
${config.boot.postBootCommands}
${config.powerManagement.powerUpCommands}
'';
};
in
{
require = [options];
system.build.bootStage2 = bootStage2;
}