[root@localhost ~]# df
文件系統(tǒng) 1K-塊 已用 可用 已用% 掛載點
/dev/sda3 19923216 1787736 17123412 10% /
tmpfs 312672 0 312672 0% /dev/shm
/dev/sda1 198337 26359 161738 15% /boot
/dev/sdb1 2071384 68632 1897528 4% /tdisk
[root@localhost ~]#ls /boot/grub/
device.map ffs_stage1_5 jfs_stage1_5 reiserfs_stage1_5 stage2
xfs_stage1_5 e2fs_stage1_5 grub.conf menu.lst splash.xpm.gz
ufs2_stage1_5 fat_stage1_5 iso9660_stage1_5 minix_stage1_5 stage1
vstafs_stage1_5
[root@localhost ~]# grub-install [選項] 設(shè)備文件名
選項:[root@localhost ~]# gmb-install /dev/sda
#因為默認 GRUB 就是安裝到 /dev/sda 中的,所以不需要指定 --root-directory 選項
[root@localhost ~]# grub-install --root-directory=/tdisk/dev/sdb1
#把GRUB安裝至/tdisk分區(qū)
Probing devices to guess BIOS drives. This may take a long time.
Installation finished. No error reported.
This is the contents of the device map/tdisk/boot/ grub/device.map.
Check if this is correct or not. If any of the lines is incorrect,
fix it and re-rnn the script 'grub-install'.
(fd0) /dev/fd0
(hd0) /dev/sda
(hd1) /dev/sdb
#說明安裝的設(shè)備文件名
[root@localhost ~]# ll /tdisk/boot/grub/
總用量272
-rw-r--r--. 1 root root 45 5 月 22 23:51 device.map
-rw-r--r--. 1 root root 13392 5 月 22 23:51 e2fs_stage1_5
-rw-r--r--. 1 root root 12632 5 月 22 23:51 fat_stage1_5
-rw-r--r--. 1 root root 11760 5 月 22 23:51 ffs_stage1_5
-rw-r--r--. 1 root root 11768 5 月 22 23:51 iso9660_stage1_5
-rw-r--r--. 1 root root 13280 5 月 22 23:51 jfs_stage1_5
-rw-r--r--. 1 root root 11968 5 月 22 23:51 minix_stage1_5
-rw-r--r--. 1 root root 14424 5 月 22 23:51 reiserfs_stage1_5
-rw-r--r--. 1 root root 512 5月 22 23:51 stage1
-rw-r--r--. 1 root root 125984 5月 22 23:51 stage2
-rw-r--r--. 1 root root 12036 5 月 22 23:51 ufs2_stage1_5
-rw-r--r--. 1 root root 11376 5 月 22 23:51 vstafs_stage1_5
-rw-r--r--. 1 root root 13976 5 月 22 23:51 xfs_stage1_5
[root@localhost ~]# rpm -ivh /mnt/cdrom/Packages/ grub-0.97-77.el6.i686.rpm
[root@localhost ~]# vi /boot/gmb/grub.conf
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.32-279.el6.i686)
root(hd0,0)
kemel/vmlinuz-2.6.32-279.el6.i686 ro
root=UUID=b9a7a1 a8-767f-4a87-8a2ba535edb362c9 rd_NO_LUKS
KEYBOARDTYPE=pc KEYTABLE=us rd_NO_MD crashkemel=auto
LANG=zh_CN.UTF-8 rd_NO_LVM rd_NO_DM rhgb quiet
initrd/initramfs-2.6.32-279.el6.i686.img title CentOS tdisk #給自己這個啟動分區(qū)起個名字吧
root(hd1,0)
#注意啟動分區(qū)的位置是/dev/sdb1,也就是/tdisk目錄
chainloader +1
#使用當前分區(qū)所在的啟動扇區(qū)啟動系統(tǒng)
[root@localhost boot]# grub
#啟動進入GRUB交互模式
grub> root (hd0,0)
root (hd0,0)
Filesystem type is ext2fs, partition type 0x83
#設(shè)定GRUB的主目錄,這里只能是(hd0,0),因為內(nèi)核和虛擬文件系統(tǒng)安裝在/dev/sdal中,也就是/boot分區(qū)中
grub> find /boot/gnab/stagel
find /boot/grub/stagel (hd1,0)
#查詢一下Stage 1安裝的分區(qū)
#好像有一點問題,我們在/boot和/tdisk分區(qū)中都安裝了GRUB,只看到了/tdisk分區(qū)
grub> find /gcub/stagel
find /grub/stagel (hd0,0)
#只有這樣才能看到/boot分區(qū)中的Stage 1。因為/boot分區(qū)是一個單獨分區(qū)。上面能看到是因為/tdisk才是分區(qū),而/boot/grub/只是/tdisk分區(qū)中的目錄
grub> find /vmlinuz-2.6.32-279.el6.1686
find /vmlinuz-2.6.32-279.el6.i686 (hd0,0)
#能夠查到內(nèi)核位置。注意不能通過/boot/vmlinuz-2.6.32-279.el6.i686查詢,還是因為/boot是單獨分區(qū)。但是這次/tdisk分區(qū)中沒有內(nèi)核
grub> setup (hd1,0)
setup (hd1,0)
Checking if "/boot/grub/stagel" exists... no
Checking if "/grub/stagel" exists... yes
Checking if "/grub/stage2" exists... yes
Checking if "/grub/e2fs_stage1_5" exists... yes
Running "embed /grub/e2fs_stage1_5 (hd1,0)"... failed (this is not fatal)
Running "embed /grub/e2fs_stage1_5 (hd0,0)"... failed (this is not fatal)
Running "install /grub/stagel d (hd1,0) /grub/stage2 p /grub/grub.conf "...
succeeded
Done
#在/tdisk分區(qū)的啟動扇區(qū)中安裝GRUB吧。雖然有兩個failed,但這只是兩個文件系統(tǒng)的Stage 1.5文件沒有安裝,并不影響
grub> quit
#退出GRUB交互界面

sh-4.1#grub
#啟動GRUB交互界面。注意到了嗎?提示符不一樣了,那是因為系統(tǒng)是從光盤啟動的,所以環(huán)境變量沒有生效
gmb>root (hd0.0)
#同樣需要設(shè)置GRUB的主目錄
grub>setup (hd0)
#直接把GRUB安裝到MBR中,所以不需要指定分區(qū)
grub>quit
#退出
新聞熱點
疑難解答
圖片精選