ubuntu12.04升级之后移植乱码,原先还装了13.04,所以用13.04的grub不会乱码,但是删了13.04之后,12.04的grub乱码确实很难忍受,查了下官方文档,顺便摘抄一下相关知识。
原因可能是grub2被屏蔽掉了,我发现进入grub显示的是grub0.98,所以有了头绪,执行如下命令即可
sudo apt-get install grub-pc
sudo upgrade-from-grub-legacy当然除了使用命令行外,你也可以使用图形工具Boot-repair
Getting Boot-Repair
1st option : get a CD including Boot-RepairThe easiest way to use Boot-Repair is to burn one of the following disks and boot on it.
Remark : you can also install the ISO on a live-USB (eg via UnetBootin or LiliUSB or Universal USB Installer).
2nd option : install Boot-Repair in Ubuntu- boot your computer on a Ubuntu live-CD or live-USB. - choose "Try Ubuntu" - connect internet - open a new Terminal, then type:
sudo add-apt-repository ppa:yannubuntu/boot-repair && sudo apt-get update - Press Enter. - Then type: sudo apt-get install -y boot-repair && (boot-repair &) - Press Enter
Using Boot-Repair
Recommended repair
Advanced optionsWarning: the default settings are the ones used by the "Recommended Repair". Changing them may worsen your problem. Don't modify them before creating a BootInfo URL, and asking advice on this thread. |
- Update the repositories to get a list of the most recent packages available. Ensure you have a working Internet connection and access to the repositories. If you do not, STOP!
apt-get update
-
The following command will completely remove grub-pc and grub-common. In GRUB 1.99 and later, grub-gfxpayload-lists will also be removed.
-
You will be warned you are removing the bootloader. TAB to OK and press ENTER.
apt-get purge grub-common
-
- Reinstall GRUB 2. When you run the following command:
- You will be given the opportunity to add kernel options. TAB to OK. You will be given the opportunity to select the devices/drives on which to install GRUB 2. Select the appropriate drive(s) with the SPACEBAR. Normally you do NOT want to select any partitions. TAB to OK after selecting the drive(s), then press ENTER.
apt-get install grub-pc
-
If using the ChRoot procedure, Exit chroot then continue the ChRoot procedure at Step 13:
一下摘自ubuntu官方文档:
-
To upgrade to GRUB 2 install the grub-pc package. This package can be installed with Synaptic, if installed, or by running the command below. Once the installation begins, a simple script will guide the user through the rest of the installation:
sudo apt-get install grub-pc
-
The package manager may complain about version conflicts and offer a solution to un-install GRUB. This may cause you to worry that it might become impossible for you to use the "Chain load to GRUB2 from legacy GRUB" option that is mentioned below. Selecting the un-install GRUB option here will not prevent you booting with the legacy menu described in step 4 below.
1. At the first prompt, read the message, tab to select "OK", then press ENTER.
2. After selecting "OK" the next option allows the user to test GRUB 2 by adding an entry to their normal GRUB menu. Select "Yes" to place a Chainload option on the GRUB menu. When GRUB boots the next time, the user can select a normal GRUB entry or transfer control to GRUB 2 via the Chainload entry.
3. The next step(s) will import sections from GRUB's menu.lst to the "Linux command line" (shown) and possibly the "Linux default command line". These entries allow the user to enter any special commands such as quiet, splash, noapic and others of that nature. GRUB 2 should automatically import these settings. Normally the user should accept any existing entries and TAB to "OK". If necessary, entries can be added later. Refer to the Configuring GRUB 2 section for more detail.
-
When installing on a fresh drive, you may need to mark the selected partition as bootable. Although Linux does not use the boot flag, other OS's may require its presence.
-
4. During installation the user will be prompted to provide the device(s) on which to install GRUB 2. Use the UP/DOWN keys to highlight a device (sda, sdb, etc), then the SPACE key to select the device. Once at least one device is selected, use the TAB key to highlight OK and press ENTER. Failure to select a drive will result in a GRUB Error 15 and failure of the installation.
Read the information on the screen carefully. Selecting an option which includes a partition number (such as /dev/sda9 in the example) is not recommended. It will install GRUB 2 boot information directly on the Ubuntu partition. The location is specified by blocklists and GRUB 2 is more likely to break if boot files are moved for any reason.
6. If the GRUB 2 menus function properly the user can upgrade to GRUB 2 at any time by running:
sudo upgrade-from-grub-legacy
Upon successful installation of GRUB 2, a message will inform the user that some GRUB Legacy configuration files are still present and can be removed. The instructions provide the following command, which must be run as 'root': rm -f /boot/grub/menu.lst* Use caution when running the rm command as "root". Incorrectly entering this command could result in permanently deleting necessary system files.
Reverting to GRUB Legacy
If a user chooses to return to GRUB legacy (0.97), these steps will remove GRUB 2 and install GRUB.
via Boot-Repair graphical tool
-
Run Boot-Repair from a liveCD or your installed session
-
Click "Advanced options" --> GRUB options --> tick the "GRUB Legacy" option
- Click the "Apply" button
grub2主要介绍:
GRUB 2 Initial Installation
GRUB 2 installation is automatically incorporated into a normal Ubuntu installation. Input required by the user for the initial setup is very simple. If the installation will use the entire disk no specific GRUB selections are necessary. If the user wants to use a specific partition for Ubuntu the user must select the Ubuntu partition and the drive on which to embed the bootloader information.
The main GRUB 2 folder locations include /boot/grub/ and /etc/grub.d/. User preferences are stored in the /etc/default/grub file. The GRUB 2 menu is built by information contained in/boot/grub/grub.cfg.
Reinstalling GRUB 2 from a Working System
If Ubuntu is operating normally, boot into the working installation and run the following command from a terminal.
-
X is the drive (letter) on which you want GRUB to write the boot information. Normally users should not include a partition number, which would produce an error message as the command would attempt to write the information to a partition.
sudo grub-install /dev/sdX # Example: sudo grub-install /dev/sda
This will rewrite the MBR information to point to the current installation and rewrite some GRUB 2 files (which are already working). Since it isn't done during execution of the previous command, running sudo update-grub after the install will ensure GRUB 2's menu is up-to-date.
Fixing a Broken System
If a system has become unbootable due to a GRUB 2 failure or corrupted MBR/boot sector, there are various methods for reinstalling GRUB 2. The simplest is listed first, followed by more complicated methods.
via Boot-Repair Graphical Tool
Boot-Repair is a GUI application which can fix a variety of GRUB 2 problems. It can be used either from a LiveCD, its own CD, or during a normal Ubuntu session. In addition to providing a simple user interface, Boot-Repair also includes the ability to run a script to gather details of the system which can be used for troubleshooting help on various forums and IRC channels.
Please refer to the Boot-Repair community documentation for instructions on how to install and run this application.
via GRUB2 Rescue mode
GRUB 2 provides a rescue mode which allows the user to attempt to repair GRUB 2 from a special GRUB terminal during boot. Refer to the Grub2 Command_Line_and_Rescue_Mode section for information on GRUB terminal operations.
-