Chinaunix首页 | 论坛 | 博客
  • 博客访问: 839355
  • 博文数量: 182
  • 博客积分: 1992
  • 博客等级: 上尉
  • 技术积分: 1766
  • 用 户 组: 普通用户
  • 注册时间: 2010-10-18 11:49
文章分类

全部博文(182)

文章存档

2019年(1)

2016年(5)

2015年(29)

2014年(38)

2013年(21)

2012年(36)

2011年(52)

我的朋友

分类: LINUX

2013-08-08 13:41:26

image

Ubuntu and many other Linux distributions use the GRUB2 boot loader. If GRUB2 breaks — for example, if you install Windows after installing Ubuntu or overwrite your MBR — you won’t be able to boot into Ubuntu.

You can easily restore GRUB2 from a Ubuntu live CD or USB drive. This process is different from  on older Linux distributions.

Graphical Method – Boot Repair

Boot Repair is a graphical tool that can repair GRUB2 with a single click. This is the ideal solution to boot problems for most users.

If you have the media you installed Ubuntu from, insert it into your computer and restart. If you don’t,  and burn it to a disc or . You can also download a .

After booting into the live Ubuntu environment, open a terminal from the Dash and run the following commands to install Boot Repair:

sudo add-apt-repository ppa:yannubuntu/boot-repair
sudo apt-get update
sudo apt-get install -y boot-repair
boot-repair

The Boot Repair window will appear after you run the boot-repair command. After it scans your system, click the Recommended repair button to repair GRUB2 with a single click.

You can also click the Advanced options header to customize GRUB2’s options without learning its command-line syntax.

Restart your computer after using the Boot Repair tool. Ubuntu should boot up normally.

Terminal Method

If you’d rather get your hands dirty, you can do this yourself from a terminal. You’ll need to boot from a live CD or USB drive, as in the graphical method above. Ensure the version of Ubuntu on the CD is the same as the version of Ubuntu installed on your computer — for example, if you have Ubuntu 12.04 installed, ensure you use a Ubuntu 12.04 live CD.

Open a terminal after booting into the live environment. Identify the partition Ubuntu is installed on using one of the following commands:

sudo fdisk -l
sudo blkid

Here’s the output of both commands. In the fdisk -l command, the Ubuntu partition is identified by the word Linux in the System column. In the blkid command, the partition is identified by its ext4 file system.

Run the following command to mount the Ubuntu partition at  /mnt, replacing /dev/sdX#with the device name of your Ubuntu partition from the above commands:

sudo mount /dev/sdX# /mnt

For example, use /dev/sda1 for the first partition of the first hard disk device.

Important: If you have a separate boot partition, skip the above command and mount the boot partition at /mnt/boot. If you don’t know whether you have a separate boot partition, you probably don’t.

Run the following command to reinstall grub from the live CD, replacing /dev/sdX with the device name of the hard disk above. Omit the number. For example, if you used /dev/sda1above, use /dev/sda here.

sudo grub-install –boot-directory=/mnt/boot /dev/sdX

Restart your computer and Ubuntu should boot properly.


For more detailed technical information, including how to use the chroot command to gain access to a broken Ubuntu system’s files and restore GRUB2, consult the .

阅读(812) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~