个人工具

“UbuntuHelp:RecoveringUbuntuAfterInstallingWindows/zh”的版本间的差异

来自Ubuntu中文

跳转至: 导航, 搜索
第3行: 第3行:
 
{{Translator|聂海波 }}
 
{{Translator|聂海波 }}
 
{{Languages|php5}}}
 
{{Languages|php5}}}
 +
 +
== Using the Ubuntu Desktop/Live CD ==
 +
 +
Please choose one of the following options:
 +
 +
=== Using the Desktop/LiveCD while preserving Windows Bootloader ===
 +
 +
Don't forget that this method, as described, puts GRUB back on the MBR (master boot record) of the hard drive instead of in the root parititon. This is fine for most people, but not if you already have an alternative boot manager.
 +
 +
In other words, if you use something like Boot Magic or System Commander, the commands you've just read will overwrite what you've got.
 +
 +
If you've installed GRUB into the Root Partition instead of the MBR, the commands are a little different. Here's are the instructions that I have for my system:
 +
 +
How to Restore the Grub Menu after a Re-Ghosting:
 +
 +
1. Boot from a Live CD, like Ubuntu Live, Knoppix, Mepis, or similar.
 +
 +
2. Open a Terminal. Open a root terminal (that is, type "su" in a non-Ubuntu distro, or "sudo -i" in Ubuntu). Enter root passwords as necessary.
 +
 +
3. Type "grub" which makes a GRUB prompt appear.
 +
 +
4. Type "find /boot/grub/stage1". You'll get a response like "(hd0)" or in my case "(hd0,3)". Use whatever your computer spits out for the following lines.
 +
 +
5. Type "root (hd0,3)".
 +
 +
6. Type "setup (hd0,3)". This is key. Other instructions say to use "(hd0)", and that's fine if you want to write GRUB to the MBR. If you want to write it to your linux root partition, then you want the number after the comma, such as "(hd0,3)".
 +
 +
7. Type "quit".
 +
 +
8. Restart the system. Remove the bootable CD.
 +
 +
From: http://ubuntuforums.org/showpost.php?p=121355&postcount=5
 +
 +
=== Using the Desktop/LiveCD and Overwriting the Windows bootloader ===
 +
 +
Boot from a Live CD and open a terminal. You'll need to run a few commands as root so you can use ''sudo -i'' to get a root shell and run them normally instead of using ''sudo'' on each of them. Be extra careful when running a root shell, especially for typos !
 +
 +
We'll need to find which partition your Ubuntu system is installed on. Type the command ''fdisk -l''. It will output a list of all your partitions, for example :
 +
 +
<pre><nowiki>$ 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</nowiki></pre>
 +
 +
Here I have three Linux partitions. /dev/hda2 is my root partition, /dev/hda1 is my /boot partition and /dev/hda6 is my /home partitoins. If you only have one, obviously this is the one your Ubuntu system is installed on. If you have more than one and you don't know which one your Ubuntu is installed on, we'll look for it later. First, create a mountpoint for your partition, for example :
 +
 +
<code><nowiki>mkdir /mnt/root</nowiki></code>
 +
 +
Then mount your partition in it. If you don't know which one it is, then mount any of them, we'll se if it's the correct one.
 +
 +
<code><nowiki>mount -t ext3 /dev/hda2 /mnt/root</nowiki></code>
 +
 +
Of course, replace /dev/hda2 with the correct name of your partition. You can check if it's the correct one by running ''ls /mnt/root'', which should output something like this :
 +
 +
<pre><nowiki>bin    dev      home        lib    mnt  root    srv  usr
 +
boot  etc      initrd      lib64  opt  sbin    sys  var
 +
cdrom  initrd.img  media  proc  selinux  tmp  vmlinuz</nowiki></pre>
 +
 +
If what you have looks not at all like this, you didn't mount the correct partition. Do ''umount /mnt/root'' to unmount it and try another one. You also need to mount your /boot partition if you made one, like this :
 +
 +
<code><nowiki>mount -t ext3 /dev/hda1 /mnt/root/boot</nowiki></code>
 +
 +
To make sure it was the correct one, run ''ls /mnt/root/boot'', which sould output something like this :
 +
 +
<pre><nowiki>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</nowiki></pre>
 +
 +
Once again, if what you have doesn't fit, unmount it and try another partition.
 +
 +
Now that everything is mounted, we just need to reinstall GRUB :
 +
 +
<code><nowiki>grub-install --root-directory=/mnt/root /dev/hda</nowiki></code>
 +
 +
If you got BIOS warnings try:
 +
 +
<code><nowiki>grub-install --root-directory=/mnt/root /dev/hda -recheck</nowiki></code>
 +
 +
Of course, replace /dev/hda with the location you want to install GRUB on. If all went well, you should see something like this :
 +
 +
<pre><nowiki>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</nowiki></pre>
 +
 +
Now you can reboot and the GRUB menu should appear. If you see a warning message regarding XFS filesystem, you can ignore it.
 +
 +
 +
=== Not using the Ubuntu Desktop/Live CD ===
 +
 +
You could have to run "grub" not from the Ubuntu Desktop/Live CD, but from your disk installation to make it work. To do this mount your root partition (following examples assume a root partition on hda1):
 +
 +
<pre><nowiki>sudo mkdir /mnt/linux
 +
sudo mount /dev/hda1 /mnt/linux
 +
</nowiki></pre>
 +
 +
then change directory to your installation sbin and run grub from there
 +
 +
<pre><nowiki>cd /mnt/linux/sbin
 +
sudo ./grub
 +
</nowiki></pre>

2007年11月11日 (日) 00:19的版本

}

Using the Ubuntu Desktop/Live CD

Please choose one of the following options:

Using the Desktop/LiveCD while preserving Windows Bootloader

Don't forget that this method, as described, puts GRUB back on the MBR (master boot record) of the hard drive instead of in the root parititon. This is fine for most people, but not if you already have an alternative boot manager.

In other words, if you use something like Boot Magic or System Commander, the commands you've just read will overwrite what you've got.

If you've installed GRUB into the Root Partition instead of the MBR, the commands are a little different. Here's are the instructions that I have for my system:

How to Restore the Grub Menu after a Re-Ghosting:

1. Boot from a Live CD, like Ubuntu Live, Knoppix, Mepis, or similar.

2. Open a Terminal. Open a root terminal (that is, type "su" in a non-Ubuntu distro, or "sudo -i" in Ubuntu). Enter root passwords as necessary.

3. Type "grub" which makes a GRUB prompt appear.

4. Type "find /boot/grub/stage1". You'll get a response like "(hd0)" or in my case "(hd0,3)". Use whatever your computer spits out for the following lines.

5. Type "root (hd0,3)".

6. Type "setup (hd0,3)". This is key. Other instructions say to use "(hd0)", and that's fine if you want to write GRUB to the MBR. If you want to write it to your linux root partition, then you want the number after the comma, such as "(hd0,3)".

7. Type "quit".

8. Restart the system. Remove the bootable CD.

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

Using the Desktop/LiveCD and Overwriting the Windows bootloader

Boot from a Live CD and open a terminal. You'll need to run a few commands as root so you can use sudo -i to get a root shell and run them normally instead of using sudo on each of them. Be extra careful when running a root shell, especially for typos !

We'll need to find which partition your Ubuntu system is installed on. Type the command fdisk -l. It will output a list of all your partitions, for example :

$ 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

Here I have three Linux partitions. /dev/hda2 is my root partition, /dev/hda1 is my /boot partition and /dev/hda6 is my /home partitoins. If you only have one, obviously this is the one your Ubuntu system is installed on. If you have more than one and you don't know which one your Ubuntu is installed on, we'll look for it later. First, create a mountpoint for your partition, for example :

mkdir /mnt/root

Then mount your partition in it. If you don't know which one it is, then mount any of them, we'll se if it's the correct one.

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

Of course, replace /dev/hda2 with the correct name of your partition. You can check if it's the correct one by running ls /mnt/root, which should output something like this :

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

If what you have looks not at all like this, you didn't mount the correct partition. Do umount /mnt/root to unmount it and try another one. You also need to mount your /boot partition if you made one, like this :

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

To make sure it was the correct one, run ls /mnt/root/boot, which sould output something like this :

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

Once again, if what you have doesn't fit, unmount it and try another partition.

Now that everything is mounted, we just need to reinstall GRUB :

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

If you got BIOS warnings try:

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

Of course, replace /dev/hda with the location you want to install GRUB on. If all went well, you should see something like this :

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

Now you can reboot and the GRUB menu should appear. If you see a warning message regarding XFS filesystem, you can ignore it.


Not using the Ubuntu Desktop/Live CD

You could have to run "grub" not from the Ubuntu Desktop/Live CD, but from your disk installation to make it work. To do this mount your root partition (following examples assume a root partition on hda1):

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

then change directory to your installation sbin and run grub from there

cd /mnt/linux/sbin
sudo ./grub