From f32236e54283b533422bd02ecfda720d7fc86017 Mon Sep 17 00:00:00 2001 From: Daniel Golle Date: Sun, 8 Aug 2021 15:34:27 +0100 Subject: [PATCH] lvm2: add hotplug script to scan and enable PVs on hotplug Automatically scan and activate physical volumes when added at runtime. Signed-off-by: Daniel Golle --- utils/lvm2/Makefile | 2 ++ utils/lvm2/files/lvm2.hotplug | 6 ++++++ 2 files changed, 8 insertions(+) create mode 100644 utils/lvm2/files/lvm2.hotplug diff --git a/utils/lvm2/Makefile b/utils/lvm2/Makefile index 3ec9c42e6..e4a06ffc0 100644 --- a/utils/lvm2/Makefile +++ b/utils/lvm2/Makefile @@ -144,6 +144,8 @@ define Package/lvm2/install $(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 + $(INSTALL_DIR) $(1)/etc/hotplug.d/block + $(INSTALL_DATA) ./files/lvm2.hotplug $(1)/etc/hotplug.d/block/20-lvm2 $(FIND) $(PKG_INSTALL_DIR)/usr/sbin/ -type l -exec $(CP) -a {} $(1)/sbin/ \; endef diff --git a/utils/lvm2/files/lvm2.hotplug b/utils/lvm2/files/lvm2.hotplug new file mode 100644 index 000000000..0ef48c540 --- /dev/null +++ b/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 || :