1.一般情况
个人编译内核,制作版本后只需要将对应版本放入/boot目录下,然后执行sudo update-grub。 grub2会自动生成配置文件。用户重启系统后,可以根据需要选择登录。
同理,如果需要删除某个版本,只要删除/boot目录下版本文件,然后执行sudo update-grub。 grub2会自动生成配置文件。用户重启系统后,可以根据需要选择登录。
2.个人定制启动菜单
进入/etc/grub.d/目录。执行sudo vi 40_custom
在原文
#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries. Simply type the
# menu entries you want to add after this comment. Be careful not to change
# the 'exec tail' line above.
的基础上,添加
menuentry "External drive (on hd1)" {
insmod part_msdos
insmod fat #注意,对linux格式为insmod ext2
set root='(hd1,msdos1)'
# drivemap -s (hd0) ${root}用于windows系统检测启动
drivemap -s (hd0) ${root}
chainloader +1
}
然后执行sudo update-grub。 grub2会自动生成配置文件。用户重启系统后,可以根据需要选择登录。
如果需要删除原有菜单,那么需要将40_custom 中内容删掉后执行sudo update-grub。需要注意的是,之前将删除前的文件保存为40_custom _add。结果系统执行sudo update-grub时,也扫描了该文件,导致内容没有删除掉。
3,在usb上安装grub2.
根据http://www.pendrivelinux.com/install-grub2-on-usb-from-ubuntu-linux/中的介绍。
将格式好的u盘mount到系统分区。
执行
sudo su
fdisk -l
mount /dev/sdb1 /media/udisk/
grugrub-install --force --no-floppy --root-directory=/media/udisk/ /dev/sdb
注意必须是分区1