centos 6.5安裝的UEFI-GPT回退為MBR引導

來源:互聯網
上載者:User

我自己在伺服器上裝了centos 6.5系統,預設用的就是UEFI,沒有注意可以只用GRUB,接著問題就出現了,我在伺服器內安裝了另外一塊帶grub啟動系統的硬碟,

這個硬碟啟動系統後,如果去掉此塊硬碟,再重新啟動,總是識別不出來centos 6.5的UEFI,這個可以通過啟動主板的UEFI,然後用UEFI的命令:

mount fs0fs0:cd EFIcd redhatgrub.efi
檔案夾名稱可能不準,大概是這樣就可以手動啟動系統了,另外還可以通過插入系統硬碟,upgrade一下就可以了,不用每次手動,也不會遺失資料,但是總覺得

這樣不是很好。所以我就有了將UEFI-GPT回退為MBR的想法。

Google總是很牛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 分區。

我進入隨身碟啟動的系統後,把sda1分區掛載到mnt目錄內,發現在efi->redhat目錄內,存在一個檔案grub.conf,相比經常把玩系統的人都知道這個是幹嘛的。就是有了這個,我才有了希望。

下面就是拯救的具體步驟:

1、mount上sda1,然後拷貝出grub.conf留作後用,切忌!然後umount

2、使用fdisk將sda1修改為83-linux,sda2也修改為83-linux,並且把sda1設定為開機磁碟分割。

大致命令流程如下:fdisk /dev/sdat183t283a1
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,卸載硬碟,重新啟動就可以了。



相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.