* Create devicemapper/lvm device nodes from udev (using the rules

supplied by the lvm package).  This makes the "lvm" Upstart task
  unnecessary.  Also, we now get /dev/disk/by-{label,uuid} symlinks
  for LVM logical disks.

svn path=/nixos/trunk/; revision=19300
This commit is contained in:
Eelco Dolstra 2010-01-07 22:39:35 +00:00
parent fa2a6f835f
commit 6f8a3ba7c7
2 changed files with 22 additions and 38 deletions

View File

@ -44,19 +44,6 @@ let
# called by 50-firmware.rules works properly.
echo 'ENV{FIRMWARE_DIRS}="${toString config.hardware.firmware}"' >> $out/00-path.rules
# Fix some paths in the standard udev rules.
for i in $out/*.rules; do
substituteInPlace $i \
--replace /sbin/modprobe ${modprobe}/sbin/modprobe \
--replace /sbin/blkid ${pkgs.utillinux}/sbin/blkid \
--replace /sbin/mdadm ${pkgs.mdadm}/sbin/madm
done
# If auto-configuration is disabled, then remove
# udev's 80-drivers.rules file, which contains rules for
# automatically calling modprobe.
${if !config.boot.hardwareScan then "rm $out/80-drivers.rules" else ""}
# Add the udev rules from other packages.
for i in ${toString cfg.packages}; do
for j in $i/*/udev/rules.d/*; do
@ -64,6 +51,21 @@ let
done
done
# Fix some paths in the standard udev rules. Hacky.
for i in $out/*.rules; do
substituteInPlace $i \
--replace /sbin/modprobe ${modprobe}/sbin/modprobe \
--replace /sbin/blkid ${pkgs.utillinux}/sbin/blkid \
--replace /sbin/mdadm ${pkgs.mdadm}/sbin/madm \
--replace '$env{DM_SBIN_PATH}/blkid' ${pkgs.utillinux}/sbin/blkid \
--replace 'ENV{DM_SBIN_PATH}="/sbin"' 'ENV{DM_SBIN_PATH}="${pkgs.lvm2}/sbin"'
done
# If auto-configuration is disabled, then remove
# udev's 80-drivers.rules file, which contains rules for
# automatically calling modprobe.
${if !config.boot.hardwareScan then "rm $out/80-drivers.rules" else ""}
# Use the persistent device rules (naming for CD/DVD and
# network devices) stored in
# /var/lib/udev/rules.d/70-persistent-{cd,net}.rules. These are
@ -186,8 +188,12 @@ in
''
# Let udev create device nodes for all modules that have already
# been loaded into the kernel (or for which support is built into
# the kernel).
# the kernel). The `STARTUP' variable is needed to force
# the LVM rules to create device nodes. See
# http://www.mail-archive.com/fedora-devel-list@redhat.com/msg10261.html
${udev}/sbin/udevadm control --env=STARTUP=1
${udev}/sbin/udevadm trigger
${udev}/sbin/udevadm control --env=STARTUP=
${udev}/sbin/udevadm settle # wait for udev to finish
initctl emit -n new-devices

View File

@ -6,32 +6,10 @@
config = {
jobs.lvm =
{ startOn = "started udev or new-devices";
script =
''
# Load the device mapper.
${config.system.sbin.modprobe}/sbin/modprobe dm_mod || true
${pkgs.lvm2}/sbin/dmsetup mknodes
# Scan for block devices that might contain LVM physical volumes
# and volume groups.
${pkgs.lvm2}/sbin/vgscan --mknodes
# Make all logical volumes on all volume groups available, i.e.,
# make them appear in /dev.
${pkgs.lvm2}/sbin/vgchange --available y
initctl emit -n new-devices
'';
task = true;
};
environment.systemPackages = [ pkgs.lvm2 ];
services.udev.packages = [ pkgs.lvm2 ];
};
}