USB Pendrive 上的 GRUB 自定义条目解决方法

USB Pendrive 上的 GRUB 自定义条目解决方法

好吧,我在 USB Pendrive 上安装了 Porteus,我将其分为 3 个分区,第一个分区位于 exFAT(为了兼容旧 Windows),第二个分区位于 ext2,因为它是启动分区,第三个分区包含 Porteus ISO 和数据文件夹。

你可以看到另一个帖子->https://forum.porteus.org/viewtopic.php?f=140&t=10878&p=94752#p94752

好吧,事情是在我的 grub.conf 里面,我把这个解决方法

    if [ "$root" == "hd0,msdos2" ]; then unset root ; root="sda2" ; fi
    if [ "$root" == "hd0,msdos3" ]; then unset root ; root="sda3" ; fi
    if [ "$root" == "hd0,msdos4" ]; then unset root ; root="sda4" ; fi
    if [ "$root" == "hd0,msdos5" ]; then unset root ; root="sda5" ; fi
    if [ "$root" == "hd0,msdos6" ]; then unset root ; root="sda6" ; fi
    if [ "$root" == "hd0,msdos7" ]; then unset root ; root="sda7" ; fi
    if [ "$root" == "hd0,msdos8" ]; then unset root ; root="sda8" ; fi
    if [ "$root" == "hd0,msdos9" ]; then unset root ; root="sda9" ; fi
    if [ "$root" == "hd1,msdos1" ]; then unset root ; root="sdb1" ; fi
    if [ "$root" == "hd1,msdos2" ]; then unset root ; root="sdb2" ; fi
    if [ "$root" == "hd1,msdos3" ]; then unset root ; root="sdb3" ; fi
    if [ "$root" == "hd1,msdos4" ]; then unset root ; root="sdb4" ; fi
    if [ "$root" == "hd1,msdos5" ]; then unset root ; root="sdb5" ; fi
    if [ "$root" == "hd1,msdos6" ]; then unset root ; root="sdb6" ; fi
    if [ "$root" == "hd1,msdos7" ]; then unset root ; root="sdb7" ; fi
    if [ "$root" == "hd1,msdos8" ]; then unset root ; root="sdb8" ; fi
    if [ "$root" == "hd1,msdos9" ]; then unset root ; root="sdb9" ; fi
    if [ "$root" == "hd2,msdos1" ]; then unset root ; root="sdc1" ; fi
    if [ "$root" == "hd2,msdos2" ]; then unset root ; root="sdc2" ; fi
    if [ "$root" == "hd2,msdos3" ]; then unset root ; root="sdc3" ; fi
    if [ "$root" == "hd2,msdos4" ]; then unset root ; root="sdc4" ; fi
    if [ "$root" == "hd2,msdos5" ]; then unset root ; root="sdc5" ; fi
    if [ "$root" == "hd2,msdos6" ]; then unset root ; root="sdc6" ; fi
    if [ "$root" == "hd2,msdos7" ]; then unset root ; root="sdc7" ; fi
    if [ "$root" == "hd2,msdos8" ]; then unset root ; root="sdc8" ; fi
    if [ "$root" == "hd2,msdos9" ]; then unset root ; root="sdc9" ; fi
    if [ "$root" == "hd3,msdos1" ]; then unset root ; root="sdd1" ; fi
    if [ "$root" == "hd3,msdos2" ]; then unset root ; root="sdd2" ; fi
    if [ "$root" == "hd3,msdos3" ]; then unset root ; root="sdd3" ; fi
    if [ "$root" == "hd3,msdos4" ]; then unset root ; root="sdd4" ; fi
    if [ "$root" == "hd3,msdos5" ]; then unset root ; root="sdd5" ; fi
    if [ "$root" == "hd3,msdos6" ]; then unset root ; root="sdd6" ; fi
    if [ "$root" == "hd3,msdos7" ]; then unset root ; root="sdd7" ; fi
    if [ "$root" == "hd3,msdos8" ]; then unset root ; root="sdd8" ; fi
    if [ "$root" == "hd3,msdos9" ]; then unset root ; root="sdd9" ; fi
    if [ "$root" == "hd4,msdos1" ]; then unset root ; root="sde1" ; fi
    if [ "$root" == "hd4,msdos2" ]; then unset root ; root="sde2" ; fi
    if [ "$root" == "hd4,msdos3" ]; then unset root ; root="sde3" ; fi
    if [ "$root" == "hd4,msdos4" ]; then unset root ; root="sde4" ; fi
    if [ "$root" == "hd4,msdos5" ]; then unset root ; root="sde5" ; fi
    if [ "$root" == "hd4,msdos6" ]; then unset root ; root="sde6" ; fi
    if [ "$root" == "hd4,msdos7" ]; then unset root ; root="sde7" ; fi
    if [ "$root" == "hd4,msdos8" ]; then unset root ; root="sde8" ; fi
    if [ "$root" == "hd4,msdos9" ]; then unset root ; root="sde9" ; fi
    if [ "$root" == "hd5,msdos1" ]; then unset root ; root="sdf1" ; fi
    if [ "$root" == "hd5,msdos2" ]; then unset root ; root="sdf2" ; fi
    if [ "$root" == "hd5,msdos3" ]; then unset root ; root="sdf3" ; fi
    if [ "$root" == "hd5,msdos4" ]; then unset root ; root="sdf4" ; fi
    if [ "$root" == "hd5,msdos5" ]; then unset root ; root="sdf5" ; fi
    if [ "$root" == "hd5,msdos6" ]; then unset root ; root="sdf6" ; fi
    if [ "$root" == "hd5,msdos7" ]; then unset root ; root="sdf7" ; fi
    if [ "$root" == "hd5,msdos8" ]; then unset root ; root="sdf8" ; fi
    if [ "$root" == "hd5,msdos9" ]; then unset root ; root="sdf9" ; fi
    if [ "$root" == "hd6,msdos1" ]; then unset root ; root="sdg1" ; fi
    if [ "$root" == "hd6,msdos2" ]; then unset root ; root="sdg2" ; fi
    if [ "$root" == "hd6,msdos3" ]; then unset root ; root="sdg3" ; fi
    if [ "$root" == "hd6,msdos4" ]; then unset root ; root="sdg4" ; fi
    if [ "$root" == "hd6,msdos5" ]; then unset root ; root="sdg5" ; fi
    if [ "$root" == "hd6,msdos6" ]; then unset root ; root="sdg6" ; fi
    if [ "$root" == "hd6,msdos7" ]; then unset root ; root="sdg7" ; fi
    if [ "$root" == "hd6,msdos8" ]; then unset root ; root="sdg8" ; fi
    if [ "$root" == "hd6,msdos9" ]; then unset root ; root="sdg9" ; fi
    if [ "$root" == "hd7,msdos1" ]; then unset root ; root="sdh1" ; fi
    if [ "$root" == "hd7,msdos2" ]; then unset root ; root="sdh2" ; fi
    if [ "$root" == "hd7,msdos3" ]; then unset root ; root="sdh3" ; fi
    if [ "$root" == "hd7,msdos4" ]; then unset root ; root="sdh4" ; fi
    if [ "$root" == "hd7,msdos5" ]; then unset root ; root="sdh5" ; fi
    if [ "$root" == "hd7,msdos6" ]; then unset root ; root="sdh6" ; fi
    if [ "$root" == "hd7,msdos7" ]; then unset root ; root="sdh7" ; fi
    if [ "$root" == "hd7,msdos8" ]; then unset root ; root="sdh8" ; fi
    if [ "$root" == "hd7,msdos9" ]; then unset root ; root="sdh9" ; fi
    if [ "$root" == "hd8,msdos1" ]; then unset root ; root="sdi1" ; fi
    if [ "$root" == "hd8,msdos2" ]; then unset root ; root="sdi2" ; fi
    if [ "$root" == "hd8,msdos3" ]; then unset root ; root="sdi3" ; fi
    if [ "$root" == "hd8,msdos4" ]; then unset root ; root="sdi4" ; fi
    if [ "$root" == "hd8,msdos5" ]; then unset root ; root="sdi5" ; fi
    if [ "$root" == "hd8,msdos6" ]; then unset root ; root="sdi6" ; fi
    if [ "$root" == "hd8,msdos7" ]; then unset root ; root="sdi7" ; fi
    if [ "$root" == "hd8,msdos8" ]; then unset root ; root="sdi8" ; fi
    if [ "$root" == "hd8,msdos9" ]; then unset root ; root="sdi9" ; fi
    if [ "$root" == "hd9,msdos1" ]; then unset root ; root="sdj1" ; fi
    if [ "$root" == "hd9,msdos2" ]; then unset root ; root="sdj2" ; fi
    if [ "$root" == "hd9,msdos3" ]; then unset root ; root="sdj3" ; fi
    if [ "$root" == "hd9,msdos4" ]; then unset root ; root="sdj4" ; fi
    if [ "$root" == "hd9,msdos5" ]; then unset root ; root="sdj5" ; fi
    if [ "$root" == "hd9,msdos6" ]; then unset root ; root="sdj6" ; fi
    if [ "$root" == "hd9,msdos7" ]; then unset root ; root="sdj7" ; fi
    if [ "$root" == "hd9,msdos8" ]; then unset root ; root="sdj8" ; fi
    if [ "$root" == "hd9,msdos9" ]; then unset root ; root="sdj9" ; fi

有人可以告诉我,在 grub 中,这个解决方法是否可以更短,比如使用循环、数组或其他东西?

对于linux曾经的hd“number”(这个数字应该更改为字母,例如0=a,1=b,2=c,...),msdos“number”这个数字没有改变,只是“msdos”这个词在此转换中不得再出现。

我想 grub 与 bash 兼容(但命令较少),有人知道如何在短短几行中完成此操作,我真的不喜欢每行重复几乎相同的内容。

相关内容