ubuntu12.04 grub乱码解决方案及相关grub知识了解

本文介绍了Ubuntu 12.04系统升级后出现GRUB乱码的解决方法,包括卸载并重新安装GRUB 2,更新软件包,修改配置文件等步骤。同时,文章详细讲解了GRUB 2的主要目录、文件、脚本描述及配置,帮助读者理解GRUB 2的工作原理和菜单生成过程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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-Repair

The 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

  • launch Boot-Repair from either :
    • the Dash (the Ubuntu logo at the top-left of the screen)
    • or System->Administration->Boot-Repair menu (Ubuntu 10.04 only)

    • or by typing 'boot-repair' in a terminal
  • Then click the "Recommended repair" button. When repair is finished, note the URL (paste.ubuntu.com/XXXXX) that appeared on a paper, then reboot and check if you recovered access to your OSs. 

  • If the repair did not succeed, indicate the URL to people who help you by email or forum.

Advanced options

Warning: 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.

http://pix.toile-libre.org/upload/img/1335263156.png http://pix.toile-libre.org/upload/img/1335263804.png http://pix.toile-libre.org/upload/img/1357337899.png http://pix.toile-libre.org/upload/img/1335263417.png http://pix.toile-libre.org/upload/img/1357348203.png

除此之外,官方文档还介绍另外一种修复方法:

  1. 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
  2. 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
  3. 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
  4. If using the ChRoot procedure, Exit chroot then continue the ChRoot procedure at Step 13:

rrr

一下摘自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.

    g2_configuring_grub-pc.png

    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.

    g2_configuring_command-line.png

info.pngWhen 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 ENTERFailure to select a drive will result in a GRUB Error 15 and failure of the installation.

    g2_dpkg-reconfigure.png

    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

    1. Run Boot-Repair from a liveCD or your installed session

    2. Click "Advanced options" --> GRUB options --> tick the "GRUB Legacy" option

    3. Click the "Apply" button

    http://img15.hostingpics.net/pics/924248leg.png



    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. 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值