* Modularize filesystem support. Filesystems such as btrfs and

reiserfs now have separate modules that are conditional on
  boot.supportedFilesystems and boot.initrd.supportedFilesystems.
  By default, these include the filesystems specified in the fsType
  attribute in fileSystems.  Ext2/3/4 support is currently
  unconditional.

  Also unbreak the installer test (http://hydra.nixos.org/build/2272302). 

svn path=/nixos/trunk/; revision=32954
wip/yesman
Eelco Dolstra 12 years ago
parent 8708578181
commit 03ebb883d1
  1. 1
      modules/config/system-path.nix
  2. 5
      modules/module-list.nix
  3. 5
      modules/profiles/base.nix
  4. 4
      modules/services/misc/autofs.nix
  5. 2
      modules/services/network-filesystems/nfs-kernel.nix
  6. 3
      modules/system/boot/kernel.nix
  7. 19
      modules/system/boot/stage-1.nix
  8. 98
      modules/tasks/filesystems.nix
  9. 38
      modules/tasks/filesystems/btrfs.nix
  10. 22
      modules/tasks/filesystems/ext.nix
  11. 25
      modules/tasks/filesystems/nfs.nix
  12. 25
      modules/tasks/filesystems/reiserfs.nix

@ -17,7 +17,6 @@ let
requiredPackages =
[ config.system.sbin.modprobe # must take precedence over module_init_tools
config.system.sbin.mount # must take precedence over util-linux
config.system.build.upstart
config.environment.nix
pkgs.acl

@ -114,6 +114,7 @@
./services/networking/cntlm.nix
./services/networking/ddclient.nix
./services/networking/dhclient.nix
#./services/networking/dhcpcd.nix
./services/networking/dhcpd.nix
./services/networking/dnsmasq.nix
./services/networking/ejabberd.nix
@ -198,6 +199,10 @@
./system/upstart/upstart.nix
./tasks/cpu-freq.nix
./tasks/filesystems.nix
./tasks/filesystems/btrfs.nix
./tasks/filesystems/ext.nix
./tasks/filesystems/nfs.nix
./tasks/filesystems/reiserfs.nix
./tasks/kbd.nix
./tasks/lvm.nix
./tasks/network-interfaces.nix

@ -31,7 +31,6 @@
# Tools to create / manipulate filesystems.
pkgs.ntfsprogs # for resizing NTFS partitions
pkgs.btrfsProgs
pkgs.dosfstools
pkgs.xfsprogs
pkgs.jfsutils
@ -50,4 +49,8 @@
pkgs.bvi # binary editor
pkgs.joe
];
# Include support for various filesystems.
boot.supportedFilesystems = [ "btrfs" "reiserfs" ];
}

@ -6,8 +6,6 @@ let
cfg = config.services.autofs;
mount = config.system.sbin.mount;
autoMaster = pkgs.writeText "auto.master" cfg.autoMaster;
in
@ -114,7 +112,7 @@ in
unescapeSpaces(){ sed 's/\\040/ /g'; }
sed -n 's@^\s*\(\([^\\ ]\|\\ \)*\)\s.*@\1@p' ${autoMaster} | sed 's/[\\]//' | while read mountPoint; do
sed -n "s@[^ ]\+\s\+\($(echo "$mountPoint"| escapeSpaces)[^ ]*\).*@\1@p" /proc/mounts | sort -r | unescapeSpaces| while read smountP; do
${mount}/bin/umount -l "$smountP" || true
${pkgs.utillinux}/bin/umount -l "$smountP" || true
done
done
'';

@ -151,7 +151,7 @@ in
${config.system.sbin.modprobe}/sbin/modprobe nfsd || true
${pkgs.sysvtools}/bin/mountpoint -q /proc/fs/nfsd \
|| ${config.system.sbin.mount}/bin/mount -t nfsd none /proc/fs/nfsd
|| ${pkgs.utillinux}/bin/mount -t nfsd none /proc/fs/nfsd
${optionalString cfg.server.createMountPoints
''

@ -148,9 +148,6 @@ let kernel = config.boot.kernelPackages.kernel; in
"ide_disk"
"ide_generic"
# Filesystems.
"ext2" "ext3" "ext4"
# Support USB keyboards, in case the boot fails and we only have
# a USB keyboard.
"uhci_hcd"

@ -153,17 +153,6 @@ let
cp -v ${pkgs.coreutils}/bin/sleep $out/bin
cp -v ${pkgs.coreutils}/bin/ln $out/bin
# Copy e2fsck and friends.
cp -v ${pkgs.e2fsprogs}/sbin/e2fsck $out/bin
cp -v ${pkgs.e2fsprogs}/sbin/tune2fs $out/bin
cp -v ${pkgs.reiserfsprogs}/sbin/reiserfsck $out/bin
ln -sv e2fsck $out/bin/fsck.ext2
ln -sv e2fsck $out/bin/fsck.ext3
ln -sv e2fsck $out/bin/fsck.ext4
ln -sv reiserfsck $out/bin/fsck.reiserfs
cp -pdv ${pkgs.e2fsprogs}/lib/lib*.so.* $out/lib
# Copy dmsetup and lvm.
cp -v ${pkgs.lvm2}/sbin/dmsetup $out/bin/dmsetup
cp -v ${pkgs.lvm2}/sbin/lvm $out/bin/lvm
@ -189,11 +178,6 @@ let
cp ${kernelPackages.splashutils}/${kernelPackages.splashutils.helperName} $out/bin/splash_helper
''}
# Copy nfsmount if there is any NFS mounts required for boot.
${optionalString (filter (fs: fs.fsType == "nfs" && (fs.mountPoint == "/" || fs.neededForBoot)) fileSystems != []) ''
cp -v ${pkgs.klibc}/lib/klibc/bin.static/nfsmount $out/bin
''}
${config.boot.initrd.extraUtilsCommands}
# Run patchelf to make the programs refer to the copied libraries.
@ -223,13 +207,10 @@ let
export LD_LIBRARY_PATH=$out/lib
$out/bin/mount --version | grep "mount from"
$out/bin/umount --version | grep "umount "
$out/bin/e2fsck -V 2>&1 | grep "e2fsck "
$out/bin/tune2fs 2> /dev/null | grep "tune2fs "
$out/bin/udevadm --version
$out/bin/blkid -v 2>&1 | tee -a $out/log | grep "blkid from util-linux"
$out/bin/dmsetup --version 2>&1 | tee -a $out/log | grep "version:"
LVM_SYSTEM_DIR=$out $out/bin/lvm version 2>&1 | tee -a $out/log | grep "LVM"
$out/bin/reiserfsck -V
$out/bin/mdadm --version
$out/bin/basename --version
$out/bin/modprobe --version

@ -2,37 +2,6 @@
with pkgs.lib;
let
usingSome = fsname: any (fs: fs.fsType == fsname) config.fileSystems;
usingSomeStage1 = fsname: any (fs: fs.fsType == fsname &&
(fs.mountPoint == "/" || fs.neededForBoot)) config.fileSystems;
usingBtrfs = usingSome "btrfs";
usingBtrfsStage1 = usingSomeStage1 "btrfs";
usingReiserfs = usingSome "reiserfs";
usingReiserfsStage1 = usingSomeStage1 "reiserfs";
# Packages that provide fsck backends.
fsPackages = [ pkgs.e2fsprogs pkgs.dosfstools ]
++ optional usingReiserfs pkgs.btrfsProgs
++ optional usingBtrfs pkgs.btrfsProgs;
fsKernelModules = optional usingBtrfsStage1 [ "btrfs" "crc32c" ]
++ optional usingReiserfsStage1 [ "reiserfs" ];
fsExtraUtilsCommands = optionalString usingBtrfsStage1 ''
cp -v ${pkgs.btrfsProgs}/bin/btrfsck $out/bin
cp -v ${pkgs.btrfsProgs}/bin/btrfs $out/bin
ln -sv btrfsck $out/bin/fsck.btrfs
'';
fsPostDeviceCommands = optionalString usingBtrfsStage1 ''
btrfs device scan
'';
in
{
###### interface
@ -54,7 +23,7 @@ in
}
];
description = "
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:
@ -72,7 +41,7 @@ in
<literal>autocreate</literal> forces <literal>mountPoint</literal> to be created with
<command>mkdir -p</command> .
";
'';
type = types.nullOr (types.list types.optionSet);
@ -81,36 +50,28 @@ in
mountPoint = mkOption {
example = "/mnt/usb";
type = types.uniq types.string;
description = "
Location of the mounted the file system.
";
description = "Location of the mounted the file system.";
};
device = mkOption {
default = null;
example = "/dev/sda";
type = types.uniq (types.nullOr types.string);
description = "
Location of the device.
";
description = "Location of the device.";
};
label = mkOption {
default = null;
example = "root-partition";
type = types.uniq (types.nullOr types.string);
description = "
Label of the device (if any).
";
description = "Label of the device (if any).";
};
fsType = mkOption {
default = "auto";
example = "ext3";
type = types.uniq types.string;
description = "
Type of the file system.
";
description = "Type of the file system.";
};
options = mkOption {
@ -124,10 +85,10 @@ in
autocreate = mkOption {
default = false;
type = types.bool;
description = "
description = ''
Automatically create the mount point defined in
<option>fileSystems.*.mountPoint</option>.
";
'';
};
noCheck = mkOption {
@ -138,12 +99,24 @@ in
};
};
system.sbin.mount = mkOption {
system.fsPackages = mkOption {
internal = true;
default = pkgs.utillinux;
description = "
Package containing mount and umount.
";
default = [ ];
description = "Packages supplying file system mounters and checkers.";
};
boot.supportedFilesystems = mkOption {
default = [ ];
example = [ "btrfs" ];
type = types.list types.string;
description = "Names of supported filesystem types.";
};
boot.initrd.supportedFilesystems = mkOption {
default = [ ];
example = [ "btrfs" ];
type = types.list types.string;
description = "Names of supported filesystem types in the initial ramdisk.";
};
};
@ -153,10 +126,19 @@ in
config = {
boot.supportedFilesystems =
map (fs: fs.fsType) config.fileSystems;
boot.initrd.supportedFilesystems =
map (fs: fs.fsType)
(filter (fs: fs.mountPoint == "/" || fs.neededForBoot) config.fileSystems);
# Add the mount helpers to the system path so that `mount' can find them.
system.fsPackages = [ pkgs.dosfstools ];
environment.systemPackages =
[ pkgs.ntfs3g pkgs.cifs_utils pkgs.nfsUtils pkgs.mountall ]
++ fsPackages;
[ pkgs.ntfs3g pkgs.cifs_utils pkgs.mountall ]
++ config.system.fsPackages;
environment.etc = singleton
{ source = pkgs.writeText "fstab"
@ -183,10 +165,6 @@ in
target = "fstab";
};
boot.initrd.extraUtilsCommands = fsExtraUtilsCommands;
boot.initrd.postDeviceCommands = fsPostDeviceCommands;
boot.initrd.kernelModules = fsKernelModules;
jobs.mountall =
{ startOn = "started udev"
# !!! The `started nfs-kernel-statd' condition shouldn't be
@ -198,12 +176,12 @@ in
task = true;
path = [ pkgs.utillinux ] ++ config.system.fsPackages;
script =
''
exec > /dev/console 2>&1
echo "mounting filesystems..."
export PATH=${config.system.sbin.mount}/bin:${makeSearchPath "sbin" ([pkgs.utillinux] ++ fsPackages)}:$PATH
${optionalString usingBtrfs "${pkgs.btrfsProgs}/bin/btrfs device scan"}
${pkgs.mountall}/sbin/mountall
'';
};

@ -0,0 +1,38 @@
{ config, pkgs, ... }:
with pkgs.lib;
let
inInitrd = any (fs: fs == "btrfs") config.boot.initrd.supportedFilesystems;
in
{
config = mkIf (any (fs: fs == "btrfs") config.boot.supportedFilesystems) {
system.fsPackages = [ pkgs.btrfsProgs ];
boot.initrd.kernelModules = mkIf inInitrd [ "btrfs" "crc32c" ];
boot.initrd.extraUtilsCommands = mkIf inInitrd
''
cp -v ${pkgs.btrfsProgs}/bin/btrfsck $out/bin
cp -v ${pkgs.btrfsProgs}/bin/btrfs $out/bin
ln -sv btrfsck $out/bin/fsck.btrfs
'';
boot.initrd.postDeviceCommands = mkIf inInitrd
''
btrfs device scan
'';
# !!! This is broken. There should be a udev rule to do this when
# new devices are discovered.
jobs.udev.postStart =
''
${pkgs.btrfsProgs}/bin/btrfs device scan
'';
};
}

@ -0,0 +1,22 @@
{ config, pkgs, ... }:
{
config = {
system.fsPackages = [ pkgs.e2fsprogs ];
boot.initrd.kernelModules = [ "ext2" "ext3" "ext4" ];
boot.initrd.extraUtilsCommands =
''
# Copy e2fsck and friends.
cp -v ${pkgs.e2fsprogs}/sbin/e2fsck $out/bin
cp -v ${pkgs.e2fsprogs}/sbin/tune2fs $out/bin
ln -sv e2fsck $out/bin/fsck.ext2
ln -sv e2fsck $out/bin/fsck.ext3
ln -sv e2fsck $out/bin/fsck.ext4
cp -pdv ${pkgs.e2fsprogs}/lib/lib*.so.* $out/lib
'';
};
}

@ -0,0 +1,25 @@
{ config, pkgs, ... }:
with pkgs.lib;
let
inInitrd = any (fs: fs == "nfs") config.boot.initrd.supportedFilesystems;
in
{
config = {
system.fsPackages = [ pkgs.nfsUtils ];
boot.initrd.kernelModules = mkIf inInitrd [ "nfs" ];
boot.initrd.extraUtilsCommands = mkIf inInitrd
''
# !!! Uh, why don't we just install mount.nfs?
cp -v ${pkgs.klibc}/lib/klibc/bin.static/nfsmount $out/bin
'';
};
}

@ -0,0 +1,25 @@
{ config, pkgs, ... }:
with pkgs.lib;
let
inInitrd = any (fs: fs == "reiserfs") config.boot.initrd.supportedFilesystems;
in
{
config = mkIf (any (fs: fs == "reiserfs") config.boot.supportedFilesystems) {
system.fsPackages = [ pkgs.reiserfsprogs ];
boot.initrd.kernelModules = mkIf inInitrd [ "reiserfs" ];
boot.initrd.extraUtilsCommands = mkIf inInitrd
''
cp -v ${pkgs.reiserfsprogs}/sbin/reiserfsck $out/bin
ln -sv reiserfsck $out/bin/fsck.reiserfs
'';
};
}
Loading…
Cancel
Save