Skip to contentSkip to conversation

Cope with / being on a ZFS root dataset

PATCH In review Colin Watson 2 participants 2 messages Oct 29, 2018 – Oct 31, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Cope with / being on a ZFS root dataset

If / is on the root dataset in a ZFS pool, then ${bootfs} will be set to "/" (whereas if it is on a non-root dataset, there will be no trailing slash). Passing "root=ZFS=${rpool}/" will fail to boot, but "root=ZFS=${rpool}" works fine, so strip the trailing slash.

---
 util/grub.d/10_linux.in     | 2 +-
 util/grub.d/20_linux_xen.in | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
util/grub.d/10_linux.in +1 -1
index 61ebd7dc7..4532266be 100644
@@ -73,7 +73,7 @@ case x"$GRUB_FS" in
     xzfs)
 	rpool=`${grub_probe} --device ${GRUB_DEVICE} --target=fs_label 2>/dev/null || true`
 	bootfs="`make_system_path_relative_to_its_root / | sed -e "s,@$,,"`"
-	LINUX_ROOT_DEVICE="ZFS=${rpool}${bootfs}"
+	LINUX_ROOT_DEVICE="ZFS=${rpool}${bootfs%/}"
 	;;
 esac
 
util/grub.d/20_linux_xen.in +1 -1
index e8143b079..d22626e30 100644
@@ -81,7 +81,7 @@ case x"$GRUB_FS" in
     xzfs)
 	rpool=`${grub_probe} --device ${GRUB_DEVICE} --target=fs_label 2>/dev/null || true`
 	bootfs="`make_system_path_relative_to_its_root / | sed -e "s,@$,,"`"
-	LINUX_ROOT_DEVICE="ZFS=${rpool}${bootfs}"
+	LINUX_ROOT_DEVICE="ZFS=${rpool}${bootfs%/}"
 	;;
 esac
 
Signature · 1 line
2.19.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 8 lines · Colin Watson

If / is on the root dataset in a ZFS pool, then ${bootfs} will be set to "/" (whereas if it is on a non-root dataset, there will be no trailing slash). Passing "root=ZFS=${rpool}/" will fail to boot, but "root=ZFS=${rpool}" works fine, so strip the trailing slash.

Daniel