ASR_BASE
Change-Id: Icf3719cc0afe3eeb3edc7fa80a2eb5199ca9dda1
diff --git a/external/subpack/utils/lvm2/files/lvm2.hotplug b/external/subpack/utils/lvm2/files/lvm2.hotplug
new file mode 100644
index 0000000..0ef48c5
--- /dev/null
+++ b/external/subpack/utils/lvm2/files/lvm2.hotplug
@@ -0,0 +1,6 @@
+
+[ "$ACTION" = "add" ] || return 0
+[ -e "/dev/$DEVNAME" ] || return 0
+
+/sbin/lvm vgscan --mknodes --devices /dev/$DEVNAME || :
+/sbin/lvm vgchange -aly --devices /dev/$DEVNAME || :
diff --git a/external/subpack/utils/lvm2/files/lvm2.init b/external/subpack/utils/lvm2/files/lvm2.init
new file mode 100644
index 0000000..4faf5d5
--- /dev/null
+++ b/external/subpack/utils/lvm2/files/lvm2.init
@@ -0,0 +1,14 @@
+#!/bin/sh /etc/rc.common
+# Copyright (C) 2009 Stefan Monnier
+START=15
+
+start () {
+ mkdir -p /tmp/lvm/cache
+ /sbin/lvm vgscan --ignorelockingfailure --mknodes || :
+ /sbin/lvm vgchange -aly --ignorelockingfailure || return 2
+}
+
+stop () {
+ mkdir -p /tmp/lvm/cache
+ /sbin/lvm vgchange -aln --ignorelockingfailure || return 2
+}
diff --git a/external/subpack/utils/lvm2/files/lvm2.preinit b/external/subpack/utils/lvm2/files/lvm2.preinit
new file mode 100644
index 0000000..b654e79
--- /dev/null
+++ b/external/subpack/utils/lvm2/files/lvm2.preinit
@@ -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