修改Linux默認(rèn)啟動(dòng)系統(tǒng)的方法之一
如何修改 grub 以更改Linux默認(rèn)啟動(dòng)系統(tǒng)網(wǎng)上的說法主要有兩種,分別是修改兩個(gè)文件:/boot/grub/grub.conf or /boot/grub/menu.lst也有說是 /etc 目錄下的相應(yīng)文件的。這里介紹一下我的嘗試。
在 Ubuntu-9.10 下面,具體文件是這樣地:
/boot/grub/grub.cfg
至于更改的那個(gè) set default=”x“, 那個(gè)x的意思,就拿我機(jī)器作為例子來說:
- [eg].> ls -l grub.cfg-r--r--r-- grub.cfg
- > sudo chmod 244 grub.cfg> ls -l grub.cfg--w-r--r-- grub.cfg
- > sudo vim grub.cfg
修改之后,最后別忘了:> sudo chmod 444 grub.cfg // 一定記得要改回來.
我暈,用過一段時(shí)間后竟然有這么多東西,那么就用彩色來突出一下重點(diǎn)吧,其他內(nèi)容請(qǐng)自動(dòng)跳過。如藍(lán)色部分所示,grub里面一共分為這么幾個(gè)部分,一般三個(gè)。再如紅色部分所示,也就是 menuentry 項(xiàng),所以 menuentry 項(xiàng)按順序從 0 開始排列,如果想讓哪個(gè)成為L(zhǎng)inux默認(rèn)啟動(dòng)系統(tǒng),就將 set default=“x” 中的 x 改為那個(gè) entry 的編號(hào)。eg,如果我的電腦想默認(rèn)進(jìn) windows (雖然這是沒門的事),就另 x 為 8. 體現(xiàn)為啟動(dòng)時(shí)到選擇啟動(dòng)系統(tǒng)時(shí)光標(biāo)默認(rèn)定位在 windows 系統(tǒng)入口上。
至于將 windows 系統(tǒng)不僅設(shè)置為L(zhǎng)inux默認(rèn)啟動(dòng)系統(tǒng), 而且要放在所有系統(tǒng)入口最頂端,還沒試過。只是根據(jù)這個(gè)文件猜測(cè):是不是將這個(gè)文件的 windows 的那個(gè) menuentry 剪切到最前面就行? 使其 entry 編號(hào)為 0... 這個(gè)猜測(cè)暫不確定。
- -------------------------------------- grub.cfg, start ---------------------------------#
- # DO NOT EDIT THIS FILE
- #
- # It is automatically generated by /usr/sbin/grub-mkconfig using templates
- # from /etc/grub.d and settings from /etc/default/grub
- #
- ### BEGIN /etc/grub.d/00_header ###
- if [ -s /boot/grub/grubenv ]; then
- have_grubenv=true
- load_env
- fi
- set default="0"
- if [ ${prev_saved_entry} ]; then
- saved_entry=${prev_saved_entry}
- save_env saved_entry
- prev_saved_entry=
- save_env prev_saved_entry
- fi
- insmod ext2
- set root=(hd0,8)
- search --no-floppy --fs-uuid --set ab1eac76-a5d7-4656-8918-ffb406010912
- if loadfont /usr/share/grub/unicode.pf2 ; then
- set gfxmode=640x480
- insmod gfxterm
- insmod vbe if terminal_output gfxterm ; then true ; else # For backward compatibility with versions of terminal.mod that don't # understand terminal_output terminal gfxterm fifiif [ ${recordfail} = 1 ]; then set timeout=-1else set timeout=10fi### END /etc/grub.d/00_header ###
- ### BEGIN /etc/grub.d/05_debian_theme ###set menu_color_normal=white/blackset menu_color_highlight=black/white### END /etc/grub.d/05_debian_theme ###
- ### BEGIN /etc/grub.d/10_linux ###menuentry "Ubuntu, Linux 2.6.31-18-generic" { // 0 recordfail=1 if [ -n ${have_grubenv} ]; then save_env recordfail; fi set quiet=1 insmod ext2 set root=(hd0,8) search --no-floppy --fs-uuid --set ab1eac76-a5d7-4656-8918-ffb406010912 linux /boot/vmlinuz-2.6.31-18-generic root=UUID=ab1eac76-a5d7-4656-8918-ffb406010912 ro quiet splash initrd /boot/initrd.img-2.6.31-18-generic}menuentry "Ubuntu, Linux 2.6.31-18-generic (recovery mode)" { // 1 recordfail=1 if [ -n ${have_grubenv} ]; then save_env recordfail; fi insmod ext2 set root=(hd0,8) search --no-floppy --fs-uuid --set ab1eac76-a5d7-4656-8918-ffb406010912 linux /boot/vmlinuz-2.6.31-18-generic root=UUID=ab1eac76-a5d7-4656-8918-ffb406010912 ro single initrd /boot/initrd.img-2.6.31-18-generic}menuentry "Ubuntu, Linux 2.6.31-17-generic" { // 2 recordfail=1 if [ -n ${have_grubenv} ]; then save_env recordfail; fi set quiet=1 insmod ext2 set root=(hd0,8) search --no-floppy --fs-uuid --set ab1eac76-a5d7-4656-8918-ffb406010912 linux /boot/vmlinuz-2.6.31-17-generic root=UUID=ab1eac76-a5d7-4656-8918-ffb406010912 ro quiet splash initrd /boot/initrd.img-2.6.31-17-generic}menuentry "Ubuntu, Linux 2.6.31-17-generic (recovery mode)" { // 3 recordfail=1 if [ -n ${have_grubenv} ]; then save_env recordfail; fi insmod ext2 set root=(hd0,8) search --no-floppy --fs-uuid --set ab1eac76-a5d7-4656-8918-ffb406010912 linux /boot/vmlinuz-2.6.31-17-generic root=UUID=ab1eac76-a5d7-4656-8918-ffb406010912 ro single initrd /boot/initrd.img-2.6.31-17-generic}menuentry "Ubuntu, Linux 2.6.31-14-generic" { // 4 recordfail=1 if [ -n ${have_grubenv} ]; then save_env recordfail; fi set quiet=1 insmod ext2 set root=(hd0,8) search --no-floppy --fs-uuid --set ab1eac76-a5d7-4656-8918-ffb406010912 linux /boot/vmlinuz-2.6.31-14-generic root=UUID=ab1eac76-a5d7-4656-8918-ffb406010912 ro quiet splash splash initrd /boot/initrd.img-2.6.31-14-generic}menuentry "Ubuntu, Linux 2.6.31-14-generic (recovery mode)" { // 5 recordfail=1 if [ -n ${have_grubenv} ]; then save_env recordfail; fi insmod ext2 set root=(hd0,8) search --no-floppy --fs-uuid --set ab1eac76-a5d7-4656-8918-ffb406010912 linux /boot/vmlinuz-2.6.31-14-generic root=UUID=ab1eac76-a5d7-4656-8918-ffb406010912 ro single initrd /boot/initrd.img-2.6.31-14-generic}### END /etc/grub.d/10_linux ###
- ### BEGIN /etc/grub.d/20_memtest86+ ###menuentry "Memory test (memtest86+)" { // 6 linux16 /boot/memtest86+.bin}menuentry "Memory test (memtest86+, serial console 115200)" { // 7 linux16 /boot/memtest86+.bin console=ttyS0,115200n8}### END /etc/grub.d/20_memtest86+ ###### BEGIN /etc/grub.d/30_os-prober ###menuentry "Microsoft Windows XP Professional (on /dev/sda1)" { // 8 insmod ntfs set root=(hd0,1) search --no-floppy --fs-uuid --set 6044685444682f4a drivemap -s (hd0) ${root} chainloader +1}### END /etc/grub.d/30_os-prober ###
- ### BEGIN /etc/grub.d/40_custom #### 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.### END /etc/grub.d/40_custom ###
- --------------------------------- grub.cfg, end ---------------------------------------------
以上是用grub修改Linux默認(rèn)啟動(dòng)系統(tǒng)的一種嘗試。
【編輯推薦】