* 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
wip/yesman
Eelco Dolstra 15 years ago
parent fa2a6f835f
commit 6f8a3ba7c7
  1. 26
      modules/services/hardware/udev.nix
  2. 26
      modules/tasks/lvm.nix

@ -44,12 +44,21 @@ 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.
# Add the udev rules from other packages.
for i in ${toString cfg.packages}; do
for j in $i/*/udev/rules.d/*; do
ln -s $j $out/$(basename $j)
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 /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
@ -57,13 +66,6 @@ let
# 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
ln -s $j $out/$(basename $j)
done
done
# 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

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

Loading…
Cancel
Save