From e914ed950de9429260189976e5d4f1a30d0148d5 Mon Sep 17 00:00:00 2001 From: Guohan Lu Date: Sat, 18 Apr 2020 12:22:47 +0000 Subject: [PATCH 1/2] [grub]: use UUID for root partition Signed-off-by: Guohan Lu --- installer/x86_64/install.sh | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/installer/x86_64/install.sh b/installer/x86_64/install.sh index d0aa7818df9b..997813b6f858 100755 --- a/installer/x86_64/install.sh +++ b/installer/x86_64/install.sh @@ -583,19 +583,20 @@ EOF $onie_root_dir/tools/bin/onie-boot-mode -q -o install fi -# Add a menu entry for the DEMO OS +# Add a menu entry for the SONiC OS # Note: assume that apparmor is supported in the kernel demo_grub_entry="$demo_volume_revision_label" if [ "$install_env" = "sonic" ]; then old_sonic_menuentry=$(cat /host/grub/grub.cfg | sed "/$running_sonic_revision/,/}/!d") - demo_dev=$(echo $old_sonic_menuentry | sed -e "s/.*root\=\(.*\)rw.*/\1/") + grub_cfg_root=$(echo $old_sonic_menuentry | sed -e "s/.*root\=\(.*\)rw.*/\1/") onie_menuentry=$(cat /host/grub/grub.cfg | sed "/menuentry ONIE/,/}/!d") -fi - -if [ "$install_env" = "build" ]; then +elif [ "$install_env" = "build" ]; then grub_cfg_root=%%SONIC_ROOT%% else - grub_cfg_root=$demo_dev + grub_cfg_root=$(blkid "$demo_dev" | grep -oE "[[:blank:]]UUID=\".*\"" | sed s/\"//g | sed s/\ //g) + if [ -z "$grub_cfg_root" ]; then + grub_cfg_root=$demo_dev + fi fi cat <> $grub_cfg From a85e71738642f3546755ccc3e5cd200caab6a333 Mon Sep 17 00:00:00 2001 From: Guohan Lu Date: Sun, 19 Apr 2020 00:39:11 +0000 Subject: [PATCH 2/2] simplify the uuid extraction with sed Signed-off-by: Guohan Lu --- installer/x86_64/install.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/installer/x86_64/install.sh b/installer/x86_64/install.sh index 997813b6f858..6a347c78db73 100755 --- a/installer/x86_64/install.sh +++ b/installer/x86_64/install.sh @@ -592,10 +592,12 @@ if [ "$install_env" = "sonic" ]; then onie_menuentry=$(cat /host/grub/grub.cfg | sed "/menuentry ONIE/,/}/!d") elif [ "$install_env" = "build" ]; then grub_cfg_root=%%SONIC_ROOT%% -else - grub_cfg_root=$(blkid "$demo_dev" | grep -oE "[[:blank:]]UUID=\".*\"" | sed s/\"//g | sed s/\ //g) - if [ -z "$grub_cfg_root" ]; then +else # install_env = "onie" + uuid=$(blkid "$demo_dev" | sed -ne 's/.* UUID=\"\([^"]*\)\".*/\1/p') + if [ -z "$uuid" ]; then grub_cfg_root=$demo_dev + else + grub_cfg_root=UUID=$uuid fi fi