Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1kq5UQ-000466-Ed for mharc-grub-devel@gnu.org; Thu, 17 Dec 2020 21:27:30 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:42612) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kq5UO-00045t-Bp for grub-devel@gnu.org; Thu, 17 Dec 2020 21:27:28 -0500 Received: from mail-qk1-x736.google.com ([2607:f8b0:4864:20::736]:46991) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kq5UL-00054b-HD for grub-devel@gnu.org; Thu, 17 Dec 2020 21:27:28 -0500 Received: by mail-qk1-x736.google.com with SMTP id d14so755837qkc.13 for ; Thu, 17 Dec 2020 18:27:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cardoe.com; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=isO317n1q5F/x98y6nNrNLMrm6LECK4sTmWVTwqQdOA=; b=PZJo+wspFajEsZoC/clDDEaiSG1MTGoefulgK+U9BuXphwuMcUEtTukMh+uVSviA7X VPMeN2ZdMZ1G9PzGxX/K+fZR/ttM1oz7R9h7QXVBkShGoGvBqVhuJU5w/HwpoXq7LZEm psYCFlsu+nJvsISv3EBAhLBMxajk8Flq+eDAU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=isO317n1q5F/x98y6nNrNLMrm6LECK4sTmWVTwqQdOA=; b=SA8hXLDhKYW0pa94AyDHsa90uGTLbiTDu3t/DePWe0FKjJifTZAbZoCidXHhfNyo59 nDmFtyUpiigjZQuW0951qXskEVJU0JRTOIzRG+Quk+UR8+MkgoppwgN0+mM0VMkcJ3pt 0BVJYoh5jT8QaxgjD3jlrUChpG3gVZWz0jVYxmJTyCw0ZhhcGObWozlrCo91R6NFDqsc rbnFvawcC6GzyJr1tcVn1DwAfBdXrevlOkxhhoOpInG7tXlLpQiDoZFTQiILh/F6hVf6 MzDf2lXq7X/nOsiAe3PRN1ByVYCa5cAX7JbtSwFKLUjIcrznZy+85S6KRd95Wpk+pj0q Wz6A== X-Gm-Message-State: AOAM530j1d04EG5KzsrhaqNSiojdub7++9xSJu010Hsz20S7sLqDs0uv vRvPxTs8pnAbJUS5oGllpZE1f720R0ym5A== X-Google-Smtp-Source: ABdhPJz6eeCSGp+U5LZL8t+rpDWwN9WpLV0Kn8+AkDgWUG//kwpfDGLFf8882zT+TJN7/lUOpdLQBw== X-Received: by 2002:a05:620a:5eb:: with SMTP id z11mr2441864qkg.411.1608258443790; Thu, 17 Dec 2020 18:27:23 -0800 (PST) Received: from doug-macbook.localdomain ([2600:1700:7b90:52f8:b8d9:c6e1:6c6e:5200]) by smtp.gmail.com with ESMTPSA id z20sm4753498qtb.31.2020.12.17.18.27.22 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 17 Dec 2020 18:27:23 -0800 (PST) From: Doug Goldstein To: grub-devel@gnu.org Cc: Richard Laager , Vladimir Serbinenko , Colin Watson , Doug Goldstein Subject: [PATCH] zfs: fix LINUX_ROOT_DEVICE when grub-probe fails Date: Thu, 17 Dec 2020 20:27:14 -0600 Message-Id: <20201218022714.6329-1-cardoe@cardoe.com> X-Mailer: git-send-email 2.24.3 (Apple Git-128) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2607:f8b0:4864:20::736; envelope-from=cardoe@cardoe.com; helo=mail-qk1-x736.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 18 Dec 2020 02:27:28 -0000 When grub-probe fails, the current code is to just stuff an empty result in which causes the user to not knowingly have a system that no longer boots. grub-probe can fail because the ZFS pool that contains the root filesystem might have features that grub does not yet support which is a common configuration for people with a rpool and a bpool. This behavior uses the zdb utility to dump the same value as the filesystem label would print. Signed-off-by: Doug Goldstein --- util/grub.d/10_linux.in | 2 +- util/grub.d/20_linux_xen.in | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/util/grub.d/10_linux.in b/util/grub.d/10_linux.in index e8b01c0d0..33a25ba8f 100644 --- a/util/grub.d/10_linux.in +++ b/util/grub.d/10_linux.in @@ -71,7 +71,7 @@ case x"$GRUB_FS" in GRUB_CMDLINE_LINUX="rootflags=subvol=${rootsubvol} ${GRUB_CMDLINE_LINUX}" fi;; xzfs) - rpool=`${grub_probe} --device ${GRUB_DEVICE} --target=fs_label 2>/dev/null || true` + rpool=`${grub_probe} --device ${GRUB_DEVICE} --target=fs_label 2>/dev/null || zdb -l ${GRUB_DEVICE} | awk -F \' '/ name/ { print $2 }'` bootfs="`make_system_path_relative_to_its_root / | sed -e "s,@$,,"`" LINUX_ROOT_DEVICE="ZFS=${rpool}${bootfs%/}" ;; diff --git a/util/grub.d/20_linux_xen.in b/util/grub.d/20_linux_xen.in index 3b1f47049..96210c24d 100644 --- a/util/grub.d/20_linux_xen.in +++ b/util/grub.d/20_linux_xen.in @@ -79,7 +79,7 @@ case x"$GRUB_FS" in GRUB_CMDLINE_LINUX="rootflags=subvol=${rootsubvol} ${GRUB_CMDLINE_LINUX}" fi;; xzfs) - rpool=`${grub_probe} --device ${GRUB_DEVICE} --target=fs_label 2>/dev/null || true` + rpool=`${grub_probe} --device ${GRUB_DEVICE} --target=fs_label 2>/dev/null || zdb -l ${GRUB_DEVICE} | awk -F \' '/ name/ { print $2 }'` bootfs="`make_system_path_relative_to_its_root / | sed -e "s,@$,,"`" LINUX_ROOT_DEVICE="ZFS=${rpool}${bootfs%/}" ;; -- 2.24.3 (Apple Git-128)