changes to allow boot/install from/to virtual raid disk
cover changes to allow boot/install from/to virtual raid disk
These series patches used to add support to install image to Intel Virtual Raid disk and boot from it.
To boot from raid disk, mdadm is the necessory tools to initial it, so it must run in initrd to make raid disk available, then rootfs on it can be mounted to use, rootfs can be stored directly in raid disk partition or LVM partition.
Liwei Song (8):
mdadm: add mdmon service to support Intel VROC
mdadm: add udev rules to create by-partuuid for MD devices
udev-extraconf: move md* and dm* from mount blacklist
initramfs-framework: mount efivarfs to make Intel VROC work well
initramfs-framework: add lvm module
init-install: add support for install image to Intel VROC raid disk
init-install: fix a typo which will led delete section failed when use
sed
oe-core: add ledmon to support Intel VROC
.../initrdscripts/files/init-install-efi.sh | 25 +++++++++++++---- .../initrdscripts/initramfs-framework/init | 5 ++++ .../initrdscripts/initramfs-framework/lvm | 13 +++++++++ .../initrdscripts/initramfs-framework_1.0.bb | 9 ++++++ .../udev/udev-extraconf/mount.blacklist | 2 -- meta/recipes-extended/ledmon/ledmon_git.bb | 32 ++++++++++++++++++++++ ...ev.rules-create-by-partuuid-for-md-device.patch | 29 ++++++++++++++++++++ meta/recipes-extended/mdadm/mdadm_4.1.bb | 4 ++- 8 files changed, 111 insertions(+), 8 deletions(-) create mode 100644 meta/recipes-core/initrdscripts/initramfs-framework/lvm create mode 100644 meta/recipes-extended/ledmon/ledmon_git.bb create mode 100644 meta/recipes-extended/mdadm/files/0001-udev.rules-create-by-partuuid-for-md-device.patch
Signature · 1 line
2.7.4
PATCH 1/8 mdadm: add mdmon service to support Intel VROC
Install [email protected] to make Intel VROC work well.
[email protected] called from udev is used to update Intel VROC metadata, with it the VROC raid is operational to read or write under user space.
--- meta/recipes-extended/mdadm/mdadm_4.1.bb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
meta/recipes-extended/mdadm/mdadm_4.1.bb +2 -1
@@ -26,7 +26,7 @@ SRC_URI[sha256sum] = "ab7688842908d3583a704d491956f31324c3a5fc9f6a04653cb75d19f1 inherit autotools-brokensep ptest systemd -SYSTEMD_SERVICE_${PN} = "mdmonitor.service" +SYSTEMD_SERVICE_${PN} = "mdmonitor.service [email protected]" SYSTEMD_AUTO_ENABLE = "disable" CFLAGS_append_toolchain-clang = " -Wno-error=address-of-packed-member"
@@ -57,6 +57,7 @@ do_install_append() { install -m 644 ${S}/mdadm.conf-example ${D}${sysconfdir}/mdadm.conf install -d ${D}/${systemd_unitdir}/system install -m 644 ${WORKDIR}/mdmonitor.service ${D}/${systemd_unitdir}/system + install -m 644 ${S}/systemd/[email protected] ${D}/${systemd_unitdir}/system install -d ${D}/${sysconfdir}/init.d install -m 755 ${WORKDIR}/mdadm.init ${D}${sysconfdir}/init.d/mdmonitor }
Signature · 1 line
2.7.4
PATCH 2/8 mdadm: add udev rules to create by-partuuid for MD devices
In reply to Liwei Songinstaller use partuuid for boot and swap partition,
But the udev rules for MD devices do not have rules to create by-partuuid under /dev/disk/, this will take 90s to wait until failed add the rules to create by-partuuid to support boot from raid disk with "root=PARTUUID=XXX"
--- ...ev.rules-create-by-partuuid-for-md-device.patch | 29 ++++++++++++++++++++++ meta/recipes-extended/mdadm/mdadm_4.1.bb | 1 + 2 files changed, 30 insertions(+) create mode 100644 meta/recipes-extended/mdadm/files/0001-udev.rules-create-by-partuuid-for-md-device.patch
meta/recipes-extended/mdadm/files/0001-udev.rules-create-by-partuuid-for-md-device.patch new file +29 -0
@@ -0,0 +1,29 @@ +From 7d1fa6afba936edb3e211f0ccdb58b1472b4bbf4 Mon Sep 17 00:00:00 2001 +From: Liwei Song <[email protected]> +Date: Tue, 26 Feb 2019 07:05:42 +0000 +Subject: [PATCH] udev.rules: create by-partuuid for md device + +Create by-partuuid for every md devices. + +Upstream-Status: sent to [email protected](https://www.spinics.net/lists/raid/msg62373.html) + +Signed-off-by: Liwei Song <[email protected]> +--- + udev-md-raid-arrays.rules | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/udev-md-raid-arrays.rules b/udev-md-raid-arrays.rules +index c95ec7b1e4a9..e326414efcbc 100644 +--- a/udev-md-raid-arrays.rules ++++ b/udev-md-raid-arrays.rules +@@ -30,6 +30,7 @@ IMPORT{builtin}="blkid" + OPTIONS+="link_priority=100" + OPTIONS+="watch" + ENV{ID_FS_USAGE}=="filesystem|other|crypto", ENV{ID_FS_UUID_ENC}=="?*", SYMLINK+="disk/by-uuid/$env{ID_FS_UUID_ENC}" ++ENV{ID_FS_USAGE}=="filesystem|other", ENV{ID_PART_ENTRY_UUID}=="?*", SYMLINK+="disk/by-partuuid/$env{ID_PART_ENTRY_UUID}" + ENV{ID_FS_USAGE}=="filesystem|other", ENV{ID_FS_LABEL_ENC}=="?*", SYMLINK+="disk/by-label/$env{ID_FS_LABEL_ENC}" + + ENV{MD_LEVEL}=="raid[1-9]*", ENV{SYSTEMD_WANTS}+="mdmonitor.service" +-- +2.11.0 +
meta/recipes-extended/mdadm/mdadm_4.1.bb +1 -0
@@ -20,6 +20,7 @@ SRC_URI = "${KERNELORG_MIRROR}/linux/utils/raid/mdadm/${BPN}-${PV}.tar.xz \ file://mdadm.init \ file://mdmonitor.service \ file://0001-mdadm-gcc8-maybe-uninitialized-format-overflow-warni.patch \ + file://0001-udev.rules-create-by-partuuid-for-md-device.patch \ " SRC_URI[md5sum] = "51bf3651bd73a06c413a2f964f299598" SRC_URI[sha256sum] = "ab7688842908d3583a704d491956f31324c3a5fc9f6a04653cb75d19f1934f4a"
Signature · 1 line
2.7.4
Re: [PATCH 2/8] mdadm: add udev rules to create by-partuuid for MD devices
Quoted 35 lines · Liwei Song
installer use partuuid for boot and swap partition,
But the udev rules for MD devices do not have rules to create by-partuuid under/dev/disk/, this will take 90s to wait until failed add the rules to create by-partuuid to support boot from raid disk with "root=PARTUUID=XXX"Signed-off-by Liwei Song <[email protected]>--- ...ev.rules-create-by-partuuid-for-md-device.patch | 29 ++++++++++++++++++++++ meta/recipes-extended/mdadm/mdadm_4.1.bb | 1 + 2 files changed, 30 insertions(+) create mode 100644 meta/recipes-extended/mdadm/files/0001-udev.rules-create-by-partuuid-for-md-device.patch
(quoted diff) +0
-0create-by-partuuid-for-md-device.patch b/meta/recipes- extended/mdadm/files/0001-udev.rules-create-by-partuuid-for-md- device.patch
new file mode 100644
index 000000000000..c1f7b1cf8736meta/recipes-extended/mdadm/files/0001-udev.rules-create-by- new file +0
-0partuuid-for-md-device.patch
meta/recipes-extended/mdadm/files/0001-udev.rules-create-by- new file +1
-0@@ -0,0 +1,29 @@ +From 7d1fa6afba936edb3e211f0ccdb58b1472b4bbf4 Mon Sep 17 00:00:002001
meta/recipes-extended/mdadm/files/0001-udev.rules-create-by- new file +7
-0+From: Liwei Song <[email protected]> +Date: Tue, 26 Feb 2019 07:05:42 +0000 +Subject: [PATCH] udev.rules: create by-partuuid for md device + +Create by-partuuid for every md devices. + +Upstream-Status: sent to [email protected](
meta/recipes-extended/mdadm/files/0001-udev.rules-create-by-
Quoted 5 lines
meta/recipes-extended/mdadm/files/0001-udev.rules-create-by- new file +5
-0+ +Signed-off-by: Liwei Song <[email protected]> +--- + udev-md-raid-arrays.rules | 1 + + 1 file changed, 1 insertion(+)
It looks like upstream had concerns about this so I'd like to hold off on this until those are resolved.
https://www.spinics.net/lists/raid/msg62376.html
Cheers,
Richard
Re: [PATCH 2/8] mdadm: add udev rules to create by-partuuid for MD devices
Quoted 36 lines · Richard Purdie
Quoted 35 lines · Liwei Song
installer use partuuid for boot and swap partition,
But the udev rules for MD devices do not have rules to create by-partuuid under/dev/disk/, this will take 90s to wait until failed add the rules to create by-partuuid to support boot from raid disk with "root=PARTUUID=XXX"Signed-off-by Liwei Song <[email protected]>--- ...ev.rules-create-by-partuuid-for-md-device.patch | 29 ++++++++++++++++++++++ meta/recipes-extended/mdadm/mdadm_4.1.bb | 1 + 2 files changed, 30 insertions(+) create mode 100644 meta/recipes-extended/mdadm/files/0001-udev.rules-create-by-partuuid-for-md-device.patch
(quoted diff) +0
-0create-by-partuuid-for-md-device.patch b/meta/recipes- extended/mdadm/files/0001-udev.rules-create-by-partuuid-for-md- device.patch
new file mode 100644
index 000000000000..c1f7b1cf8736meta/recipes-extended/mdadm/files/0001-udev.rules-create-by- new file +0
-0partuuid-for-md-device.patch
meta/recipes-extended/mdadm/files/0001-udev.rules-create-by- new file +1
-0@@ -0,0 +1,29 @@ +From 7d1fa6afba936edb3e211f0ccdb58b1472b4bbf4 Mon Sep 17 00:00:002001
meta/recipes-extended/mdadm/files/0001-udev.rules-create-by- new file +7
-0+From: Liwei Song <[email protected]> +Date: Tue, 26 Feb 2019 07:05:42 +0000 +Subject: [PATCH] udev.rules: create by-partuuid for md device + +Create by-partuuid for every md devices. + +Upstream-Status: sent to [email protected](
Quoted 8 lines
meta/recipes-extended/mdadm/files/0001-udev.rules-create-by-
Quoted 5 lines
meta/recipes-extended/mdadm/files/0001-udev.rules-create-by- new file +5
-0+ +Signed-off-by: Liwei Song <[email protected]> +--- + udev-md-raid-arrays.rules | 1 + + 1 file changed, 1 insertion(+)It looks like upstream had concerns about this so I'd like to hold off on this until those are resolved.
No problem, let's wait if other folks have more concern before it is applied.
https://www.spinics.net/lists/raid/msg62379.html
Thanks,
Liwei.
Quoted 9 lines
https://www.spinics.net/lists/raid/msg62376.html
Cheers,
Richard
PATCH 3/8 udev-extraconf: move md* and dm* from mount blacklist
In reply to Liwei SongWhen use rootfs.img as rootfs, root=/dev/ram0 was set, init will search rootfs.img from all automount point, if deploy it to MD or DM device, rootfs.img will not be found, then boot failed.
Do not black MD and DM device to allow boot from raid disk or raid LVM volume.
--- meta/recipes-core/udev/udev-extraconf/mount.blacklist | 2 -- 1 file changed, 2 deletions(-)
meta/recipes-core/udev/udev-extraconf/mount.blacklist +0 -2
@@ -1,5 +1,3 @@ /dev/loop /dev/ram /dev/mtdblock -/dev/md -/dev/dm-*
Signature · 1 line
2.7.4
PATCH 4/8 initramfs-framework: mount efivarfs to make Intel VROC work well
In reply to Liwei Songefivafs contain some meta data about Intel VROC, which will be used by mdadm to create raid device.
These are preparation work to support boot from Intel VROC RAID disk.
--- meta/recipes-core/initrdscripts/initramfs-framework/init | 5 +++++ 1 file changed, 5 insertions(+)
meta/recipes-core/initrdscripts/initramfs-framework/init +5 -0
@@ -72,6 +72,7 @@ ROOTFS_DIR="/rootfs" # where to do the switch root MODULE_PRE_HOOKS="" # functions to call before running each module MODULE_POST_HOOKS="" # functions to call after running each module MODULES_DIR=/init.d # place to look for modules +EFI_DIR=/sys/firmware/efi # place to store device firmware information # make mount stop complaining about missing /etc/fstab touch /etc/fstab
@@ -81,6 +82,10 @@ mkdir -p /proc /sys /run/lock /var/lock mount -t proc proc /proc mount -t sysfs sysfs /sys +if [ -d $EFI_DIR ];then + mount -t efivarfs none /sys/firmware/efi/efivars +fi + # populate bootparam environment for p in `cat /proc/cmdline`; do opt=`echo $p | cut -d'=' -f1`
Signature · 1 line
2.7.4
PATCH 5/8 initramfs-framework: add lvm module
In reply to Liwei Songlvm module will initial lvm volume to support boot from Logical Volume.
--- meta/recipes-core/initrdscripts/initramfs-framework/lvm | 13 +++++++++++++ meta/recipes-core/initrdscripts/initramfs-framework_1.0.bb | 9 +++++++++ 2 files changed, 22 insertions(+) create mode 100644 meta/recipes-core/initrdscripts/initramfs-framework/lvm
meta/recipes-core/initrdscripts/initramfs-framework/lvm new file +13 -0
@@ -0,0 +1,13 @@ +#!/bin/sh + +lvm_enabled() { + if ! lvscan |grep -i -w "inactive" &>/dev/null;then + return 1 + fi + return 0 +} + +lvm_run() { + lvm pvscan --cache --activate ay + udevadm trigger --action=add +}
meta/recipes-core/initrdscripts/initramfs-framework_1.0.bb +9 -0
@@ -17,6 +17,7 @@ SRC_URI = "file://init \ file://udev \ file://e2fs \ file://debug \ + file://lvm \ " S = "${WORKDIR}"
@@ -45,6 +46,9 @@ do_install() { # debug install -m 0755 ${WORKDIR}/debug ${D}/init.d/00-debug + # lvm + install -m 0755 ${WORKDIR}/lvm ${D}/init.d/09-lvm + # Create device nodes expected by some kernels in initramfs # before even executing /init. install -d ${D}/dev
@@ -59,6 +63,7 @@ PACKAGES = "${PN}-base \ initramfs-module-nfsrootfs \ initramfs-module-rootfs \ initramfs-module-debug \ + initramfs-module-lvm \ " FILES_${PN}-base = "/init /init.d/99-finish /dev"
@@ -98,3 +103,7 @@ FILES_initramfs-module-rootfs = "/init.d/90-rootfs" SUMMARY_initramfs-module-debug = "initramfs dynamic debug support" RDEPENDS_initramfs-module-debug = "${PN}-base" FILES_initramfs-module-debug = "/init.d/00-debug" + +SUMMARY_initramfs-module-lvm = "initramfs lvm rootfs support" +RDEPENDS_initramfs-module-lvm = "${PN}-base" +FILES_initramfs-module-lvm = "/init.d/09-lvm"
Signature · 1 line
2.7.4
PATCH 6/8 init-install: add support for install image to Intel VROC raid disk
In reply to Liwei SongIntel VROC raid device named as /dev/mdXX, now it only can boot with initramfs method because it need mdadm to do initial work in it, so do not remove initrd for such kind device.
It also use "p" as partition prefix, adjust it to aviod use a wrong device name durning install.
--- .../initrdscripts/files/init-install-efi.sh | 23 ++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-)
meta/recipes-core/initrdscripts/files/init-install-efi.sh +19 -4
@@ -44,9 +44,10 @@ echo "Searching for hard drives ..." # Some eMMC devices have special sub devices such as mmcblk0boot0 etc # we're currently only interested in the root device so pick them wisely -devices=`ls /sys/block/ | grep -v mmcblk` || true +devices=`ls /sys/block/ | grep -v "mmcblk\|md\|dm"` || true mmc_devices=`ls /sys/block/ | grep "mmcblk[0-9]\{1,\}$"` || true -devices="$devices $mmc_devices" +md_devices=`cat /proc/mdstat |grep -w active |awk -F":" '{print $1}'` || true +devices="$devices $mmc_devices $md_devices" for device in $devices; do case $device in
@@ -165,6 +166,14 @@ if [ ! "${device#/dev/mmcblk}" = "${device}" ] || \ rootwait="rootwait" fi +# MD raid device use partition prefix charater 'p' +# and it need a larger capacity to store initrd, +# considering some debug purpose, enlarge it to 1G. +if [ ! "${device#/dev/md}" = "${device}" ]; then + part_prefix="p" + boot_size=1024 +fi + # USB devices also require rootwait if [ -n `readlink /dev/disk/by-id/usb* | grep $TARGET_DEVICE_NAME` ]; then rootwait="rootwait"
@@ -251,8 +260,14 @@ if [ -f /run/media/$1/EFI/BOOT/grub.cfg ]; then # Update grub config for the installed image # Delete the install entry sed -i "/menuentry 'install'/,/^}/d" $GRUBCFG - # Delete the initrd lines - sed -i "/initrd /d" $GRUBCFG + # initrd is necessary to boot from MD device + if [ ! "${device#/dev/md}" = "${device}" ]; then + cp /run/media/$1/initrd /boot + cp /run/media/$1/startup.nsh /boot + else + # Delete the initrd lines + sed -i "/initrd /d" $GRUBCFG + fi # Delete any LABEL= strings sed -i "s/ LABEL=[^ ]*/ /" $GRUBCFG # Replace root= and add additional standard boot options
Signature · 1 line
2.7.4
PATCH 7/8 init-install: fix a typo which will led delete section failed when use sed
In reply to Liwei Songuse sed to delete the install section may failed due to an typo in installer routine.
--- meta/recipes-core/initrdscripts/files/init-install-efi.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
meta/recipes-core/initrdscripts/files/init-install-efi.sh +1 -1
@@ -259,7 +259,7 @@ if [ -f /run/media/$1/EFI/BOOT/grub.cfg ]; then cp /run/media/$1/EFI/BOOT/grub.cfg $GRUBCFG # Update grub config for the installed image # Delete the install entry - sed -i "/menuentry 'install'/,/^}/d" $GRUBCFG + sed -i "/menuentry 'install/,/^}/d" $GRUBCFG # initrd is necessary to boot from MD device if [ ! "${device#/dev/md}" = "${device}" ]; then cp /run/media/$1/initrd /boot
Signature · 1 line
2.7.4
PATCH 8/8 oe-core: add ledmon to support Intel VROC
In reply to Liwei SongThis add ledmon demon to control Intel VROC's SSD disk led.
--- meta/recipes-extended/ledmon/ledmon_git.bb | 32 ++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 meta/recipes-extended/ledmon/ledmon_git.bb
meta/recipes-extended/ledmon/ledmon_git.bb new file +32 -0
@@ -0,0 +1,32 @@ +SUMMARY = "Intel(R) Enclosure LED Utilities" + +DESCRIPTION = "The utilities are designed primarily to be used on storage servers \ + utilizing MD devices (aka Linux Software RAID) for RAID arrays.\ +" +HOMEPAGE = "https://github.com/intel/ledmon" + +LICENSE = "GPLv2" +LIC_FILES_CHKSUM = "file://COPYING;md5=0636e73ff0215e8d672dc4c32c317bb3 \ +" + +DEPENDS = " udev sg3-utils" + +PARALLEL_MAKE = "" + +SRC_URI = "git://github.com/intel/ledmon;branch=master" +SRCREV = "8a5d9526e5666e75625427b85a2586436651e89c" + +COMPATIBLE_HOST = "(i.86|x86_64).*-linux" + +S = "${WORKDIR}/git" +EXTRA_OEMAKE = "CC='${CC}' LDFLAGS='${LDFLAGS}'" + +do_compile() { + oe_runmake SYSROOT="${STAGING_DIR_TARGET}" +} + +do_install() { + oe_runmake install DESTDIR=${D} + cd ${S}/systemd + oe_runmake install DESTDIR=${D} +}
Signature · 1 line
2.7.4
Re: [PATCH 8/8] oe-core: add ledmon to support Intel VROC
Quoted 15 lines · Liwei Song
This add ledmon demon to control Intel VROC's SSD disk led.
Signed-off-by Liwei Song <[email protected]>--- meta/recipes-extended/ledmon/ledmon_git.bb | 32 ++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 meta/recipes-extended/ledmon/ledmon_git.bbmeta/recipes-extended/ledmon/ledmon_git.bb new file +0
-0
meta/recipes-extended/ledmon/ledmon_git.bb line 6
Quoted 6 lines
meta/recipes-extended/ledmon/ledmon_git.bb new file +6
-0@@ -0,0 +1,32 @@ +SUMMARY = "Intel(R) Enclosure LED Utilities" + +DESCRIPTION = "The utilities are designed primarily to be used on storage servers \ + utilizing MD devices (aka Linux Software RAID) for RAID arrays.\ +" +HOMEPAGE = "https://github.com/intel/ledmon"
I'm not sure many of our systems have this. Would this not be more appropriate in meta-intel or in some other layer? it does seem a bit of a specialist use case?
Cheers,
Richard
Re: [PATCH 8/8] oe-core: add ledmon to support Intel VROC
Quoted 18 lines · Richard Purdie
Quoted 17 lines · Liwei Song
This add ledmon demon to control Intel VROC's SSD disk led.
Signed-off-by Liwei Song <[email protected]>--- meta/recipes-extended/ledmon/ledmon_git.bb | 32 ++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 meta/recipes-extended/ledmon/ledmon_git.bbmeta/recipes-extended/ledmon/ledmon_git.bb new file +3
-0@@ -0,0 +1,32 @@ +SUMMARY = "Intel(R) Enclosure LED Utilities" + +DESCRIPTION = "The utilities are designed primarily to be used on storage servers \
Quoted 8 lines
meta/recipes-extended/ledmon/ledmon_git.bb line 6
Quoted 4 lines
meta/recipes-extended/ledmon/ledmon_git.bb new file +3
-0+ utilizing MD devices (aka Linux Software RAID) for RAID arrays.\ +" +HOMEPAGE = "https://github.com/intel/ledmon"I'm not sure many of our systems have this. Would this not be more appropriate in meta-intel or in some other layer? it does seem a bit of a specialist use case?
OK, will try to send it to meta-intel, Thanks for your suggestion.
Liwei.
Quoted 7 lines
Cheers,
Richard