[Nix-dev] NixOS with ROOT on lvm device
Yurii G. Kudryashov
urkud at mccme.ru
Mon Jun 25 01:59:27 CEST 2007
Hello!
Current NixOS configuration doesn't support booting with ROOT on
lvm device. I've patched some files, and using ROOT on LVM.
I've also upgraded device-mapper and lvm2 to the latest versions.
`svn diff` output is attached.
Currently I have the following problem: vgscan --mknodes in
patched lvm upstart job creates /dev/vg_name directory with mode
700 instead of 755.
Unpatched upstart lvm job doesn't create any /dev/vg_name/lv_name
files (at least on my computer).
--
Yura,
mailto: urkud at mccme.ru
Jabber: urkud.urkud at gmail.com
ICQ: 174534205
-------------- next part --------------
Index: boot/boot-stage-1-init.sh
===================================================================
--- boot/boot-stage-1-init.sh (revision 8916)
+++ boot/boot-stage-1-init.sh (working copy)
@@ -73,6 +73,13 @@
udevtrigger
udevsettle
+if type -p dmsetup > /dev/null; then
+ echo "dmsetup found, starting device mapper and lvm"
+ dmsetup mknodes
+ vgscan --ignorelockingfailure
+ vgchange -ay --ignorelockingfailure
+fi
+
if test -n "$debug1devices"; then fail; fi
Index: system/system.nix
===================================================================
--- system/system.nix (revision 8916)
+++ system/system.nix (working copy)
@@ -52,10 +52,18 @@
inherit (pkgsStatic) utillinux;
inherit (pkgsDiet) udev;
e2fsprogs = pkgs.e2fsprogsDiet;
+ devicemapper = if config.get ["boot" "initrd" "lvm"] then pkgs.devicemapperStatic else null;
+ lvm2 = if config.get ["boot" "initrd" "lvm"] then pkgs.lvm2Static else null;
allowedReferences = []; # prevent accidents like glibc being included in the initrd
}
"
ensureDir $out/bin
+ if [ -n $devicemapper ]; then
+ cp $devicemapper/sbin/dmsetup.static $out/bin/dmsetup
+ cp $lvm2/sbin/lvm.static $out/bin/lvm
+ ln -s lvm $out/bin/vgscan
+ ln -s lvm $out/bin/vgchange
+ fi
cp $utillinux/bin/mount $utillinux/bin/umount $utillinux/sbin/pivot_root $out/bin
cp -p $e2fsprogs/sbin/fsck* $e2fsprogs/sbin/e2fsck $out/bin
cp $udev/sbin/udevd $udev/sbin/udevtrigger $udev/sbin/udevsettle $out/bin
Index: system/options.nix
===================================================================
--- system/options.nix (revision 8916)
+++ system/options.nix (working copy)
@@ -177,6 +177,15 @@
";
}
+ {
+ name = ["boot" "initrd" "lvm"];
+ default = false;
+ description = "
+ Whether to include lvm in the initial ramdisk. You should use this option
+ if your ROOT device is on lvm volume. Also add dm_mod to
+ extraKernelModules in this case.
+ ";
+ }
{
name = ["boot" "initrd" "enableSplashScreen"];
Index: upstart-jobs/default.nix
===================================================================
--- upstart-jobs/default.nix (revision 8916)
+++ upstart-jobs/default.nix (working copy)
@@ -36,7 +36,7 @@
# Makes LVM logical volumes available.
(import ../upstart-jobs/lvm.nix {
inherit modprobe;
- inherit (pkgs) lvm2;
+ inherit (pkgs) lvm2 devicemapper;
})
# Activate software RAID arrays.
Index: upstart-jobs/lvm.nix
===================================================================
--- upstart-jobs/lvm.nix (revision 8916)
+++ upstart-jobs/lvm.nix (working copy)
@@ -1,4 +1,4 @@
-{modprobe, lvm2}:
+{modprobe, lvm2, devicemapper}:
{
name = "lvm";
@@ -12,9 +12,10 @@
# Load the device mapper.
${modprobe}/sbin/modprobe dm_mod || true
+ ${devicemapper}/sbin/dmsetup mknodes
# Scan for block devices that might contain LVM physical volumes
# and volume groups.
- #${lvm2}/sbin/vgscan
+ ${lvm2}/sbin/vgscan --mknodes
# Make all logical volumes on all volume groups available, i.e.,
# make them appear in /dev.
-------------- next part --------------
Index: pkgs/os-specific/linux/device-mapper/default.nix
===================================================================
--- pkgs/os-specific/linux/device-mapper/default.nix (revision 8916)
+++ pkgs/os-specific/linux/device-mapper/default.nix (working copy)
@@ -1,11 +1,12 @@
-{stdenv, fetchurl}:
+{stdenv, fetchurl, static ? false}:
stdenv.mkDerivation {
- name = "device-mapper-1.02.13";
+ name = "device-mapper-1.02.20";
src = fetchurl {
- url = ftp://sources.redhat.com/pub/dm/device-mapper.1.02.13.tgz;
- md5 = "9ab13083a939ceb26ce5da6b625aeb3c";
+ url = ftp://sources.redhat.com/pub/dm/device-mapper.1.02.20.tgz;
+ sha256 = "2db8a8d402b6a827c5684919b4013444cb9fad50ab8cf7ca86ade9bea7796b1c";
};
+ configureFlags = if static then "--enable-static_link" else "";
# To prevent make install from failing.
installFlags = "OWNER= GROUP=";
}
Index: pkgs/os-specific/linux/lvm2/default.nix
===================================================================
--- pkgs/os-specific/linux/lvm2/default.nix (revision 8916)
+++ pkgs/os-specific/linux/lvm2/default.nix (working copy)
@@ -1,12 +1,13 @@
-{stdenv, fetchurl, devicemapper}:
+{stdenv, fetchurl, devicemapper, static ? false}:
stdenv.mkDerivation {
- name = "lvm2-2.02.17";
+ name = "lvm2-2.02.26";
src = fetchurl {
- url = ftp://sources.redhat.com/pub/lvm2/old/LVM2.2.02.17.tgz;
- sha256 = "12bbr0rg5cmysmdvz6pv2fz9yhcff3fmivdcy2qaxn4p412255sj";
+ url = ftp://sources.redhat.com/pub/lvm2/LVM2.2.02.26.tgz;
+ sha256 = "6a177953f1a81aff91144b6bea8eb5f73f6139b10bffd5946c22a32f586ab899";
};
buildInputs = [devicemapper];
+ configureFlags = if static then "--enable-static_link" else "";
# To prevent make install from failing.
preInstall = "installFlags=\"OWNER= GROUP= confdir=$out/etc\"";
}
Index: pkgs/top-level/all-packages.nix
===================================================================
--- pkgs/top-level/all-packages.nix (revision 8916)
+++ pkgs/top-level/all-packages.nix (working copy)
@@ -2232,6 +2232,11 @@
inherit fetchurl stdenv;
};
+ devicemapperStatic = lowPrio (appendToName "static" (import ../os-specific/linux/device-mapper {
+ inherit fetchurl stdenv;
+ static = true;
+ }));
+
dietlibc = import ../os-specific/linux/dietlibc {
inherit fetchurl glibc;
# Dietlibc 0.30 doesn't compile on PPC with GCC 4.1, bus GCC 3.4 works.
@@ -2435,6 +2440,12 @@
inherit fetchurl stdenv devicemapper;
};
+ lvm2Static = lowPrio (appendToName "static" (import ../os-specific/linux/lvm2 {
+ inherit fetchurl stdenv;
+ static = true;
+ devicemapper = devicemapperStatic;
+ }));
+
mdadm = import ../os-specific/linux/mdadm {
inherit fetchurl stdenv groff;
};
More information about the nix-dev
mailing list