Restart Ubuntu after Windows is installed.

Source: Internet
Author: User
Ubuntuhelp: recoveringubuntuafterinstallingwindows/ZH from Ubuntu Chinese

This entry is being translated from documents in other languages
To Chinese.


You are welcome to actively participate in translation and revision.

.
Source:
 

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

Translators:
 

Min Haibo

Click to translate
:

 

English

Chinese


 

Directory

[Hide
]

  • 1
    Use Ubuntu Desktop/live CD

    • 1.1
      Using the desktop/livecd while
      Preserving windows bootloader

    • 1.2
      Use livecd to reconstruct grub

    • 1.3
      Use desktop/livecd to rewrite windows
      Bootloader

    • 1.4
      Do not use Ubuntu Desktop/live
      CD
  • 2
    Use an unofficial "Super grub disk"

  • 3
    Fault Detection and repair

    • 3.1
      Prepare your work environment

      • 3.1.1
        Automatic grub recovery

      • 3.1.2
        Restore grub manually

      • 3.1.3
        Configure GRUB menu

  • 4
    Use Ubuntu Alternate/install
    CD

    • 4.1
      Use Alternate/install CD to rewrite windows
      Bootloader
  • 5
    Grub Resources

[Edit
]

Use Ubuntu Desktop/live CD

Select one of the following options:

[Edit
]

Using the desktop/livecd while preserving windows
Bootloader

[Edit
]

Use livecd to reconstruct grub

Do not forget the following method: replace MBR with grub in the hard drive boot partition (Master Boot Record ). This applies to most people unless you have another available Bootstrap program.

On the other hand, if you use boot magic or system commander, the command you read will rewrite what you do.

If you have installed grub with MBR in the boot partition, the command will be different. My suggestions are as follows:

How to restore grub After Ghost:
(Translator's note: it is applicable to the loss of grub caused by Windows reinstallation. I have used the Ghost Software and the gho image to restore the Windows system and will not map grub .)

1. Use live CD to boot the system, such as Ubuntu live, knoppix, mepis, or similar.

2. Open the terminal. Open the root terminal ("Su" is used on a non-Ubuntu CD and "Sudo-I" is used on the Ubuntu CD ). The password is required.

3. Enter "Grub ".

4. Enter "find/boot/GRUB/stage1 ". You will see something like "(hd0 )"
(My is (hd0, 3 )"). In the following operations, use the information displayed on your computer. (Note: if it is a separate Boot partition, you need to change it to "find ".
/GRUB/stage1 ")

5. Enter "root (hd0, 3 )". The following information is taken as an example of the original author)

6. Enter "setup (hd0, 3 )".
This is the key. If you want to write grub into MBR, you can use other operations, such as "(hd0 )". If you want to write it to your Linux boot partition, you can write the number after a comma, such as "(hd0, 3 )".

7. Enter "quit ".

8. restart the system. Remove the boot CD.

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

[Edit
]

Use desktop/livecd to rewrite windows bootloader

Use live CD boot to open the terminal. You can useSudo-I

To obtain the root command line.Sudo
. Be especially careful when typing errors.

We need to find the partition where the Ubuntu system is located. Enter the commandFdisk-l
. The list of all your partitions will be returned, 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 partition. if you only have one, it is obviously your Ubuntu system installation partition. you have more partitions, but you don't know which one is the partition for your Ubuntu system installation. You can try again later. first, create a mount point for your partition, for example:

mkdir /mnt/root

Then mount your partition. If you do not know which one is, mount each partition once until the correct one is found.

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

Of course, replace/dev/hda2. with your correct partition name.Ls/mnt/root
To check whether it is correct. The following information may be displayed:

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 not, the correct partition is not mounted.Umount/mnt/root

To unmount the partition and try another one. You may need to mount your/boot partition, for example:

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

Make sure the mounting is correct.Ls/mnt/root/boot
The following information is returned for verification:

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

Again, if it still does not match, Unmount and load another partition.

Now it is mounted. We need to reinstall GRUB:

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

If you receive a BIOS warning, try:

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

Of course, replace/dev/hda with the location where you want to install grub. If everything succeeds, you will see the following information:

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 restart and the GRUB menu will display. If there is an XFS file system warning, ignore it.

[Edit
]

Do not use Ubuntu Desktop/live CD

You may not use Ubuntu Desktop/live
To mount your partition (the following example assumes that the root partition is hda1 ):

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

Then change the path to your sbin installation and run grub from there

cd /mnt/linux/sbin
sudo ./grub

[Edit
]

Use an unofficial "Super grub disk"

  • Download super grub Disk

  • Burn a cd (recommended) or swap it into a floppy disk
  • Start
  • Select: Language
  • Select: Linux
  • Select: repair the boot of Linux (grub)
  • Select the Linux or GRUB installation you want to recover.
  • You will see the information: SGD is ready!
  • Restart
  • Successful.

[Edit
]

Fault Detection and repair

This part will:

  • Install the dual-Start Settings for Windows only after Ubuntu is installed.
  • Windows must be reinstalled
  • Windows Recovery Technology involves MBR
  • Other cases of grub installation failure

Prerequisites:

  • Your Ubuntu partition is still complete
  • You have a livecd, such as Ubuntu Desktop CD, or other alternatives.
  • You are familiar with livecd and can get support.
  • You still remember that your installation partition (printing '/etc/fstab' is a good method, so you can use fdisk-L/dev/hda)
  • If you use a non-Ubuntu kernel or build your own kernel, you need to know the core work knowledge (especially about initrd)
  • Your kernel version; depending on 2.6.10-5-386

[Edit
]

Prepare your work environment

Start to recover the program, insert livecd, and restart the computer until your livecd is started to see the interface. If your livecd does not appear on the console immediately, use the terminal. Use Ubuntu
Livecd, click Application-System Tools-terminal.

Note:
: Because this is the livecd environment,
Any changes to the user account or file system will not be maintained. This means you can set a temporary root password to create a directory without affecting your actual installation.

Now you want to get the root permission. In ubuntu, run the following command:

sudo -i

In knoppix, the following command is enough and the password is not required:

su -

Now you have the root permission to mount the partitions of the boot file.

You have to access the '/sbin/' and/boot/'directories. If there is a'/boot/'list in 'fstab', two partitions must be mounted.

Start to create a mount point for the work environment-be sure to create a directory at the same time.

mkdir /mnt/work

If '/boot/' must be mounted, use the following command.

mkdir /mnt/work/boot

Now you can load the file system data. Review 'fstab' and make sure that '/' and '/boot/' are like '/dev/hda3'
And '/dev/hda4'. the letters A and number 3 and 4 may be different.

Note:
: '/Dev/hda3' and'/dev/hda4' is assumed and must be replaced with your own.

Type the following command to load your file system. Some Grub information may be used.

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

Now, you enter your work environment. You should be careful with the following commands.

chroot /mnt/work/ /bin/bash

"" Warning ": From this moment on, any changes will affect your Ubuntu system. You have left the Secure Mode of livecd. Pay special attention to this.

[Edit
]

Automatic grub recovery

If you have an independent/boot partition, run the following command:

sudo mount /dev/hda3 /boot/

It is easier to install grub from here. You only need to use the following command:

sudo /sbin/grub-install /dev/hda

Unfortunately, you have to manually configure grub (this is not difficult) if the above command is not available. If it is successful, the last section will show: "rolling ing the GRUB menu ".

[Edit
]

Restore grub manually

If you think the following statements are long and annoying, you can refer to: simple graph matching example.

Before starting the next step, it is very important to understand how grub defines partitions.

For grub, the number starts from 0 and the letter is clear.

For example, for grub,/dev/hda1 is "hd0, 0". For example, if/dev/HDB3 is hd1, 2. For example, '/dev/hda1' is
"Hd0, 0" to grub. Similarly, '/dev/hdb3' is "hd1, 2 ".

"" NOTE ":" root "must point to your '/boot/' partition. If you have one, if not, it points to the '/' partition.

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

[Edit
]

Configure GRUB menu

Note:
:
If only MBR is restored, this step is unnecessary. installing Windows does not change the existing 'menu. lst', so everything works normally. You only need to restart the computer.

Open the GRUB menu file '/boot/GRUB/menu. lst' in your favorite editor. For example:

sudo nano /boot/grub/menu.lst

Note:
:
'Menu. the lst' file is used to control the display of grub when the operating system is started. this guide will only explain how to enable your operating system. It will not tell you how to make your bootloader beautiful.

A menu. lst example to remove the necessary remarks, for example, the above example is based on/dev/hda3 and dev/hda4, and assumes that Windows is located in/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

Now, save and close the file and restart the system.

[Edit
]

Use Ubuntu Alternate/install CD

This section explains how to restore grub (the grand uniied Boot Loader) and use Ubuntu Alternate/install CD.

  • Go to BIOS settings to start from the optical drive. If you can start from Cd, insert Cd. Exit BIOS (Save settings to make sure you can start from CD ).
  • When the boot command line appears on the Ubuntu flash screen, enter rescue and press Enter.
  • Select the language, location (country), and keyboard layout, just like installing again.
  • Enter a name or use the default ubuntu.
  • In this phase, submit and select which is your root partition (there is a list of hard disk partitions, so you must know which partition Ubuntu is located ). This will be

dev/discs/disc0/partX
, HereX
It is a partition number.

  • A command prompt is submitted.
  • Input$ grub-install /dev/hdaX
    , X is your Ubuntu root installation partition.

 

[Edit
]

Use Alternate/install CD to rewrite windows bootloader

  • Start the computer with Ubuntu CD
  • Install the program until "[!] appears. Disk partition"
  • Select manual partitioning
  • Mount the correct LINUX partition:
      • /
      • /Boot
      • Swap
      • ...
  • Do not format them.
  • Complete manual partitioning
  • If you want to save the changes, select "yes"
  • Then, the system will give an error message, "the system cannot be installed ......"
  • Ignore, continue to select "continue" until you get the Ubuntu installation menu
  • Go to "Install grub ...."
  • After that, restart the computer.

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

[Edit
]

Grub Resources

    • 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

From "http://wiki.ubuntu.org.cn/index.php? Title = ubuntuhelp: recoveringubuntuafterinstallingwindows/ZH & variant = ZH-CN
"6 categories
:
Translating

| Translation request

| Chinese
Translation

| Categorydocumentation

| Categorycleanup

| Ubuntuhelp

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.