linux grub set root,grub2的配置文件grub.cfg详解 drivemap -s (hd0) ${root} ,作用相当于grub的map...

注:一般修改/etc/default/grub文件,然后执行sudo update-grub来生成/boot/grub/grub.cfg

grub.cfg 默认为只读,要修改前先设为可写sudo chmod +w /boot/grub/grub.cfg

set default=0

#更改为以下两项可以保存上次的默认启动项# GRUB_DEFAULT=saved

# GRUB_SAVEDEFAULT=true

#默认为0

insmod jpeg#添加jpg支持,如要使用png或tga文件做背景,加上 insmod png或insmod tga

insmod ext2#除了用作启动的分区外,其他分区格式可在menu底下再添加

set root=(hd0,7)#设定root分区

search –no-floppy –fs-uuid –set f255285a-5ad4-4eb8-93f5-4f767190d3b3#设定uuid=****的分区为root,和上句重复,可删除

# 以下为终端配置  if loadfont /usr/share/grub/unicode.pf2 ; then#设置终端字体,unicode.pf2支持中文显示

set gfxmode=640×480

#设置分辨率,默认为 640×480,可用800×600,1024×768,建议跟你想设定的图片大小一致

insmod gfxterm#插入模块 gfxterm,支持中文显 示,它还支持 24 位图像

insmod vbe#插入 vbe 模块,GRUB 2 引入很多模块的东西,要使用它,需要在这里加入

if terminal_output gfxterm ; then true ; else# For backward compatibility with versions of terminal.mod that don’t# understand terminal_outputterminal gfxterm#设置 GRUB 2 终端为 gfxterm

fifiset timeout=10background_image (hd0,7)/boot/images/1.jpg#设置背景图片

### END /etc/grub.d/00_header ###

### BEGIN /etc/grub.d/05_debian_theme ###set menu_color_normal=white/blackset menu_color_highlight=cyan/black#这两行为 Debian 下的菜单颜色设置,如果默认的话,你会发现背景完全被蓝色挡住了,你需要修改 blue 为 black,这样背景就会出现

### END /etc/grub.d/05_debian_theme ###

# 10_linux 为自动添加的当前root分区linux引导项

### BEGIN /etc/grub.d/10_linux ####菜单项,要包括 menuentry 双引号” ” 和大括号 { }才完整,否则不显示菜单

menuentry “Ubuntu, Linux 2.6.31-9-386″ {insmod ext2set root=(hd0,7)search –no-floppy –fs-uuid –set f255285a-5ad4-4eb8-93f5-4f767190d3b3#这句与set root=(hd0,7)重复,可删除

linux /boot/vmlinuz-2.6.31-9-386 root=UUID=f255285a-5ad4-4eb8-93f5-4f767190d3b3 ro quite splash#不喜欢看到一长串的, roo=UUID=***可用root=/dev/sda7代替

initrd /boot/initrd.img-2.6.31-9-386}### END /etc/grub.d/10_linux ###

### BEGIN /etc/grub.d/20_memtest86+ ###menuentry “Memory test (memtest86+)” {linux16 /boot/memtest86+.bin}### END /etc/grub.d/20_memtest86+ ###

# 自动添加存在于其他分区的系统引导项

### BEGIN /etc/grub.d/30_os-prober ####windows 启动菜单  menuentry “Windows Vista (loader) (on /dev/sda1)” {insmod ntfs#windows格式为ntfs,或为fat32改为 insmod fat

set root=(hd0,1)search –no-floppy –fs-uuid –set ece067d2e067a196#可删除  #grub2比较先进的地方就是如果发现windows启动是通过ntldr 引导的,定为2000/xp/2003,会在这加上 drivemap -s (hd0) ${root} ,作用相当于grub的map,可正常启动非第一硬盘的xp/2003系统。

chainloader +1}# 查找到其他分区上的linux系统并自动添加

menuentry “Ubuntu karmic (development branch) (9.10) (on /dev/sda3)” {insmod ext2set root=(hd0,3)search –no-floppy –fs-uuid –set 4d893970-0685-44ed-86b3-1de45b2db84alinux /boot/vmlinuz-2.6.31-9-generic root=/dev/sda3initrd /boot/initrd.img-2.6.31-9-generic}#若存在macos会自动在这里添加。

### END /etc/grub.d/30_os-prober ###

# 以下为手动添加的菜单项  ### BEGIN /etc/grub.d/40_custom ###menuentry “CDLinux”{set root=(hd0,8)linux /CDlinux/bzImage root=/dev/ram0 vga=791 CDL_LANG=zh_CN.UTF-8initrd /CDlinux/initrd}### END /etc/grub.d/40_custom ###

# 手动添加时,硬盘编号从0开始(hd0),主分区编号从1开始(hd0,1),逻辑分区从5开始(hd0,5)

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值