我自己在服務器上裝了centos 6.5系統,默認用的就是UEFI,沒有注意可以只用GRUB,接著問題就出現了,我在服務器內安裝了另外一塊帶grub啟動系統的硬盤,
這個硬盤啟動系統后,如果去掉此塊硬盤,再重新啟動,總是識別不出來centos 6.5的UEFI,這個可以通過啟動主板的UEFI,然后用UEFI的命令:
mount fs0
fs0:
cd EFI
cd redhat
grub.efi
文件夾名稱可能不準,大概是這樣就可以手動啟動系統了,另外還可以通過插入系統盤,upgrade一下就可以了,不用每次手動,也不會丟失數據,但是總覺得
這樣不是很好。所以我就有了將UEFI-GPT回退為MBR的想法。
谷歌總是很牛x,所以我得到的結果是用gdisk,我啟動另一個系統,掛載上centos 6.5的硬盤,然后按照google上的步驟:
1
Click "Applications." Point to "Accessories," then click "Terminal." Input the following into Terminal: sudo fdisk -l
2
Press "Enter" to see the disk devices connected to the computer. The device with the asterisk next to it is the boot device. Write down the filename (for example, /dev/sda) assigned to the disk.
3
Input the following into Terminal: sudo apt-get install gdisk. Press "Enter" to install the partitioning tool to Ubuntu.
4
Input "sudo gdisk" into Terminal, then press "Enter" to run gdisk as a superuser. Input the name assigned to the boot device, then press "Enter" again.
5
Press "r," then hit "Enter," to switch to the recovery and transformation options. Press "g," then press "Enter," to select the option to convert GPT to MBR on Linux.
6
Press "w," then press "Enter," to convert GPT to MBR on the primary partitions. Press "y," then "Enter," to finalize and exit.
操作完成后,重啟發現系統起不來,手動引導UEFI也不行了。
人類一思考,上帝就發笑,可是俺思考后發現還是能拯救的,
先提前說明,centos 6.5安裝的時候,是分了三個區的,sda1 -- UEFI所在區,是fat32,sda2 -- 在fdisk -l下顯示是NTFS(但實際上是ext4)的存儲實際系統和數據的分區,
sda3 -- swap 分區。
我進入U盤啟動的系統后,把sda1分區掛載到mnt目錄內,發現在efi->redhat目錄內,存在一個文件grub.conf,相比經常把玩系統的人都知道這個是干嘛的。就是有了這個,我才有了希望。
下面就是拯救的具體步驟:
1、mount上sda1,然后拷貝出grub.conf留作后用,切忌!然后umount
2、使用fdisk將sda1修改為83-linux,sda2也修改為83-linux,并且把sda1設置為啟動分區。
大致命令流程如下: fdisk /dev/sda t 1 83 t 2 83 a 1
3、將sda1做成ext3,因為他是fat32
命令:mkfs.ext3 /dev/sda1
4、mount上sda1和sda2,我這里sda1在/mnt,sda2在/sda2 ,給sda1安裝grub,grub-install --root-directory=/mnt /dev/sda,這樣grub就裝好了
5、 把備份的grub.conf拷貝到/mnt/boot/grub目錄下,并且做一個軟連接,menu.lst指向grub.conf,命令是:ln -s grub.conf menu.lst
6、將/sda2/boot/目錄下在grub.conf內用到的文件,一個是kernel會用到的,一個是initrd會用到的,拷貝到/mnt/boot目錄下
7、修改/mnt/boot/grub/grub.conf,把root (hd0, 1)這個改為root (hd0,0)
8、保存,sync,umount,卸載硬盤,重新啟動就可以了。
新聞熱點
疑難解答