Академический Документы
Профессиональный Документы
Культура Документы
RecoveringUbuntuAfterInstallingWindows
Style Cleanup Required: This article does not follow the style standards in the Wiki Guide. More info... This page documents how to restore or recover the boot-loader after installing Windows. Ubuntu uses the Grub boot-loader; refer to the GrubHowto or Grub2 for more information on Grub. Some reasons to repair your boot-loader might include installing Microsoft Windows after you have installed Ubuntu, adding or removing a hard drive, or changing hard drive settings. Note: These instructions provide multiple options. Pick the option which works best for you; otherwise, choose recommended option.
Contents 1. Recovery Using the Ubuntu Desktop/Live CD (RECOMMENDED) 1. Introduction 2. Create and boot from a Live CD 3. Are you using Grub or Grub 2? 4. Overwriting the Master Boot Record 1. For Grub Legacy 5. Troubleshooting 1. I don't see a Grub menu 2. Grub comes up in shell mode with no boot menu 3. What if Grub 2 does not list Windows 4. Grub 2 gives "error: no such device: xxxxx.xxxxx.xxxxx.xxxx" 5. What if Grub Legacy misses Windows 2. Recovery using Microsoft Windows and Its Bootloader 1. Restoring GRUB 2. Making Windows Load GRUB (and then Linux) 3. Recovery Using the Unofficial "Super Grub Disk" 1. From within Windows 2. As a standalone cd/floppy/usb 3. Preserving Windows Bootloader 4. Recovery Using the Ubuntu Alternate/Install CD 1. The GUI Way: Using the Alternate/Install CD and Overwriting the Windows bootloader 5. Recovery Using Third-Party Proprietary Software 6. Troubleshooting 1. Preparing Your Working Environment 1. Recovering GRUB Automatically 2. Recovering GRUB Manually 3. Configuring the GRUB Menu 7. GRUB Resources
GRUB 2 should display a version number of 1.96 or later. Legacy GRUB is version 0.97.
Grub2: Download the latest version of Ubuntu Desktop edition from http://www.ubuntu.com/GetUbuntu/download and burn your Ubuntu CD.
https://help.ubuntu.com/community/RecoveringUbuntuAfterInstallingWindows
Grub Legacy: See the dual-boot guide about recovering grub Reboot your computer and boot into a live session. Mount your Ubuntu partition from Places menu.
Go into boot/grub directory and check for existances of files menu.lst and grub.cfg.
https://help.ubuntu.com/community/RecoveringUbuntuAfterInstallingWindows
Grub Legacy uses boot/grub/menu.lst. Grub 2 uses uses boot/grub/grub.cfg. If you are still not sure, view the file and check whether syntax follows Grub2 conventions. If you downloaded Ubuntu Karmic 9.10 Live CD, but your installed version of Ubuntu uses Grub Legacy, please use this guide https://help.ubuntu.com/community/DualBoot/Grub#Ubuntu%209.10%20&%20earlier
Your Ubuntu partition is now mounted. You will need to continue Using the Terminal. Verify if your partition is correct.
Note the designation for the disk /dev/sda which you will be using later, and the directory in /media.
https://help.ubuntu.com/community/RecoveringUbuntuAfterInstallingWindows
Use Tab Completion in Terminal to complete the path. Hitting the <TAB> key will automatically finish file names, directory locations, and other long or hard to type file names. To make sure this is indeed the Ubuntu boot partition, run ls /media/0d104aff-ec8c-44c8-b811-92b993823444 /boot, substituting 0d104aff-ec8c-44c8-b811-92b993823444 with your volume's UUID from before, which should output something like this:
If what you have is not similar, unmount it and try another partition. Now that everything is mounted, we just need to reinstall GRUB by specifying the correct directory and the correct drive name:
Replace /dev/sda with the location you want to install GRUB on. If all went well, you should see something like this:
Reboot, making sure to boot to your hard drive and not to the live CD. Grub should be installed and both Ubuntu and Windows should have been automatically detected and listed in the menu. The Master Boot Record will execute Grub as the initial bootloader. The Windows bootloader is contained within the Windows partition and will then be chainloaded by the Grub bootloader.
Troubleshooting
I don't see a Grub menu
If the menu is not normally displayed during boot, hold down the SHIFT key as the computer attempts to boot to display the GRUB 2 menu. For Grub Legacy, use ESC key to display a menu.
https://help.ubuntu.com/community/RecoveringUbuntuAfterInstallingWindows
This should automatically detect the devices and configure grub appropriately.
Or, in Kubuntu:
Note: Put your Windows stanza before or after AUTOMAGIC KERNEL LIST in the menu.lst
Restoring GRUB
1. Boot from a Live CD, like Ubuntu Desktop, or similar. It is recommended to use Ubuntu 9.04 or newer as this has NTFS write support. 2. Open a Terminal. Open a root terminal (For non-Ubuntu live CDs type su the terminal. For Ubuntu based distros run sudo -i) 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 the output from this command for the following commands. Note: You should have mounted the partition which has your Linux system before typing this command. (e.g. In Knoppix Live CD partitions are shown on the desktop but they're not mounted until you double-click on them or mount them manually)
https://help.ubuntu.com/community/RecoveringUbuntuAfterInstallingWindows
5. Type root (hd0,3) note the space between root and (hd0,3). 6. Type setup (hd0,3) into the prompt. 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. At this stage you can either restart the system and install your own bootloader, or you can continue and tell the Windows bootloader where to find GRUB which will handle booting Linux.
However, when writing directly to the C:\ drive you could also do some damage to the system if you delete or move something. If you do pick the option to write directly, go in, put the file where it belongs, and touch NOTHING else. 3. Now you are going to make a copy of your boot partition. Finding out what this is called is not always completely reliable since the Linux naming conventions differ from the GRUB naming conventions. Linux labels partitions as hd[Letter][Number] or sd[Letter][Number] whereas GRUB always names them as hd[Number][Number]. If you installed GRUB on (hd0,0), then the /boot partition will be on hda1 or sda1. (Since (hd1,0) == hdb1 or sdb1, then by extension if you installed GRUB on (hd0,1) then the /boot partition will be on hda2 or sda2 and so on and so forth.) This narrows you down to two possibilities. If you now paste ls /dev |grep hd it will let you know if you have that drive on your machine. If nothing comes up which matches, then that means you must have an sd drive. Note: The command df won't work as you are booted from a Live CD. 4. Having determined your boot partition run this command as root: #dd if=/dev/sda2 of=/tmp/windows/linux.bin bs=512 count=1 Looking at this example /dev/sda2 is your boot partition and /tmp/windows/ is the drive you want to copy the boot sector image to. 5. If you haven't created linux.bin in the Windows drive then you need to copy it there now. 6. Next, reboot your computer and boot into Windows. Open c:\boot.ini in Notepad, and add a new line at the bottom:
This file might be write protected. If that is so, you need to enable writing to the file. To do so, right click, and from the context menu select Properties. Then uncheck the box that says "File is read only". Make sure to put that checkmark back afterwards. Next, make sure that at the top of the boot.ini file there is a timeout set, i.e timeout=5 or some such number. Do not edit this file from the Live CD, even if you have NTFS write support. Linux and Windows represent line breaks in different ways, so even though you can edit the file, it won't add a new line. 7. That's it, reboot and you will be given the option of booting into Linux, selecting that will chainload GRUB and this will let you boot into your Linux distro. Source: http://ubuntuforums.org/showpost.php?p=121355&postcount=5
https://help.ubuntu.com/community/RecoveringUbuntuAfterInstallingWindows
As a standalone cd/floppy/usb
Download Super Grub Disk Burn into a cdrom (better) or a floppy Boot from it Select: GRUB => MBR & !LINUX! (>2) MANUAL |8-) Select the Linux or Grub installation you want to restore. You see the message: SGD has done it! Reboot You're done.
https://help.ubuntu.com/community/RecoveringUbuntuAfterInstallingWindows
5. At this stage you are presented with a screen where you can select which partition is your root partition (there is a list of the partitions on your hard drive, so you are required to know which partition number Ubuntu is on). This will be dev/discs/disc0/partX, where the X is a partition number. 6. you are then presented with a command prompt (a hash). 7. type
where XXX is the device of your Ubuntu install. (eg: grub-install /dev/""hda"" or grub-install /dev/""sdb"" ). Note: newer 2.6.xx kernels call all hard disks ""sdx"" now but not sure if grub does.
The GUI Way: Using the Alternate/Install CD and Overwriting the Windows bootloader
1. 2. 3. 4. Boot your computer with the Ubuntu CD Go through the installation process until you reach "[!!!] Disk Partition" Select Manual Partition Mount your appropriate linux partitions: / /boot swap ... DO NOT FORMAT THEM. Finish the manual partition Say "Yes" when it asks you to save the changes It will give you errors saying that "the system couldn't install ....." after that Ignore them, keep select "continue" until you get back to the Ubuntu installation menu Jump to "Install Grub ...." Once it is finished, just restart your computer
5. 6. 7. 8. 9. 10. 11.
EasyBCD software allows Microsoft Windows users to boot into multiple operating systems, including Ubuntu Linux.
Troubleshooting
This section applies to... Dual-boot setups in which Windows was installed after Ubuntu Conditions where Windows failure forced a re-installation Windows recovery techniques involving the "restoration" of the MBR Cases where GRUB failed to install Prerequisites: Your Ubuntu partitions are all still intact You have a LiveCD, such as the Ubuntu Desktop CD or the Knoppix Live CD You're familiar enough with your LiveCD to gain access to a console You remember how you set up your partitions (having a printout of /etc/fstab is ideal, though you can make do with the output of fdisk -l /dev/hda) Knowledge of how your kernel works (specifically with regards to initrd), if you're using a non-Ubuntu kernel or you have built your own Your kernel's version; this howto assumes 2.6.10-5-386
https://help.ubuntu.com/community/RecoveringUbuntuAfterInstallingWindows
Note: Since this is a LiveCD environment, any changes to user accounts or filesystem layouts at this level will not be permanent. This means you can set a temporary root password and create directories without affecting your actual installation. Now, you need to gain root access. Under Ubuntu, this can be done with the following commands:
Under Knoppix, the following command will suffice, and you will not be prompted for a password.
Now that you have root access, you need to mount the partition(s) containing your bootloader files. You will need access to both your /sbin/ and /boot/ directories. If you have a /boot/ listing in your fstab, you are among those who will need to mount two partitions. Begin by creating a mount point for your working environment -- you'll notice this is the same as creating a directory.
Now it's time to actually load your filesystem data. Review your fstab and identify the location(s) of / and /boot/; these will likely look something like /dev/hda3 and /dev/hda4, though the letter 'a' and the numbers 3 and 4 may differ. Note: For the remainder of this howto, /dev/hda3 and /dev/hda4 will be assumed, so alter them as needed when typing them in yourself. Enter the following commands to load your filesystem and some information GRUB may need.
Now, you have to enter your working environment. The following command will take care of that.
Warning: From this point on, any files you modify will affect your Ubuntu system. You have left the safety of the LiveCD. Exercise caution.
Reinstalling GRUB from this point is easy. Just enter the following command.
If the command you used above failed, which is unlikely, you will need to configure GRUB manually (it isn't too hard). If it succeeded, you should read the note at the start of the final section: "Configuring the GRUB Menu".
https://help.ubuntu.com/community/RecoveringUbuntuAfterInstallingWindows
your / partition.
Note: Your menu.lst file is used to control the operating systems GRUB displays on startup, as well as its visual appearance. This howto will only explain how to get your operating systems to boot, it will not tell you how to make your bootloader pretty. 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.
And that's it. Save and close the file, then reboot and try out the entries.
GRUB Resources
GRUB Manual GRUB homepage GRUB wiki Recovering grub after installing Windows to dual-boot Linux+Win+Grub HowTo Super Grub Disk - Ready to go cdrom or floppy that restores Grub on MBR automatically GRUB for DOS CategoryLive CategoryBackupRecovery CategoryBootAndPartition CategoryInstallation
RecoveringUbuntuAfterInstallingWindows (last edited 2010-06-25 15:37:58 by https://login.launchpad.net/+id/DDpGXYJ @ 68-117-137-233.dhcp.mdsn.wi.charter.com[68.117.137.233]:bl8n8r)
Page History
https://help.ubuntu.com/community/RecoveringUbuntuAfterInstallingWindows