aboutsummaryrefslogtreecommitdiffstats
path: root/main/mkinitfs/0002-init-fix-root-ZFS.-from-grub.patch
blob: 5b3fd46eb3ec5c1229d9a1de429d1742a1d0ccc6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
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