aboutsummaryrefslogtreecommitdiffstats
path: root/main/mkinitfs
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2019-01-26 21:24:10 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2019-01-26 21:28:20 +0000
commit9d5033df27320084ede522f307a5ac81ea77e547 (patch)
treef1a11bd97b950fdc5757800b23574ca7667a0bd4 /main/mkinitfs
parent1acade4e029334027ca5011b6ccf9f42f245db63 (diff)
downloadaports-9d5033df27320084ede522f307a5ac81ea77e547.tar.bz2
aports-9d5033df27320084ede522f307a5ac81ea77e547.tar.xz
main/mkinitfs: fix zfs root with grub
grub-mkconfig will generate a root=ZFS=pool/path line. Fix nlplug-findfs to deal with search device ZFS=... and fix initramfs to also deal with a missing rootfstype=zfs A side-effect of this is that it is faster to boot zfs root since we no longer need to wait for nlplug-findfs timeout of 5 seconds.
Diffstat (limited to 'main/mkinitfs')
-rw-r--r--main/mkinitfs/0001-nlplug-findfs-detect-zfs-pool.patch63
-rw-r--r--main/mkinitfs/0002-init-fix-root-ZFS.-from-grub.patch59
-rw-r--r--main/mkinitfs/APKBUILD8
3 files changed, 128 insertions, 2 deletions
diff --git a/main/mkinitfs/0001-nlplug-findfs-detect-zfs-pool.patch b/main/mkinitfs/0001-nlplug-findfs-detect-zfs-pool.patch
new file mode 100644
index 0000000000..d7a146f6bd
--- /dev/null
+++ b/main/mkinitfs/0001-nlplug-findfs-detect-zfs-pool.patch
@@ -0,0 +1,63 @@
+From 76530be3c34db2e4fdbe9eefd86384ad5f2f38e2 Mon Sep 17 00:00:00 2001
+From: Natanael Copa <ncopa@alpinelinux.org>
+Date: Fri, 25 Jan 2019 18:15:48 +0000
+Subject: [PATCH 1/2] nlplug-findfs: detect zfs pool
+
+if search device is prefixed with ZFS= then we search for a label with
+the zpool name in the zfs path. For example, if search device is
+"ZFS=tank/alpine/root" then we search for device that is type
+"zfs_member" and label "tank".
+
+This makes it work better with grub which creates a boot cmdline with
+ZFS=
+---
+ nlplug-findfs.c | 16 +++++++++++++++-
+ 1 file changed, 15 insertions(+), 1 deletion(-)
+
+diff --git a/nlplug-findfs.c b/nlplug-findfs.c
+index e037a93..0283161 100644
+--- a/nlplug-findfs.c
++++ b/nlplug-findfs.c
+@@ -961,6 +961,16 @@ static void founddev(struct ueventconf *conf, int found)
+ }
+ }
+
++static int is_zfs_pool(const char *path, const char *label)
++{
++ char pool_name[256];
++ char *p;
++ snprintf(pool_name, sizeof(pool_name), "%s", path);
++ if ((p = strchr(pool_name, '/')))
++ *p = '\0';
++ return strcmp(label, pool_name) == 0 ? FOUND_DEVICE : 0;
++}
++
+ static int searchdev(struct uevent *ev, const char *searchdev, int scanbootmedia)
+ {
+ struct ueventconf *conf = ev->conf;
+@@ -981,10 +991,10 @@ static int searchdev(struct uevent *ev, const char *searchdev, int scanbootmedia
+
+ type = blkid_get_tag_value(conf->blkid_cache, "TYPE", ev->devnode);
+ uuid = blkid_get_tag_value(conf->blkid_cache, "UUID", ev->devnode);
++ label = blkid_get_tag_value(conf->blkid_cache, "LABEL", ev->devnode);
+
+ if (searchdev != NULL) {
+ if (strncmp("LABEL=", searchdev, 6) == 0) {
+- label = blkid_get_tag_value(conf->blkid_cache, "LABEL", ev->devnode);
+ if (label && strcmp(label, searchdev+6) == 0)
+ rc = FOUND_DEVICE;
+ } else if (strncmp("UUID=", searchdev, 5) == 0) {
+@@ -1003,6 +1013,10 @@ static int searchdev(struct uevent *ev, const char *searchdev, int scanbootmedia
+ start_lvm2(ev->devnode);
+ } else if (strcmp("zfs_member", type) == 0) {
+ start_zpool(uuid);
++ if (searchdev != NULL && label != NULL
++ && strncmp("ZFS=", searchdev, 4) == 0) {
++ rc = is_zfs_pool(&searchdev[4], label);
++ }
+ } else if (scanbootmedia) {
+ rc = scandev(conf, ev->devnode, type);
+ }
+--
+2.20.1
+
diff --git a/main/mkinitfs/0002-init-fix-root-ZFS.-from-grub.patch b/main/mkinitfs/0002-init-fix-root-ZFS.-from-grub.patch
new file mode 100644
index 0000000000..5b3fd46eb3
--- /dev/null
+++ b/main/mkinitfs/0002-init-fix-root-ZFS.-from-grub.patch
@@ -0,0 +1,59 @@
+From 61bb69ba80ed8d46429b717ff4e40f5e78f434a0 Mon Sep 17 00:00:00 2001
+From: Natanael Copa <ncopa@alpinelinux.org>
+Date: Fri, 25 Jan 2019 18:32:20 +0000
+Subject: [PATCH 2/2] init: fix root=ZFS... from grub
+
+grub will set root=ZFS=... when root is zfs but will not add rootfstype,
+so make a special case for zfs
+---
+ initramfs-init.in | 16 ++++++++++++----
+ 1 file changed, 12 insertions(+), 4 deletions(-)
+
+diff --git a/initramfs-init.in b/initramfs-init.in
+index 69f917e..252b9ca 100755
+--- a/initramfs-init.in
++++ b/initramfs-init.in
+@@ -401,10 +401,18 @@ if [ "${KOPT_s390x_net%%,*}" = "qeth_l2" ]; then
+ echo 1 > /sys/bus/ccwgroup/drivers/qeth/"${_channel%%,*}"/online
+ fi
+
++# make sure we load zfs module if root=ZFS=...
++rootfstype=${KOPT_rootfstype}
++if [ -z "$rootfstype" ]; then
++ case "$KOPT_root" in
++ ZFS=*) rootfstype=zfs ;;
++ esac
++fi
++
+ # load available drivers to get access to modloop media
+ ebegin "Loading boot drivers"
+
+-modprobe -a $(echo "$KOPT_modules $KOPT_rootfstype" | tr ',' ' ' ) loop squashfs 2> /dev/null
++modprobe -a $(echo "$KOPT_modules $rootfstype" | tr ',' ' ' ) loop squashfs 2> /dev/null
+ if [ -f /etc/modules ] ; then
+ sed 's/\#.*//g' < /etc/modules |
+ while read module args; do
+@@ -454,7 +462,7 @@ if [ -n "$KOPT_root" ]; then
+ nlplug-findfs $cryptopts -p /sbin/mdev ${KOPT_debug_init:+-d} \
+ $KOPT_root
+
+- if echo "$KOPT_modules $KOPT_rootfstype" | grep -qw btrfs; then
++ if echo "$KOPT_modules $rootfstype" | grep -qw btrfs; then
+ /sbin/btrfs device scan >/dev/null || \
+ echo "Failed to scan devices for btrfs filesystem."
+ fi
+@@ -476,9 +484,9 @@ if [ -n "$KOPT_root" ]; then
+ mkdir -p /media/root-rw/work /media/root-rw/root
+ mount -t overlay -o lowerdir=/media/root-ro,upperdir=/media/root-rw/root,workdir=/media/root-rw/work overlayfs $sysroot
+ else
+- mount ${KOPT_rootfstype:+-t} ${KOPT_rootfstype} \
++ mount ${rootfstype:+-t} ${rootfstype} \
+ -o ${KOPT_rootflags:-ro} \
+- $KOPT_root $sysroot
++ ${KOPT_root#ZFS=} $sysroot
+ fi
+
+ eend $?
+--
+2.20.1
+
diff --git a/main/mkinitfs/APKBUILD b/main/mkinitfs/APKBUILD
index 9d8926249b..198d7d696b 100644
--- a/main/mkinitfs/APKBUILD
+++ b/main/mkinitfs/APKBUILD
@@ -2,7 +2,7 @@
pkgname=mkinitfs
pkgver=3.4.0
_ver=${pkgver%_git*}
-pkgrel=1
+pkgrel=2
pkgdesc="Tool to generate initramfs images for Alpine"
url="https://git.alpinelinux.org/cgit/mkinitfs"
arch="all"
@@ -18,6 +18,8 @@ install="$pkgname.pre-upgrade $pkgname.post-install $pkgname.post-upgrade"
triggers="$pkgname.trigger=/usr/share/kernel/*"
source="https://dev.alpinelinux.org/archive/$pkgname/$pkgname-$_ver.tar.xz
0001-features-add-crc32-modules-to-f2fs.patch
+ 0001-nlplug-findfs-detect-zfs-pool.patch
+ 0002-init-fix-root-ZFS.-from-grub.patch
"
builddir="$srcdir/$pkgname-$_ver"
@@ -33,4 +35,6 @@ package() {
}
sha512sums="6c7c1e49e49203f50784e08c8dec9b6bc3bbe5e238d91e85a0a61c09623f6c7b7dfcb490f20e1d6317cbb87287d23e7ef848f1ebf563392cee4b80499676cffc mkinitfs-3.4.0.tar.xz
-00d598c5bbcfc0cc99a43aefae388bb1740e5e6c678c0eca14c3707f81d6378f9385bc15da3cd383e97e4a107adea739bdb1a80c1100f93597dcea37eaf8c6f8 0001-features-add-crc32-modules-to-f2fs.patch"
+00d598c5bbcfc0cc99a43aefae388bb1740e5e6c678c0eca14c3707f81d6378f9385bc15da3cd383e97e4a107adea739bdb1a80c1100f93597dcea37eaf8c6f8 0001-features-add-crc32-modules-to-f2fs.patch
+064ee531edff553f2a1eacba9805d156e3257c87cfacd075f149a318132dd0cc96ff1a7c2766d370b4d4a1c3aa5bb6f6dfb3a76f2696f105df3787ade1f1f73b 0001-nlplug-findfs-detect-zfs-pool.patch
+7ad0a117678b2e7e1a6366db7194525aca3cff04159bba8199feeb5e51399745436e52129d61ad7d48b880dd0a6e6b50d529f0ce2361580ed60e49d9e5b90017 0002-init-fix-root-ZFS.-from-grub.patch"