systemd-initrd: autoFormat and autoResize in initrd
This commit is contained in:
parent
1abf154179
commit
213de9b108
3 changed files with 22 additions and 4 deletions
|
@ -108,8 +108,9 @@ let
|
|||
fileSystems = filter utils.fsNeededForBoot config.system.build.fileSystems;
|
||||
|
||||
fstab = pkgs.writeText "fstab" (lib.concatMapStringsSep "\n"
|
||||
({ fsType, mountPoint, device, options, ... }:
|
||||
"${device} /sysroot${mountPoint} ${fsType} ${lib.concatStringsSep "," options}") fileSystems);
|
||||
({ fsType, mountPoint, device, options, autoFormat, autoResize, ... }@fs: let
|
||||
opts = options ++ optional autoFormat "x-systemd.makefs" ++ optional autoResize "x-systemd.growfs";
|
||||
in "${device} /sysroot${mountPoint} ${fsType} ${lib.concatStringsSep "," opts}") fileSystems);
|
||||
|
||||
kernel-name = config.boot.kernelPackages.kernel.name or "kernel";
|
||||
modulesTree = config.system.modulesTree.override { name = kernel-name + "-modules"; };
|
||||
|
@ -294,7 +295,7 @@ in {
|
|||
config = mkIf (config.boot.initrd.enable && cfg.enable) {
|
||||
system.build = { inherit initialRamdisk; };
|
||||
boot.initrd.systemd = {
|
||||
initrdBin = [pkgs.bash pkgs.coreutils pkgs.kmod cfg.package];
|
||||
initrdBin = [pkgs.bash pkgs.coreutils pkgs.kmod cfg.package] ++ config.system.fsPackages;
|
||||
|
||||
objects = [
|
||||
{ object = "${cfg.package}/lib/systemd/systemd"; symlink = "/init"; }
|
||||
|
@ -357,6 +358,21 @@ in {
|
|||
// listToAttrs (map
|
||||
(v: let n = escapeSystemdPath v.where;
|
||||
in nameValuePair "${n}.automount" (automountToUnit n v)) cfg.automounts);
|
||||
|
||||
# The unit in /run/systemd/generator shadows the unit in
|
||||
# /etc/systemd/system, but will still apply drop-ins from
|
||||
# /etc/systemd/system/foo.service.d/
|
||||
#
|
||||
# We need IgnoreOnIsolate, otherwise the Requires dependency of
|
||||
# a mount unit on its makefs unit causes it to be unmounted when
|
||||
# we isolate for switch-root. Use a dummy package so that
|
||||
# generateUnits will generate drop-ins instead of unit files.
|
||||
packages = [(pkgs.runCommand "dummy" {} ''
|
||||
mkdir -p $out/etc/systemd/system
|
||||
touch $out/etc/systemd/system/systemd-{makefs,growfs}@.service
|
||||
'')];
|
||||
services."systemd-makefs@".unitConfig.IgnoreOnIsolate = true;
|
||||
services."systemd-growfs@".unitConfig.IgnoreOnIsolate = true;
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -323,7 +323,7 @@ in
|
|||
unitConfig.DefaultDependencies = false; # needed to prevent a cycle
|
||||
serviceConfig.Type = "oneshot";
|
||||
};
|
||||
in listToAttrs (map formatDevice (filter (fs: fs.autoFormat) fileSystems)) // {
|
||||
in listToAttrs (map formatDevice (filter (fs: fs.autoFormat && !(utils.fsNeededForBoot fs)) fileSystems)) // {
|
||||
# Mount /sys/fs/pstore for evacuating panic logs and crashdumps from persistent storage onto the disk using systemd-pstore.
|
||||
# This cannot be done with the other special filesystems because the pstore module (which creates the mount point) is not loaded then.
|
||||
"mount-pstore" = {
|
||||
|
|
|
@ -923,6 +923,8 @@ in
|
|||
mkVMOverride (cfg.fileSystems //
|
||||
{
|
||||
"/".device = cfg.bootDevice;
|
||||
"/".fsType = "ext4";
|
||||
"/".autoFormat = true;
|
||||
|
||||
"/tmp" = mkIf config.boot.tmpOnTmpfs
|
||||
{ device = "tmpfs";
|
||||
|
|
Loading…
Reference in a new issue