Repair GRUB2 When Ubuntu Won’t Boot

17
How to Repair GRUB2 When Ubuntu Won’t Boot 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 restoring the legacy GRUB boot loader 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, download a Ubuntu live CD and burn it to a disc or install it on a USB flash drive . You can also download a dedicated Boot Repair live CD .

Transcript of Repair GRUB2 When Ubuntu Won’t Boot

Page 1: Repair GRUB2 When Ubuntu Won’t Boot

How to Repair GRUB2 When Ubuntu Won’t Boot

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 restoring the legacy GRUB boot loader 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, download a Ubuntu live CD and burn it to a disc or install it on a USB flash drive. You can also download a dedicated Boot Repair live CD.

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-repairsudo apt-get updatesudo apt-get install -y boot-repairboot-repair

Page 2: Repair GRUB2 When Ubuntu Won’t Boot

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.

Page 3: Repair GRUB2 When Ubuntu Won’t Boot

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 -lsudo 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.

Page 4: Repair GRUB2 When Ubuntu Won’t Boot

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.

Page 5: Repair GRUB2 When Ubuntu Won’t Boot

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.

Page 6: Repair GRUB2 When Ubuntu Won’t Boot

Reinstall / Recover GRUB from Ubuntu live CD / USBPosted by Manivannan on May 3, 2012 in Linux | 27 comments

40 

EmailShare

Updated on May 3, 2012.This is the common problem which is faced, when you try for dual boot. Recently I have posted the article on How to Recover / Re-Install Grub in Ubuntu using Boot-Repair from live cd / usb. Boot Repair is the simple graphical tool used to repair, restore or reinstall the grub bootloader on Ubuntu. Now this tools has been updated with some new features in advanced option, using boot- repair you can also restore the MBR on Windows.

On dual boot once you update your Ubuntu OS, your Windows / Fedora will not be listed on your grub. After installing Windows / Fedora your Ubuntu will not boot anymore and its grub may be wiped out. To restore it follow the steps belowTo Reinstall Grub You need to have Ubuntu Live CD or Live USB. Normal session can be used to repair the grub. Boot using your Ubuntu Live CD or Live USB, while booting choose Try Ubuntu.

Page 7: Repair GRUB2 When Ubuntu Won’t Boot

Once booted then open a terminal, and run the following command one by one toinstall the boot repair.To add boot-repair to the repository$ sudo add-apt-repository ppa:yannubuntu/boot-repairTo Update your repository$ sudo apt-get updateTo install boot-repair$ sudo apt-get install -y boot-repairOnce Installation complete run boot-repair on terminal by typing the following command or select it by System->Aministration->Boot Repair.$ boot-repairNOTE: Update the Boot Repair if its newer version is available.It will scan the System for few seconds and will show you the options Recommended repair and Create a BootInfo summary. By clicking the Recommended Repair it will start repair the grub. Check the screen shots below.

Once done click ok and restart your system, your grub should work now. If not run the boot-repair again using live cd / usb. Then follow the steps below.Select the Advanced options, In Main options tab check whether the following options are selected or not. If not select it, the options are Reinstall Grub and unhide boot menu for 10 seconds. Check the screen shot below

Page 8: Repair GRUB2 When Ubuntu Won’t Boot

Then select the GRUB locations tab and check the following options are selected or not. The options are OS to boot by default and place grub into, In “OS to boot by default” option choose the OS which you want to be default on boot. Then select the drive where you need to reinstall the grub in “place grub into” option and click apply. Check the screen shots below

Click ok and restart your System. To restore MBR Click Here.Hope this will be helpful for you!!!

Page 9: Repair GRUB2 When Ubuntu Won’t Boot

Restore MBR from Ubuntu live CD / USBPosted by Manivannan on Aug 17, 2011 in Linux | 8 comments

1  

EmailShare

On dual boot Ubuntu and Windows, If you like to uninstall / remove Ubuntu from your machine and like to have windows alone. Then you need to restore your original MBR and it can be done easily with Boot Repair using Ubuntu Live CD / USB.To install the Boot Repair You need to have Ubuntu Live CD or Live USB. Boot using your Ubuntu Live CD or Live USB, while booting choose Try Ubuntu.Once booted then open a terminal, and run the following command one by one toinstall the boot repair.To add boot-repair to the repository$ sudo add-apt-repository ppa:yannubuntu/boot-repairTo Update your repository$ sudo apt-get updateTo install boot-repair$ sudo apt-get install -y boot-repairOnce installation complete follow the steps below.

To Restore MBR Run boot-repair on terminal by typing the following command or select it by System->Aministration->Boot Repair.$ boot-repair

Page 10: Repair GRUB2 When Ubuntu Won’t Boot

It will scan the System for few seconds and will pop-up a small window. Select Advanced options and in Main options tab select Restore MBR. Check the screen shot below.

Then select the MBR options tab, check the drive for MBR and Windows OS. By default all the options are selected correctly if not select the drive where your MBR is to be and the correct OS. Click apply now, check the screen shots below.

Once done click ok and restart your system and it should work. Then after logging in into your windows, go to Disk Management in Computer Management then select the Storage. Now you will see the list of all available partitions, there

Page 11: Repair GRUB2 When Ubuntu Won’t Boot

you select the linux partitions and delete it. Make a new partition from the deleted one and format it with ntfs. Thats it your done.Hope this will be helpful for you!!!

Thay đổi vị trí boot mặc định trong GRUB 2Posted 02/05/2012 by tnlug in Ubuntu + Debian. Để lại phản hồi

      1 Vote

GRUB 2 ra đời với hàng loạt thay đổi so với GRUB legacy (phiên bản Grub trước). Dù muốn hay không, bạn buộc phải làm quen với GRUB 2 vì nó đã được tích hợp vào Ubuntu 9.10. Bài viết này chỉ đề cập đến một vấn đề rất nhỏ nhưng hay thường gặp trong việc cấu hình GRUB nói chung và GRUB 2 nói riêng, đó là chỉnh sửa vị trí boot mặc định.Đặt vấn đề: Tôi có cài sẳn một hệ điều hành (ví dụ windows), khi cài thêm Ubuntu 9.10 vào thì chương trình GRUB 2 luôn mặc định trỏ đến dòng Ubuntu 9.10. Bây giờ tôi muốn nó mặc định trỏ đến hệ điều hành quen thuộc của tôi (windows) khi khởi động thì phải làm thế nào?Nếu ở GRUB legacy thì bạn sẽ nghĩ ngay đến tập tin menu.lst trong /boot/grub/, nhưng qua đến GRUB 2 thì khái niệm này không còn nữa. Có người bảo rằng menu.lst năm xưa giờ là grub.cfg nên chỉ việc chỉnh sửa grub.cfg là xong thôi. Điều đó cũng đúng nhưng cũng có phần… sai! Đúng là bạn có thể tìm thấy trong đó những thông tin giống giống với GRUB cũ, còn sai là vì tập tin đó sinh ra không để chỉnh sửa.Bởi vì nó là một tập tin do máy tính tạo ra nó có thể bị thay đổi chỉ với một câu lệnh. Do đó đừng có cố chỉnh sửa tập tin grub.cfg nhé!

Page 12: Repair GRUB2 When Ubuntu Won’t Boot

Vậy thì ta sẽ chỉnh sửa ở đâu? Hơi lằng nhằng một chút, những cũng không quá phức tạp đâu! Ta sẽ tìm đến tập tin tên là grub trong /etc/default/ . Đây mới chính là tập tin ta cần thay đổi (dĩ nhiên là với quyền root rồi nhé! )# If you change this file, run ‘update-grub’ afterwards to update # /boot/grub/grub.cfg.

GRUB_DEFAULT=0 #GRUB_HIDDEN_TIMEOUT=0 GRUB_HIDDEN_TIMEOUT_QUIET=true GRUB_TIMEOUT=10 GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian` GRUB_CMDLINE_LINUX_DEFAULT=”quiet splash” GRUB_CMDLINE_LINUX=”"

# Uncomment to disable graphical terminal (grub-pc only) #GRUB_TERMINAL=console

# The resolution used on graphical terminal # note that you can use only modes which your graphic card supports via VBE # you can see them in real GRUB with the command `vbeinfo’ #GRUB_GFXMODE=640×480

Page 13: Repair GRUB2 When Ubuntu Won’t Boot

# Uncomment if you don’t want GRUB to pass “root=UUID=xxx” parameter to Linux #GRUB_DISABLE_LINUX_UUID=true

# Uncomment to disable generation of recovery mode menu entrys #GRUB_DISABLE_LINUX_RECOVERY=”true”Những dòng đầu tiên chắc sẽ quen thuộc nếu bạn có vọc với GRUB một hai lần. Hãy chú ý đến dòng đầu tiên:GRUB_DEFAULT=0Đây là thứ cần chỉnh nếu muốn thay đổi vị trí boot mặc định trong menu GRUB 2.Hãy thay 0 bằng các con số tượng trưng cho vị trí của các mục trong menu (0 là mục đầu tiên) hay bằng từ “saved” – nét mới trong GRUB 2. Khi GRUB_DEFAULT=saved thì GRUB sẽ nhớ vị trí của mục đã được boot ở lần khởi động trước, lần khởi động sau sẽ trỏ đến đúng vị trí đó. Còn nếu thay bằng con số thì ta phải bận tâm đến mục lựa chọn mà ta muốn chọn làm mặc định nằm ở vị trí thứ mấy trong mục để điền vào cho thích hợp.Trong trường hợp thay bằng số thì sau đây là cách để biết vị trí của mục cần chọn. Thông thường, các hệ điều hành khác được cài sẳn sẽ được Ubuntu nhận diện và để ở dưới cùng của bảng lựa chọn. Với phiên bản 9.10, Ubuntu cho ta tới 4 mục lựa chọn, vậy các hệ điều hành khác sẽ nằm từ vị trí thứ 5 trở đi, và vì vị trí đầu tiên bắt đầu từ số 0, cho nên vị trí thứ năm phải là số 4.Để biết có bao nhiêu mục trong menu thì chạy lệnh sau:grep menuentry /boot/grub/grub.cfgSau khi xem xét kĩ lưỡng ta thay 0 bằng 4:GRUB_DEFAULT=4Lưu lại tập tin và đừng có restart vội, vẫn còn một bước cuối cùng nữa:Chạy lệnh này trong terminal:sudo update-grubLệnh này sẽ cập nhật thông tin từ các tập tin riêng lẻ trong /etc/grub.d và tập tin vừa mới chỉnh /etc/default/grub vào trong tập tin /boot/grub/grub.cfg. Do đó, không được thay đổi tập tin grub.cfg một cách thủ công cũng là vì lẽ này.Vậy là xong rồi đó. Rườm rà phức tạp quá phải không? Cái gì mới cũng cần có thời gian làm quen tìm hiểu, rồi đâu sẽ vào đó thôi.Bổ sung: ngoài việc thay bằng các con số thứ tự và từ saved ra ta còn có thể dùng chính xác tên của mục lựa chọn. Ưu điểm là không cần phải quan tâm đến vị trí của mục trong bảng lựa chọn nữa. Cách thay như sau:GRUB_DEFAULT=”xxxx”Với xxxx là tên chính xác của mục, nhớ phải kẹp giữa 2 dấu ngoặc kép.Để biết tên mục ta cũng chạy lệnh:grep menuentry /boot/grub/grub.cfg

Page 14: Repair GRUB2 When Ubuntu Won’t Boot