From 2050b6227d11ea774784b872eb457be434752af3 Mon Sep 17 00:00:00 2001 From: Adam Gelwarg Date: Mon, 11 Apr 2022 16:18:36 -0400 Subject: [PATCH] Support multipath-boot --- images/00-base/Dockerfile | 2 ++ images/00-base/multipath.conf | 13 +++++++++++++ images/10-kernel-stage1/Dockerfile | 1 + overlay/libexec/k3os/boot | 6 ++++++ overlay/libexec/k3os/mode-disk | 16 ++++++++++++++++ 5 files changed, 38 insertions(+) create mode 100644 images/00-base/multipath.conf diff --git a/images/00-base/Dockerfile b/images/00-base/Dockerfile index 658b0535..a545918c 100644 --- a/images/00-base/Dockerfile +++ b/images/00-base/Dockerfile @@ -71,3 +71,5 @@ RUN apk --no-cache add \ # replicate the default "no idea, friend" behavior of virt-what && touch /usr/sbin/virt-what \ && chmod +x /usr/sbin/virt-what + +COPY multipath.conf /etc/multipath.conf diff --git a/images/00-base/multipath.conf b/images/00-base/multipath.conf new file mode 100644 index 00000000..507df1c7 --- /dev/null +++ b/images/00-base/multipath.conf @@ -0,0 +1,13 @@ +defaults { + find_multipaths "yes" + user_friendly_names "yes" +} +blacklist_exceptions { + property "(SCSI_IDENT_|ID_WWN)" +} +blacklist { + device { + vendor "VMware" + product "Virtual disk" + } +} diff --git a/images/10-kernel-stage1/Dockerfile b/images/10-kernel-stage1/Dockerfile index d079c028..2e475bb6 100644 --- a/images/10-kernel-stage1/Dockerfile +++ b/images/10-kernel-stage1/Dockerfile @@ -10,6 +10,7 @@ RUN apt-get --assume-yes update \ lz4 \ rsync \ xz-utils \ + multipath-tools-boot \ && echo 'r8152' >> /etc/initramfs-tools/modules \ && echo 'hfs' >> /etc/initramfs-tools/modules \ && echo 'hfsplus' >> /etc/initramfs-tools/modules \ diff --git a/overlay/libexec/k3os/boot b/overlay/libexec/k3os/boot index 6f6b257f..d7338a92 100644 --- a/overlay/libexec/k3os/boot +++ b/overlay/libexec/k3os/boot @@ -44,6 +44,12 @@ setup_services() ln -s /etc/init.d/$i /etc/runlevels/sysinit done + if [ "$K3OS_MODE" = "local" ]; then + for i in udev-trigger multipath multipathd; do + ln -s /etc/init.d/$i /etc/runlevels/sysinit + done + fi + for i in acpid hwclock syslog bootmisc hostname sysctl modules connman dbus haveged issue; do ln -s /etc/init.d/$i /etc/runlevels/boot done diff --git a/overlay/libexec/k3os/mode-disk b/overlay/libexec/k3os/mode-disk index f15e2b26..fd295ac3 100644 --- a/overlay/libexec/k3os/mode-disk +++ b/overlay/libexec/k3os/mode-disk @@ -146,6 +146,22 @@ takeover() fi } +### For boot from SAN, we need to ensure that the multipath devices are setup +### while termporarily in mode=disk so that the mount & pivot_root for mode=local +### will be the proper multipath device (rather than a single path) +setup_multipath() +{ + modprobe dm-multipath + udevd -d + udevadm settle + udevadm trigger --type=devices --action=add + udevadm settle + multipath -v3 + udevadm settle + udevadm control --exit +} + +setup_multipath setup_mounts setup_k3os setup_kernel_squashfs