Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1iMpmY-00051X-Bj for mharc-grub-devel@gnu.org; Tue, 22 Oct 2019 04:44:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48204) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iMpmU-0004z9-MZ for grub-devel@gnu.org; Tue, 22 Oct 2019 04:44:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iMpmR-0003jT-GM for grub-devel@gnu.org; Tue, 22 Oct 2019 04:44:41 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59207) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iMpmR-0003ip-7Y for grub-devel@gnu.org; Tue, 22 Oct 2019 04:44:39 -0400 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6758D85543 for ; Tue, 22 Oct 2019 08:44:37 +0000 (UTC) Received: by mail-wr1-f69.google.com with SMTP id c6so8795580wrp.3 for ; Tue, 22 Oct 2019 01:44:37 -0700 (PDT) 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=GoFnrHHVJhz4UMk15maDOnb+3yYx8zh/5RBEzLTdZS4=; b=stAzXIVCa6CR2fVRErIOmIGqKzF9mWZufeR6XS84TMqKNzGg3nRtrPDSUt2ErLoVa7 aNXPD1mLV8WKwGWNMmzwzGKS/WdzPw7H1S5R8ZELGWnEH0e7OYh4Oas+dBlMAjOGJqv+ CNFXqjzw12X4YU7klO6gK35z4uISyhxVQDOqXgds8Ru09C8xkVNN2JD+vpPYtLRaTLnJ 4HqoHByuGYj/g2cJHFEh9Ou5MTEiJn/9b1uXFqLCF1g9dMc6XBr+TCwGR0HYjtkog2/B 3xot0LfoQSECmje4rHAejCOMDO0KMqMYcsyupjpWZBKmCTNvMVmd9f8hKa56p1DqZxQN abaw== X-Gm-Message-State: APjAAAWkdd8OLQ6CErPw1Q4aIL1xXdLMk4oaF5atN6mdDekwBUI9TPE4 OtS0cETpcd6WGLYeooUUQ/nSSQchyf4LV8Cuz8NgE5EjFrasq9em6FDpVdb6+JlFmrus1Dop+Q+ uH0GpVVq9c7Q= X-Received: by 2002:a7b:cd19:: with SMTP id f25mr2010750wmj.154.1571733875639; Tue, 22 Oct 2019 01:44:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqwPtqxeEJzUbfd+cxG/rf11KWFww0dUy11Rl2XwQ+lK9ybY/cq/+kmUPOq3foJfvRy58OY4nQ== X-Received: by 2002:a7b:cd19:: with SMTP id f25mr2010723wmj.154.1571733875355; Tue, 22 Oct 2019 01:44:35 -0700 (PDT) Received: from minerva.redhat.com ([90.168.169.92]) by smtp.gmail.com with ESMTPSA id z9sm17357152wrv.1.2019.10.22.01.44.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Oct 2019 01:44:34 -0700 (PDT) From: Javier Martinez Canillas To: grub-devel@gnu.org Cc: Peter Jones , Javier Martinez Canillas , Daniel Kiper , Vladimir Serbinenko Subject: [PATCH v3] Add GRUB_DISABLE_UUID Date: Tue, 22 Oct 2019 10:44:28 +0200 Message-Id: <20191022084428.5974-1-javierm@redhat.com> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 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: Tue, 22 Oct 2019 08:44:45 -0000 From: Peter Jones The grub-mkconfig and 10_linux scripts by default attempt to use a UUID t= o set the root kernel command line parameter and the $root GRUB environment variable. The former can be disabled by setting the GRUB_DISABLE_LINUX_UUID variabl= e to "true", but there is currently no way to disable the latter. The generated grub config uses the search command with the --fs-uuid opti= on to find the device that has to be set as $root, i.e: search --no-floppy --fs-uuid --set=3Droot ... This is usually more reliable but in some cases it may not be appropriate= , so this patch introduces a new GRUB_DISABLE_UUID variable that can be use= d to disable searching for the $root device by filesystem UUID. When disabled, the $root device will be set to the value specified in the device.map as found by the grub-probe --target=3Dcompatibility_hint optio= n. When setting GRUB_DISABLE_UUID=3Dtrue, the GRUB_DISABLE_LINUX_UUID and GRUB_DISABLE_LINUX_PARTUUID variables will also be set to "true" unless these have been explicitly set to "false". That way, the GRUB_DISABLE_UUID variable can be used to force using the device names for both GRUB and Linux. Signed-off-by: Peter Jones Signed-off-by: Javier Martinez Canillas Reviewed-by: Daniel Kiper --- Changes in v3: - Make the patch more consistent with the logic in commit 51be3372ec8 ("templates: Update grub script template files"). - Add Reviewed-by tag from Daniel Kiper. Changes in v2: - Explain better in the commit message why the GRUB_DISABLE_UUID variable is needed and the difference with the existing GRUB_DISABLE_LINUX_UUID/ GRUB_DISABLE_LINUX_PARTUUID variables. - Remove logic that disabled setting the root cmdline param to either the filesystem UUID or partition UUID and instead use the existing variable= s to disable this. docs/grub.texi | 9 +++++++++ util/grub-mkconfig.in | 10 ++++++++++ util/grub-mkconfig_lib.in | 4 ++-- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/docs/grub.texi b/docs/grub.texi index d788efe440f..c25ab7a5fe7 100644 --- a/docs/grub.texi +++ b/docs/grub.texi @@ -1441,6 +1441,15 @@ enable the use of partition UUIDs, set this option= to @samp{false}. If this option is set to @samp{true}, disable the generation of recovery mode menu entries. =20 +@item GRUB_DISABLE_UUID +Normally, @command{grub-mkconfig} will generate menu entries that use +universally-unique identifiers (UUIDs) to identify various filesystems t= o +search for files. This is usually more reliable, but in some cases it m= ay +not be appropriate. To disable this use of UUIDs, set this option to +@samp{true}. Setting this option to @samp{true}, will also set the optio= ns +@samp{GRUB_DISABLE_LINUX_UUID} and @samp{GRUB_DISABLE_LINUX_PARTUUID} to +@samp{true}, unless they have been explicilty set to @samp{false}. + @item GRUB_VIDEO_BACKEND If graphical video support is required, either because the @samp{gfxterm= } graphical terminal is in use or because @samp{GRUB_GFXPAYLOAD_LINUX} is = set, diff --git a/util/grub-mkconfig.in b/util/grub-mkconfig.in index a6ce375ed18..fb7fd4902f4 100644 --- a/util/grub-mkconfig.in +++ b/util/grub-mkconfig.in @@ -158,6 +158,15 @@ if test -f ${sysconfdir}/default/grub ; then . ${sysconfdir}/default/grub fi =20 +if [ "x${GRUB_DISABLE_UUID}" =3D "xtrue" ]; then + if [ -z "${GRUB_DISABLE_LINUX_UUID}" ]; then + GRUB_DISABLE_LINUX_UUID=3D"true" + fi + if [ -z "${GRUB_DISABLE_LINUX_PARTUUID}" ]; then + GRUB_DISABLE_LINUX_PARTUUID=3D"true" + fi +fi + # XXX: should this be deprecated at some point? if [ "x${GRUB_TERMINAL}" !=3D "x" ] ; then GRUB_TERMINAL_INPUT=3D"${GRUB_TERMINAL}" @@ -227,6 +236,7 @@ export GRUB_DEFAULT \ GRUB_DISABLE_LINUX_UUID \ GRUB_DISABLE_LINUX_PARTUUID \ GRUB_DISABLE_RECOVERY \ + GRUB_DISABLE_UUID \ GRUB_VIDEO_BACKEND \ GRUB_GFXMODE \ GRUB_BACKGROUND \ diff --git a/util/grub-mkconfig_lib.in b/util/grub-mkconfig_lib.in index 0f801cab3e4..3e12b2c0e6a 100644 --- a/util/grub-mkconfig_lib.in +++ b/util/grub-mkconfig_lib.in @@ -156,7 +156,7 @@ prepare_grub_to_access_device () if [ "x$fs_hint" !=3D x ]; then echo "set root=3D'$fs_hint'" fi - if fs_uuid=3D"`"${grub_probe}" --device $@ --target=3Dfs_uuid 2> /dev/= null`" ; then + if [ "x${GRUB_DISABLE_UUID}" !=3D "xtrue" ] && fs_uuid=3D"`"${grub_pro= be}" --device $@ --target=3Dfs_uuid 2> /dev/null`" ; then hints=3D"`"${grub_probe}" --device $@ --target=3Dhints_string 2> /de= v/null`" || hints=3D echo "if [ x\$feature_platform_search_hint =3D xy ]; then" echo " search --no-floppy --fs-uuid --set=3Droot ${hints} ${fs_uuid= }" @@ -173,7 +173,7 @@ grub_get_device_id () IFS=3D' ' device=3D"$1" - if fs_uuid=3D"`"${grub_probe}" --device ${device} --target=3Dfs_uuid 2= > /dev/null`" ; then + if [ "x${GRUB_DISABLE_UUID}" !=3D "xtrue" ] && fs_uuid=3D"`"${grub_pro= be}" --device ${device} --target=3Dfs_uuid 2> /dev/null`" ; then echo "$fs_uuid"; else echo $device |sed 's, ,_,g' --=20 2.21.0