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

    This process should work on all versions of Ubuntu. It’s been tested on Ubuntu 16.04 and Ubuntu 14.04.

     
     

    The 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, restart, and boot from the removable drive. If you don’t, download a Ubuntu live CD and burn it to a disc or create a bootable USB flash drive.

    When Ubuntu boots, click “Try Ubuntu” to get a usable desktop environment.

    Ensure you have an Internet connection before continuing. You may need to choose a Wi-Fi network and enter its passphrase.

    Open a Terminal window from the Dash and run the following commands to install and launch Boot Repair:

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

    The Boot Repair window will automatically scan your system 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 choose to use the advanced options here, but Ubuntu’s wiki recommends you not use the advanced options unless you know what you’re doing. The recommended repair option can fix most problems automatically, and you could mess up your system even more by selecting the wrong advanced options.

    Boot Repair will begin working. It may ask you to open a Terminal and copy/paste a few commands into it.

     

    Just follow the instructions that appear on your screen. Perform the instructions Boot Repair wants you to and click “Forward” to continue through the wizard. The tool will walk you through everything you need to do.

    Restart your computer after the Boot Repair tool finishes applying its changes. Ubuntu should boot up normally.

    The 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 14.04 installed, ensure you use a Ubuntu 14.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.

    If you have multiple Linux ext4 partitions, you can get an idea of which is which by viewing the size of the partitions and their order on the disk here.

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

    sudo mkdir /mnt/ubuntu
    
    sudo mount /dev/sdX# /mnt/ubuntu

    In the screenshot above, our Ubuntu partition is /dev/sda1. This means the first partition on the first hard disk device.

    Important: If you have a separate boot partition, skip the above command and mount the boot partition at /mnt/ubuntu/boot instead. 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/sda1 above, use /dev/sda here.

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

    Restart your computer and Ubuntu should boot properly.

  • 相关阅读:
    SVN tags使用
    switch case执行顺序
    excel 15位身份证转18位
    .net core options 依赖注入的方式
    DICOM 相关概念了解
    Dicom文件基本操作
    asp.net core 3 使用nlog日志组件,使用$ {basedir}保存位置不对,记录下怎么解决
    asp.net core 动态更新 appsetting.json方法
    asp.net core appsetting.json 绑定读取
    centos 安装 nginx 及配置 的坑
  • 原文地址:https://www.cnblogs.com/welhzh/p/7293863.html
Copyright © 2020-2023  润新知