使用 bootadm 命令的 add-entry 子命令向 GRUB 菜单添加带有指定项标题的新项。如果指定项编号,新项将会插入到 GRUB 菜单中的指定位置。或者,如果项编号高于菜单中项的当前编号,此项将作为菜单中的最后一项进行添加。
# bootadm list-menu
# bootadm add-entry -P pool -i [entry-number] entry-title
# bootadm change-entry -i new-entry-number bootfs='pool-name/ROOT/be-name'
通过此步骤,可确保新添加的引导项不使用根池中设置的缺省 bootfs 值,根池在 bootfs pool-level 属性中指定。
# bootadm list-menu
以下示例显示了如何使用 bootadm add-entry 命令向 GRUB 菜单添加菜单项。在此示例中,添加了项编号 2。
# bootadm list-menu The location of the boot loader configuration file is /rpool/boot/grub default 2 console graphics timeout 30 0 Oracle Solaris 11/11 1 Oracle Solaris 11.2 # bootadm add-entry -i 2 Oracle Solaris 11_test # bootadm change-entry -i 2 bootfs='rpool/ROOT/test' # bootadm list-menu The location of the boot loader configuration file is /rpool/boot/grub default 2 console graphics timeout 30 0 Oracle Solaris 11/11 1 Oracle Solaris 11.2 2 Oracle Solaris 11_test
通过指定项编号查看新菜单项的内容,如下所示:
# bootadm list-menu -i 2 the location of the boot loader configuration files is: /rpool/boot/grub title: Oracle Solaris 11_test kernel: /platform/i86pc/kernel/amd64/unix kernel arguments: -B $ZFS-BOOTFS boot archive: /platform/i86pc/amd64/boot_archive ZFS root pool: rpool