lvm2: Added script and updated Makefile to activate lvm2 at preinit to allow overlays... 11528/head
authorHarrie Rooijackers <Harrie.Rooijackers+OpenWRT@gmail.com>
Thu, 26 Dec 2019 16:31:32 +0000 (17:31 +0100)
committerHarrie Rooijackers <Harrie.Rooijackers+OpenWRT@gmail.com>
Sun, 8 Mar 2020 12:57:52 +0000 (13:57 +0100)
Signed-off-by: Harrie Rooijackers <Harrie.Rooijackers+OpenWRT@gmail.com>
utils/lvm2/Makefile
utils/lvm2/files/lvm2.preinit [new file with mode: 0644]

index 2fa1eda46551b0e3e1d2f1322b401a04044b7f4c..7ee2a18caa855ec6b42dc30e9e70b6cb6da159bf 100644 (file)
@@ -10,7 +10,7 @@ include $(TOPDIR)/rules.mk
 
 PKG_NAME:=LVM2
 PKG_VERSION:=2.03.08
-PKG_RELEASE:=1
+PKG_RELEASE:=2
 
 PKG_SOURCE:=$(PKG_NAME).$(PKG_VERSION).tgz
 PKG_SOURCE_URL:=https://sourceware.org/pub/lvm2
@@ -92,6 +92,8 @@ define Package/lvm2/install
        $(INSTALL_CONF) $(PKG_INSTALL_DIR)/etc/lvm/lvmlocal.conf $(1)/etc/lvm/
        $(INSTALL_DIR) $(1)/etc/lvm/profile
        $(INSTALL_CONF) $(PKG_INSTALL_DIR)/etc/lvm/profile/* $(1)/etc/lvm/profile/
+       $(INSTALL_DIR) $(1)/lib/preinit
+       $(INSTALL_DATA) ./files/lvm2.preinit $(1)/lib/preinit/80_lvm2
        $(INSTALL_DIR) $(1)/etc/init.d
        $(INSTALL_BIN) ./files/lvm2.init $(1)/etc/init.d/lvm2
        $(FIND) $(PKG_INSTALL_DIR)/usr/sbin/ -type l -exec $(CP) -a {} $(1)/sbin/ \;
diff --git a/utils/lvm2/files/lvm2.preinit b/utils/lvm2/files/lvm2.preinit
new file mode 100644 (file)
index 0000000..b654e79
--- /dev/null
@@ -0,0 +1,25 @@
+#!/bin/sh
+# Copyright (C) 2019 Harrie Rooijackers
+
+# The make proecess copies this file to the /lib/preinit/80_lvm2
+# As a result it is executed just before 80_mount_root and makes lvm
+# entities available during the mount_root process that handles any
+# overlays.  This allows overlays to be lvm2 partitions.
+
+# Note that /lib/preinit/80_lvm2 needs to be on the initial "lower"
+# partition for this to work.
+
+do_startlvm() {
+        echo "Starting lvm2 during preinit" > /dev/kmsg
+        # The following 3 lines are copied from from the start function
+        # in /etc/rc.d/S15lvm2 which is copyright by Stefan Monnier
+        mkdir -p /tmp/lvm/cache
+        /sbin/lvm vgscan --ignorelockingfailure --mknodes > /dev/kmsg || :
+        /sbin/lvm vgchange -aly --ignorelockingfailure > /dev/kmsg || return 2
+}
+
+# Perform the function only if lvm2 is enabled by the user
+# Not sure if the test is that useful since it tests the existance
+# of /etc/rc.d/S15lvm2 on the initial "lower" partition only so
+# changes made after the overlay is created are not taken into account
+[ -f /etc/rc.d/S15lvm2 ] && boot_hook_add preinit_main do_startlvm