diff --git a/configuration/upstart.nix b/configuration/upstart.nix index f0870159ead..4065a030593 100644 --- a/configuration/upstart.nix +++ b/configuration/upstart.nix @@ -33,7 +33,7 @@ import ../upstart-jobs/gather.nix { # Mount file systems. (import ../upstart-jobs/filesystems.nix { - inherit (pkgs) utillinux; + inherit (pkgs) utillinux e2fsprogs; fileSystems = config.get ["fileSystems"]; }) diff --git a/upstart-jobs/filesystems.nix b/upstart-jobs/filesystems.nix index 6dcb8b3f2cf..c001bf14d8d 100644 --- a/upstart-jobs/filesystems.nix +++ b/upstart-jobs/filesystems.nix @@ -1,4 +1,4 @@ -{utillinux, fileSystems}: +{utillinux, e2fsprogs, fileSystems}: let @@ -18,6 +18,8 @@ start on startup start on new-devices script + PATH=${e2fsprogs}/sbin:$PATH + mountPoints=(${toString mountPoints}) devices=(${toString devices}) fsTypes=(${toString fsTypes}) @@ -39,6 +41,11 @@ script fsType=\${fsTypes[$n]} options=\${optionss[$n]} + if ! test -e \"$device\"; then + echo \"skipping $device, doesn't exist (yet)\" + continue + fi + # If $device is already mounted somewhere else, unmount it first. # !!! Note: we use /etc/mtab, not /proc/mounts, because mtab # contains more accurate info when using loop devices. @@ -63,6 +70,9 @@ script echo \"mounting $device on $mountPoint\" + # !!! should do something with the result; also prevent repeated fscks. + fsck -a \"$device\" || true + if ${utillinux}/bin/mount -t \"$fsType\" -o \"$options\" \"$device\" \"$mountPoint\"; then newDevices=1 fi