我自己在服務器上裝了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.
人類一思考,上帝就發笑,可是俺思考後發現還是能拯救的,
先提前說明,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,卸載硬盤,重新啓動就可以了。