* 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
This commit is contained in:
Eelco Dolstra 2012-03-09 14:37:58 +00:00
parent 8708578181
commit 03ebb883d1
12 changed files with 159 additions and 88 deletions

View file

@ -17,7 +17,6 @@ let
requiredPackages = requiredPackages =
[ config.system.sbin.modprobe # must take precedence over module_init_tools [ 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.system.build.upstart
config.environment.nix config.environment.nix
pkgs.acl pkgs.acl

View file

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

View file

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

View file

@ -6,8 +6,6 @@ let
cfg = config.services.autofs; cfg = config.services.autofs;
mount = config.system.sbin.mount;
autoMaster = pkgs.writeText "auto.master" cfg.autoMaster; autoMaster = pkgs.writeText "auto.master" cfg.autoMaster;
in in
@ -114,7 +112,7 @@ in
unescapeSpaces(){ sed 's/\\040/ /g'; } unescapeSpaces(){ sed 's/\\040/ /g'; }
sed -n 's@^\s*\(\([^\\ ]\|\\ \)*\)\s.*@\1@p' ${autoMaster} | sed 's/[\\]//' | while read mountPoint; do 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 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
done done
''; '';

View file

@ -151,7 +151,7 @@ in
${config.system.sbin.modprobe}/sbin/modprobe nfsd || true ${config.system.sbin.modprobe}/sbin/modprobe nfsd || true
${pkgs.sysvtools}/bin/mountpoint -q /proc/fs/nfsd \ ${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 ${optionalString cfg.server.createMountPoints
'' ''

View file

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

View file

@ -153,17 +153,6 @@ let
cp -v ${pkgs.coreutils}/bin/sleep $out/bin cp -v ${pkgs.coreutils}/bin/sleep $out/bin
cp -v ${pkgs.coreutils}/bin/ln $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. # Copy dmsetup and lvm.
cp -v ${pkgs.lvm2}/sbin/dmsetup $out/bin/dmsetup cp -v ${pkgs.lvm2}/sbin/dmsetup $out/bin/dmsetup
cp -v ${pkgs.lvm2}/sbin/lvm $out/bin/lvm cp -v ${pkgs.lvm2}/sbin/lvm $out/bin/lvm
@ -189,11 +178,6 @@ let
cp ${kernelPackages.splashutils}/${kernelPackages.splashutils.helperName} $out/bin/splash_helper 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} ${config.boot.initrd.extraUtilsCommands}
# Run patchelf to make the programs refer to the copied libraries. # Run patchelf to make the programs refer to the copied libraries.
@ -223,13 +207,10 @@ let
export LD_LIBRARY_PATH=$out/lib export LD_LIBRARY_PATH=$out/lib
$out/bin/mount --version | grep "mount from" $out/bin/mount --version | grep "mount from"
$out/bin/umount --version | grep "umount " $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/udevadm --version
$out/bin/blkid -v 2>&1 | tee -a $out/log | grep "blkid from util-linux" $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:" $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" 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/mdadm --version
$out/bin/basename --version $out/bin/basename --version
$out/bin/modprobe --version $out/bin/modprobe --version

View file

@ -2,37 +2,6 @@
with pkgs.lib; 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 ###### interface
@ -54,7 +23,7 @@ in
} }
]; ];
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>). Each the root directory (<literal>mountPoint = \"/\"</literal>). Each
entry in the list is an attribute set with the following fields: 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 <literal>autocreate</literal> forces <literal>mountPoint</literal> to be created with
<command>mkdir -p</command> . <command>mkdir -p</command> .
"; '';
type = types.nullOr (types.list types.optionSet); type = types.nullOr (types.list types.optionSet);
@ -81,36 +50,28 @@ in
mountPoint = mkOption { mountPoint = mkOption {
example = "/mnt/usb"; example = "/mnt/usb";
type = types.uniq types.string; type = types.uniq types.string;
description = " description = "Location of the mounted the file system.";
Location of the mounted the file system.
";
}; };
device = mkOption { device = mkOption {
default = null; default = null;
example = "/dev/sda"; example = "/dev/sda";
type = types.uniq (types.nullOr types.string); type = types.uniq (types.nullOr types.string);
description = " description = "Location of the device.";
Location of the device.
";
}; };
label = mkOption { label = mkOption {
default = null; default = null;
example = "root-partition"; example = "root-partition";
type = types.uniq (types.nullOr types.string); type = types.uniq (types.nullOr types.string);
description = " description = "Label of the device (if any).";
Label of the device (if any).
";
}; };
fsType = mkOption { fsType = mkOption {
default = "auto"; default = "auto";
example = "ext3"; example = "ext3";
type = types.uniq types.string; type = types.uniq types.string;
description = " description = "Type of the file system.";
Type of the file system.
";
}; };
options = mkOption { options = mkOption {
@ -124,10 +85,10 @@ in
autocreate = mkOption { autocreate = mkOption {
default = false; default = false;
type = types.bool; type = types.bool;
description = " description = ''
Automatically create the mount point defined in Automatically create the mount point defined in
<option>fileSystems.*.mountPoint</option>. <option>fileSystems.*.mountPoint</option>.
"; '';
}; };
noCheck = mkOption { noCheck = mkOption {
@ -138,12 +99,24 @@ in
}; };
}; };
system.sbin.mount = mkOption { system.fsPackages = mkOption {
internal = true; internal = true;
default = pkgs.utillinux; default = [ ];
description = " description = "Packages supplying file system mounters and checkers.";
Package containing mount and umount. };
";
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 = { 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. # Add the mount helpers to the system path so that `mount' can find them.
system.fsPackages = [ pkgs.dosfstools ];
environment.systemPackages = environment.systemPackages =
[ pkgs.ntfs3g pkgs.cifs_utils pkgs.nfsUtils pkgs.mountall ] [ pkgs.ntfs3g pkgs.cifs_utils pkgs.mountall ]
++ fsPackages; ++ config.system.fsPackages;
environment.etc = singleton environment.etc = singleton
{ source = pkgs.writeText "fstab" { source = pkgs.writeText "fstab"
@ -183,10 +165,6 @@ in
target = "fstab"; target = "fstab";
}; };
boot.initrd.extraUtilsCommands = fsExtraUtilsCommands;
boot.initrd.postDeviceCommands = fsPostDeviceCommands;
boot.initrd.kernelModules = fsKernelModules;
jobs.mountall = jobs.mountall =
{ startOn = "started udev" { startOn = "started udev"
# !!! The `started nfs-kernel-statd' condition shouldn't be # !!! The `started nfs-kernel-statd' condition shouldn't be
@ -198,12 +176,12 @@ in
task = true; task = true;
path = [ pkgs.utillinux ] ++ config.system.fsPackages;
script = script =
'' ''
exec > /dev/console 2>&1 exec > /dev/console 2>&1
echo "mounting filesystems..." 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 ${pkgs.mountall}/sbin/mountall
''; '';
}; };

View file

@ -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
'';
};
}

View file

@ -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
'';
};
}

View file

@ -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
'';
};
}

View file

@ -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
'';
};
}