重新安裝windows後修複ubuntu啟動

來源:互聯網
上載者:User
UbuntuHelp:RecoveringUbuntuAfterInstallingWindows/zh出自Ubuntu中文

本條目正在從其他語言的文檔內容翻譯
成中文。


歡迎您積极參与翻譯與修訂

文章出處:
 

http://wiki.ubuntu.org.cn/UbuntuHelp:RecoveringUbuntuAfterInstallingWindows

翻譯人員:
 

聶海波

點擊翻譯
:

 

English

 • 中文


 

目錄

[隱藏
]

  • 1
    使用Ubuntu Desktop/Live CD

    • 1.1
      Using the Desktop/LiveCD while
      preserving Windows Bootloader

    • 1.2
      使用LiveCD重建GRUB

    • 1.3
      使用Desktop/LiveCD ,改寫Windows
      bootloader

    • 1.4
      不使用 Ubuntu Desktop/Live
      CD
  • 2
    使用非官方的 "Super Grub Disk"

  • 3
    發現並修理故障

    • 3.1
      準備你的工作環境

      • 3.1.1
        自動回復 GRUB

      • 3.1.2
        手工恢複GRUB

      • 3.1.3
        配置GRUB菜單

  • 4
    使用 Ubuntu Alternate/Install
    CD

    • 4.1
      使用Alternate/Install CD改寫Windows
      bootloader
  • 5
    GRUB資源

[編輯
]

使用Ubuntu Desktop/Live CD

請選擇下列選項之一:

[編輯
]

Using the Desktop/LiveCD while preserving Windows
Bootloader

[編輯
]

使用LiveCD重建GRUB

不要忘記如下方法:在硬碟引導分區上,用GRUB替代MBR(主引導紀錄)。這適用於大多數人,除非你有了另外一個可用的引導程式。

另一方面,如果你用Boot Magic or System Commander,你讀到的命令將改寫你所做的。

如果你已在引導分區安裝GRUB替換了MBR,命令將會有所不同。下面是我的建議:

如何在Ghost後恢複Grub:
(譯者註:適用於重新安裝windows而導致丟失GRUB,我用過使用Ghost軟體和GHO鏡像恢複windows系統,不會映像grub的。)

1.用Live CD引導系統,例如Ubuntu Live, Knoppix, Mepis, or similar.

2.開啟終端。開啟根終端(用在非Ubuntu光碟片中用“su",在Ubuntu光碟片中用"sudo -i)。密碼是必須的。

3.輸入"grub" 。

4.輸入"find /boot/grub/stage1"。你會看到像"(hd0)"
的資訊(我的是(hd0,3)")。在下面的操作中,使用你的電腦顯示的資訊。 (譯者註:如果是boot單獨分區的,需要改為"find
/grub/stage1")

5.輸入"root (hd0,3)"。(譯註:以下資訊以原作者的為例,自己當改成所看到的)

6.輸入"setup (hd0,3)".
這是關鍵。如果你想將GRUB寫入MBR,可以用其他的操作,如輸入"(hd0)"。如果你想將它寫入你的linux引導分區,可以在逗號後寫入數,如"(hd0,3)"。

7.輸入"quit".

8.重啟系統。取走引導CD。

來自:http://ubuntuforums.org/showpost.php?p=121355&postcount=5

[編輯
]

使用Desktop/LiveCD ,改寫Windows bootloader

用Live CD引導,開啟終端。當需要root許可權使用一些命令時,可以使用sudo -i

來獲得root命令列,用此可以正規地代替使用sudo
。此時要特別小心,尤其是要注意打字錯誤。

我們要找到Ubuntu系統安在哪個分區。輸入命令fdisk -l
。將返回你所有分區列表,例如:

$ sudo fdisk -l

Disk /dev/hda: 120.0 GB, 120034123776 bytes
255 heads, 63 sectors/track, 14593 cylinders
Units == cylinders of 16065 * 512 == 8225280 bytes

Device Boot Start End Blocks Id System
/dev/hda1 1 8 64228+ 83 Linux
/dev/hda2 9 1224 9767520 83 Linux
/dev/hda3 * 1225 2440 9767520 a5 FreeBSD
/dev/hda4 2441 14593 97618972+ 5 Extended
/dev/hda5 14532 14593 498015 82 Linux swap / Solaris
/dev/hda6 2441 14530 97112862 83 Linux

Partition table entries are not in disk order

這裡,我有三個Linux分區./dev/hda2 是我的根分區,/dev/hda1是我的/boot 分區,dev/hda6 是我的
/home分區.如果你只有一個,顯然就是你的Ubuntu系統安裝分區.你還有更多的分區,而你不知道哪個是你的Ubuntu系統安裝分區,可以稍後再尋找.首先,為你的分區建立一個掛載點,例如:

mkdir /mnt/root

然後掛載你的分區.如果你不知道哪一個是,就每一個都掛載一次,直到找到正確的為止.

mount -t ext3 /dev/hda2 /mnt/root

當然,用你的正確分區名稱替換掉這裡的/dev/hda2.可以用ls /mnt/root
來核實是否是正確的,可能會顯示如下資訊:

bin    dev      home        lib    mnt   root     srv  usr
boot etc initrd lib64 opt sbin sys var
cdrom initrd.img media proc selinux tmp vmlinuz

如果不是像這樣的,則說明沒有掛載正確的分區.使用umount /mnt/root

來卸載掉分區,再試試另一個.你可能需要掛載你的/boot分區,例如:

mount -t ext3 /dev/hda1 /mnt/root/boot

確信掛載正確,用ls /mnt/root/boot
驗證,會返回如下資訊:

config-2.6.18-3-686      initrd.img-2.6.18-3-686.bak  System.map-2.6.18-3-686
grub lost+found vmlinuz-2.6.18-3-686
initrd.img-2.6.18-3-686 memtest86+.bin

再次說明,如果仍然不符合,卸載掉並載入另一個分區.

現在都掛載了,我們要重新安裝GRUB:

grub-install --root-directory=/mnt/root /dev/hda

如果你得到BIOS警告,試試:

grub-install --root-directory=/mnt/root /dev/hda -recheck

當然,用你自己想安裝GRUB的位置替換/dev/hda.如果一切成功,將會看到如下資訊:

Installation finished. No error reported.
This is the contents of the device map /boot/grub/device.map.
Check if this is correct or not. If any of the lines is incorrect,
fix it and re-run the script `grub-install'.

(hd0) /dev/hda

現在你可以重啟,GRUB菜單將會出現.如果有一個XFS檔案系統的相關警告,可以忽略.

[編輯
]

不使用 Ubuntu Desktop/Live CD

你可能不使用Ubuntu Desktop/Live
CD,而是從你的安裝光碟片來使用"grub".想要這樣做,掛載你的分區(下面的例子假定root分區在hda1):

sudo mkdir /mnt/linux
sudo mount /dev/hda1 /mnt/linux

接著改路徑為你的安裝sbin,並從那裡運行grub

cd /mnt/linux/sbin
sudo ./grub

[編輯
]

使用非官方的 "Super Grub Disk"

  • 下載 Super Grub Disk

  • 燒錄光碟片 (建議)或拷入磁碟片
  • 啟動
  • 選擇:語言
  • 選擇: Linux
  • 選擇: 修複 Boot of Linux (GRUB)
  • 選擇你想恢複的Linux或Grub安裝.
  • 你會看到資訊: SGD 已安好!
  • 重啟
  • 成功.

[編輯
]

發現並修理故障

這部分內容將:

  • 在Ubuntu安裝後才安裝Windows的雙啟動設定
  • Windows必須重新安裝
  • Windows恢複技術牽扯到MBR
  • GRUB安裝失敗的其他情形

前提:

  • 你的Ubuntu分區仍然完整
  • 你有一個LiveCD,如Ubuntu Desktop CD,或者其他替代品
  • 你對用LiveCD足夠熟悉,可以獲得支援
  • 你還記得你的安裝分區(列印`/etc/fstab` 是個好方法,這樣你可以使用fdisk -l /dev/hda)
  • 如果使用非Ubuntu核心或是建立自己的核心,要知道核心工作的知識(特別是關於initrd)
  • 你的核心版本;這取決於2.6.10-5-386

[編輯
]

準備你的工作環境

開始恢複程式,插入liveCD,重啟電腦.直至你的LiveCD啟動到看到介面.如果你的LiveCD沒有立即出現控制台,就用終端.用Ubuntu
LiveCD,點 應用程式-系統工具- 終端.

注意
: 因為這是LiveCD環境,
任何對使用者帳戶或檔案系統的改變不會保持.這意味著你可以設定一個臨時的根密碼,建立目錄,而不會影響你的實際安裝.

現在你要獲得根許可權.在Ubuntu下,可以用下面的命令:

sudo -i

在Knoppix下,下面的命令就足夠了,並不要密碼:

su -

現在,你有了根許可權,掛載你有啟動引導檔案的分區.

你得訪問`/sbin/`和/boot/` 目錄.如果在`fstab`中有一個`/boot/`列表,須掛載兩個分區.

開始為工作環境建立一個掛載點-得注意同時建立一個目錄.

mkdir /mnt/work

如果須掛載`/boot/`,使用下面的命令.

mkdir /mnt/work/boot

現在可以裝載檔案系統資料.複查`fstab`,確信`/`和`/boot/`;就像`/dev/hda3`
和`/dev/hda4`,這裡字母a和數字3與4可能不同.

注意
:`/dev/hda3` and `/dev/hda4`是假定的,必須換成你自己的.

鍵入以下命令來裝載你的檔案系統,一些GRUB資訊是可能要用的.

mount /dev/hda4 /mnt/work
mount -o bind /dev /mnt/work/dev
mount -o bind /proc /mnt/work/proc
cp /proc/mounts /mnt/work/etc/mtab

現在,你進入你的工作環境.下面命令得小心了.

chroot /mnt/work/ /bin/bash

""警告"":從這時起,任何改變會影響到你的Ubuntu系統.你已離開LiveCD的安全模式.特別要注意.

[編輯
]

自動回復 GRUB

如果你有獨立的/boot分區,用下面的命令:

sudo mount /dev/hda3 /boot/

從這裡起重新安裝GRUB是比較容易的.僅需使用下列命令:

sudo /sbin/grub-install /dev/hda

如果上述命令不能使用,很不幸,得手工配置GRUB(這並不難);如果成功,在最後一節會顯示:"Configuring the GRUB Menu".

[編輯
]

手工恢複GRUB

如果您覺得下面寫得又長又煩,可以看這裡:簡單配圖執行個體

開始下一步前,弄明白GRUB如何定義分區是相當重要的.

對於GRUB,數字從0開始,字母明確的,也從0開始.

例如,/dev/hda1對於GRUB,是"hd0,0".例如/dev/hdb3是hd1,2. For example, `/dev/hda1` is
"hd0,0" to GRUB. Similarly, `/dev/hdb3` is "hd1,2".

""注意"":"root"必須指向你的'/boot/'分區,如果你有的話.沒有,則指向'/'分區.

sudo /sbin/grub
grub> root (hd0,2)
grub> setup (hd0)
grub> quit

[編輯
]

配置GRUB菜單

注意
:
如果只是恢複MBR,這一步就沒必要做.安裝Windows並不會改變已存在的'menu.lst',因此一切都正常的話,也都會正常工作,只需要重啟電腦.

用你喜愛的編輯器開啟GRUB菜單檔案'/boot/grub/menu.lst'.例如:

sudo nano /boot/grub/menu.lst

注意
:
'menu.lst'檔案用來控制作業系統在啟動時GRUB的顯示.本指南將只能解釋如何讓你的作業系統啟動,它不會告訴你如何使你的bootloader漂亮。

一個menu.lst例子, 去除必要的備忘, 如: 上面的例子是基於/dev/hda3和dev/hda4,並假定Windows位於/dev/hda1.

timeout 5 #The number of seconds GRUB should wait before booting an OS
default 0 #The entry which should be booted by default
fallback 1 #The entry which should be booted in the event of the first one failing

A sample `menu.lst`, stripped of unnecessary comments, appears below. It is based on the `/dev/hda3` and `/dev/hda4` example above, and assumes Windows resides at `/dev/hda1`.
<pre><nowiki>timeout 5 #The number of seconds GRUB should wait before booting an OS
default 0 #The entry which should be booted by default
fallback 1 #The entry which should be booted in the event of the first one failing

title Ubuntu, 2.6.10 #A 32-bit Ubuntu entry
#This (or something like it) should be in your configuration
root (hd0,2)
initrd /initrd.img-2.6.10-5-386
kernel /vmlinuz-2.6.10-5-386 root=/dev/hda4

title Ubuntu, 2.6.10 #Another 32-bit Ubuntu entry
#This is an example of an Ubuntu entry which does not have a separate /boot/ partition
#(it is provided only as an alternate to the example above -- do not use them together)
root (hd0,2)
initrd /boot/initrd.img-2.6.10-5-386
kernel /boot/vmlinuz-2.6.10-5-386

title Microsoft Windows XP Home #An entry for a Windows installation
#If you're reading this guide, you probably want this
root (hd0,0)
makeactive
chainloader +1

現在,儲存並關閉這個檔案,重啟系統.

[編輯
]

使用 Ubuntu Alternate/Install CD

這一節解釋如何恢複GRUB(the GRand Unified Boot loader),使用Ubuntu alternate/install CD.

  • 進入BIOS設定從光碟機啟動.如果可以從CD啟動,插入CD.退出BIOS(儲存設定以確保可以從CD啟動).
  • 當Ubuntu閃屏出現boot命令列時,輸入rescue,並斷行符號.
  • 選擇語言,位置(國家),鍵盤配置,如同重新安裝一樣.
  • 輸入一個名字,或用預設的Ubuntu.
  • 在這個階段,提交選擇哪個是你的根分區(有一個硬碟分區列表,所以你必須知道ubuntu在哪個分區) 。這將是

dev/discs/disc0/partX
, 這裡X
是分區數字.

  • 提交了一份命令提示字元.
  • 輸入$ grub-install /dev/hdaX
    ,X是你的Ubuntu root安裝分區.

 

[編輯
]

使用Alternate/Install CD改寫Windows bootloader

  • 用Ubuntu CD啟動電腦
  • 進行安裝進程,直到出現 "[!!!] Disk Partition"
  • 選擇手動分區
  • 掛載正確linux分區:
      • /
      • /boot
      • swap
      • ...
  • DO NOT FORMAT THEM.
  • 完成手工分區
  • 問及是否儲存改變時,選擇"Yes"
  • 之後,系統會給出錯誤提示,"系統不能安裝......"
  • 忽略,繼續選擇"continue" 直到獲得Ubuntu 安裝菜單
  • 進入"Install Grub ...."
  • 完成後,重啟電腦.

From: http://doc.gwos.org/index.php/Restore_Grub
and http://ubuntuforums.org/showthread.php?t=76652

[編輯
]

GRUB資源

    • GRUB
      Manual

    • GRUB homepage
    • Grub wiki
    • Linux+Win+Grub HowTo
    • Super Grub Disk. Ready
      to go cdrom or floppy that restores Grub on MBR automatically

    • Linux Recovery and Boot Disk Creation with Grub
      .
    • Win32 Grub
    • Booting
      with GRUB

    • WinGRUB
    • GRUB
      Installer for Windows

    • GRUB for DOS
      - Bridging
      DOS/Windows to Unix/Linux

取自"http://wiki.ubuntu.org.cn/index.php?title=UbuntuHelp:RecoveringUbuntuAfterInstallingWindows/zh&variant=zh-cn
"6個分類
:
正在翻譯

| 翻譯請求

| Chinese
Translation

| CategoryDocumentation

| CategoryCleanup

| UbuntuHelp

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.