Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1iEx9A-0001WR-8D for mharc-grub-devel@gnu.org; Mon, 30 Sep 2019 10:59:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:58043) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iEx97-0001TQ-Bh for grub-devel@gnu.org; Mon, 30 Sep 2019 10:59:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iEx95-0008J9-Vx for grub-devel@gnu.org; Mon, 30 Sep 2019 10:59:29 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45826) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iEx95-0008IY-My for grub-devel@gnu.org; Mon, 30 Sep 2019 10:59:27 -0400 Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.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 E3BA785542 for ; Mon, 30 Sep 2019 14:59:25 +0000 (UTC) Received: by mail-wm1-f69.google.com with SMTP id k9so6077039wmb.0 for ; Mon, 30 Sep 2019 07:59:25 -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=UJYIGKfsdN3cPS06y/mhIu4V6YSco1mrerrpl1TLRWY=; b=QiGshiA0kxkbpHQgdxbxgEGgpykQzKbMgP5zV4Q/AQCquCmb+o4WVZS78Ox2HAdRbl M0RUgjusJqDWJ8pN5/ExD2NMP8JaK8wv92wny1mjR39bJk2+JlAvvdRM9iJbvzxXQeMJ jEaX30HMBpNFSm01QTrgyWc5ld2MMignh7JYB2AduW+sGfiTyLJ95l53utHG5WNyyFyW CzOdCXM9KwqcHLWPUimq0jjNVK1RPDAd+EYBL/2GfhMfk2nkrUtg1gQLK44yJeVmW2Z8 S8sNlyq0Bpw5I+7p8+VnV/y8PyePTmCqUV7r79+EMdVEG9JgBJf/6+HbJau8nljBlGRm E9Kg== X-Gm-Message-State: APjAAAU+2hQqPJ16pkF+IXH/IDpX+dyjnZdhSGa8pfpOB9mdua7pO6Nq VKpRs4O6OjP6UtcXWVsw/yXuxLZDauiKYSJPIq933Ra2MqYD4aZIrDlwbNPxPV7eUZfcJATqdf5 gwthDa9VUxHo= X-Received: by 2002:adf:ff91:: with SMTP id j17mr13802930wrr.5.1569855564415; Mon, 30 Sep 2019 07:59:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqyUYw473XNP9IKpykV9GhvsH7Wfaz+DiCNbMAhFe1t7ugO/GzfngwairZ5tMZ8yocMO325N+A== X-Received: by 2002:adf:ff91:: with SMTP id j17mr13802912wrr.5.1569855564165; Mon, 30 Sep 2019 07:59:24 -0700 (PDT) Received: from minerva.redhat.com ([90.168.169.92]) by smtp.gmail.com with ESMTPSA id t6sm24243383wmf.8.2019.09.30.07.59.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Sep 2019 07:59:23 -0700 (PDT) From: Javier Martinez Canillas To: grub-devel@gnu.org Cc: Peter Jones , Javier Martinez Canillas , Vladimir Serbinenko , Daniel Kiper Subject: [PATCH v2] Add GRUB_DISABLE_UUID Date: Mon, 30 Sep 2019 16:59:12 +0200 Message-Id: <20190930145912.20375-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: Mon, 30 Sep 2019 14:59:30 -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 --- Changes since v1 (suggested by Daniel Kiper): - 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 5ac61c09d1b..2fe0e1b83bb 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..2537dbca2f9 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 [ "x${GRUB_DISABLE_LINUX_UUID}" !=3D "xfalse" ]; then + GRUB_DISABLE_LINUX_UUID=3D"true" + fi + if [ "x${GRUB_DISABLE_LINUX_PARTUUID}" !=3D "xfalse" ]; 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