ubuntu16.04出現以下畫面:
初步估計:引導出現問題了,系統啟動找不到引導了。
方案一:
- Reboot.
- Press F2 when the screen is lit up and go to the BIOS settings.
- System Configurations → SATA Operations
- Change RAID to AHCI
結果:沒有解決。
方案二:
https://askubuntu.com/questions/247541/gave-up-waiting-for-root-device-on-ubuntu
Attempt #3
I opened terminal and typed the following command:
sudo grub-install /dev/sda
and then I typed another command to update grub:
sudo update-grub
After all of this, I rebooted computer and finally, error disappeared and problem was fixed!
問題是:根本進不去桌面,無法打開終端,也就無法使用sudo命令。
方案三:
I just randomly started typing stuff... try:
(initramfs) blkid (initramfs) blockdev --rereadpt /dev/sda (initramfs) blkid (initramfs) exit
This at least gets you to the desktop where you can begin trouble shooting your problem which is probably due to a proprietary driver or something.
結果:失敗,還是進入不了桌面。
下面我決定利用rufus軟件制作u盤啟動盤並進行引導的修復。
u盤啟動盤制作參考:https://www.cnblogs.com/yibeimingyue/p/15479056.html
修復引導的參考鏈接:
https://www.cxyzjd.com/article/stlinax/107025125
https://blog.csdn.net/laocaibcc229/article/details/79274412
Ubuntu 18.04 啟動失敗的修復方法_stlinax的博客-程序員宅基地
由於突然斷電,重新啟動后發現不能進入Ubuntu系統,進入了GRUB界面。按照網上的方法在GRUB界面下修復,但是還是不能成功。原因可能是GRUB啟動文件或者啟動分區遭到破壞,於是嘗試了另外一種方法,就是利用Ubuntu的安裝光盤,加載Boot-Repair修復引導程序來解決問題。
這里涉及三個問題:
- 制作Ubuntu安裝光盤或U盤,然后啟動到Ubuntu安裝界面,注意這時候要選擇“試用Ubuntu”,然后就能進入Ubuntu桌面。
- 連接上互聯網,打開終端,然后下載安裝並運行Boot-Repair進行修復。
- 如果發生分區問題,要使用GParted分區軟件分出一個BIOS-boot分區,然后再修復。
【一般情況下的修復方法】
打開終端:
sudo add-apt-repository ppa:yannubuntu/boot-repair && sudo apt-get update
sudo apt-get install -y boot-repair && boot-repair
然后進入到Boot-Repair修復引導程序,點擊“推薦修復”,如果沒有錯誤提示的話,重啟豈可成功修復。
【分區破壞后的修復方法】
點擊“推薦修復”,Boot-Repair檢測后發現並提示缺乏分區。
打開Ubuntu自帶的GParted分區軟件,然后分出一個大於1MB的分區,這個分區不需要太大,不超過10MB就夠了。注意這個分區不要選擇EXT4,而是選擇“未格式化”,點擊左上角“√”按鈕,完成分區。右擊這個新建的分區,然后點擊管理標識,在bios_grub前面打鈎,退出GParted分區軟件。
接着重新運行Boot-Repair點擊“推薦修復”,按程序提示的要求另外打開一個終端,一步一步手動運行下去。如果需要復制粘貼,可以打開一個Gedit來粘貼。
本例的修復命令如下:
sudo chroot "/mnt/boot-sav/sda2" dpkg --configure -a
sudo chroot "/mnt/boot-sav/sda2" apt-get install -fy
sudo chroot "/mnt/boot-sav/sda2" apt-get purge -y grub*-common shim-signed
sudo chroot "/mnt/boot-sav/sda2" apt-get install -y grub-pc
修復完成后,關閉所有終端和程序,然后關機,取出光盤或U盤,重啟電腦,問題解決。
另外,LinuxMint20的安裝盤是自帶Boot-Repair的,可以直接搜索后使用。
打開終端:
sudo add-apt-repository ppa:yannubuntu/boot-repair && sudo apt-get update
這一步遇到的問題:
** (appstreamcli:9437): CRITICAL **: Error while moving old database out of the way. AppStream cache update failed.
解決辦法:
https://askubuntu.com/questions/1020404/error-while-moving-old-database-out-of-the-way
然后:
sudo apt-get install -y boot-repair && boot-repair
然后進入到Boot-Repair修復引導程序,點擊“推薦修復”,如果沒有錯誤提示的話,重啟豈可成功修復。
在運行:
sudo apt-get install -y boot-repair && boot-repair
的時候,出現如下界面:
即:無法定位軟件包:boot-repair.
嘗試的方法:
Workaround: install packages for an older release
It showed a 404 not found error because the PPA was not updated for the newer release (trusty). To install boot-repair
in Ubuntu 14.04, run the below commands on terminal:
sudo add-apt-repository ppa:yannubuntu/boot-repair
codename="$(lsb_release -cs)"
sudo sh -c "sed -i 's/$codename/saucy/g' /etc/apt/sources.list.d/yannubuntu-boot-repair-$codename.list"
sudo apt-get update
sudo apt-get install -y boot-repair && (boot-repair &)
Now use the recommended repair
option to repair your grub and restart after boot-repair finished repairing.
在運行:
sudo sh -c "sed -i 's/$codename/saucy/g' /etc/apt/sources.list.d/yannubuntu-boot-repair-$codename.list"
的時候,出現的問題是:
sed: can't read /etc/apt/sources.list.d/yannubuntu-boot-repair-.list: No such file or directory
所以:方案三失敗。
方案四:
如果安裝Ubuntu后啟動報錯:“Reboot and Select proper Boot device or Insert Boot Media in selected Boot device”。(Ubuntu 16.04)
插上U盤或CD,進入Try Ubuntu模式。
用sudo fdisk -l查看原始分區信息。
sudo fdisk -l
我看網上有個圖是:
Device Boot Start End Blocks Id System /dev/sda1 * 2048 2099199 1048576 83 Linux /dev/sda2 2099200 4196351 1048576 82 Linux swap / Solaris /dev/sda3 4196352 125829119 60816384 8e Linux LVM
Device # 分區名稱
Boot # 啟動分區,用*表示的是啟動分區
Start # 表示開始的柱面
End # 表示結束的柱面
Blocks # block塊數量
Id # 分區類型ID
System # 分區類型
但是我自己的沒有帶root標志的盤,所以可能啟動沒有了。。。
查看你的Ubuntu安裝在哪里。例如:/dev/sda1,對應修改以下命令執行。注意:不要選擇EFI分區!
sudo mount /dev/sda1 /mnt
sudo apt-get update
sudo apt-get install grub
接下來修復引導:
sudo grub-install /dev/sda --root-directory=/mnt
會看到這樣的界面:
修復ubuntu引導
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
https://blog.csdn.net/u011553516/article/details/116397597
掛載一個分區的方法:
1、建一個目錄(掛載磁盤分區)
1 2 |
|
2、掛載/dev/sda1分區
1 2 |
|
2. 掛載磁盤
sudo mount /dev/sda9 /mnt
sudo mount /dev/sda8 /mnt/boot
sudo mount /dev/sda10 /mnt/home
sudo mount --bind /sys /mnt/sys
sudo mount --bind /proc /mnt/proc
sudo mount --bind /dev /mnt/dev
linux下mnt目錄的作用:mount 可直接理解為“掛載”掛接光驅、USB設備的目錄,加載后,會在mnt里多出相應設備的目錄。
linux系統根目錄下各個目錄用途說明:
1、/ 根目錄 --------- 所有目錄掛在其下
2、/boot --------- 存放Ubuntu內核和系統啟動文件。系統啟動時這些文件先被裝載。
3、/etc --------- 系統的配置文件目錄。密碼文件、設置網卡信息、環境變量的設置等都在此目錄中,許多網絡配置文件也在其中。
4、/lib --------- 根文件系統目錄下程序和核心模塊的共享庫。這個目錄里存放着系統最基本的動態鏈接共享庫,類似於Windows下的system32目錄,幾乎所有的應用程序都需要用到這些共享庫。
5、/media --------- 主要用於掛載多媒體設備。ubuntu系統自動掛載的光驅、usb設備,存放臨時讀入的文件。
6、/proc --------- 這個目錄是系統內存的映射,我們可以直接訪問這個目錄來獲取系統信息。也就是說,這個目錄的內容不在硬盤上而是在內存里。
7、/sbin --------- s就是Super User的意思,這里存放的是系統管理員使用的系統管理程序,如系統管理、目錄查詢等關鍵命令文件。
8、/tmp --------- 這個目錄是用來存放一些臨時文件的,所有用戶對此目錄都有讀寫權限。
9、/home --------- 用戶的主目錄。下面是自己定義的用戶名的文件夾。每個用戶的設置文件,用戶的桌面文件夾,還有用戶的數據都放在這里。
10、/mnt --------- 此目錄主要是作為掛載點使用。通常包括系統引導后被掛載的文件系統的掛載點。如掛載Windows下的某個分區。
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------
OK。接下來即可重啟進入操作系統!
如果安裝正確,則可以直接進入系統。當然,也有部分機子會報錯:
如果報錯“Minimal BASH-like line editing is supported.”
有兩種解決方法:
第一種(推薦)
依次輸入如下命令(注意字符中空格)
grub>root (hd0,0)
命令含義:從硬盤第一個分區C盤啟動
grub>chainloader (hd0,0)+1
命令含義:指示GRUB讀取分區的第一個扇區的引導記錄
grub>boot
命令含義:啟動GRUB
PS:我在執行這樣的命令后,ubuntu啟動提示“Unable to find a medium containing a live file system”。google有解。
第二種
sudo apt-get -y purge grub
sudo apt-get install grub-efi-amd64 grub-efi-amd64-bin grub-efi-amd64-signed
然后安裝
sudo grub-install /dev/sda --efi-directory=/mnt/boot/efi --boot-directory=/mnt/boot
如果在制作Ubuntu To Go或安裝Ubuntu出現“error: file '/grub/i386-pc/normal.mod' not found”的報錯,請查看下面這篇文章。
Ubuntu引導錯誤修復 - i386
如果在制作Ubuntu To Go或安裝Ubuntu出現“error: file '/grub/i386-pc/normal.mod' not found”的報錯,可以進入LiveCD模式進行引導的安裝。
插上U盤或CD,進入Try Ubuntu模式。
sudo fdisk -l
查看你的Ubuntu安裝在哪里。例如:/dev/sda1,對應修改以下命令執行。
sudo mount /dev/sda1 /mnt
接下來安裝GRUB 2:
sudo grub-install /dev/sda --root-directory=/mnt
OK。接下來即可重啟進入操作系統!
更多Ubuntu相關信息見Ubuntu 專題頁面 http://www.linuxidc.com/topicnews.aspx?tid=2
本文永久更新鏈接地址:http://www.linuxidc.com/Linux/2016-09/135486.htm
方案四的結局:還是不行。
方案五(2021.11.1):
針對目前出現的這個問題:
再掙扎一次。
https://itsfoss.com/fix-minimal-bash-line-editing-supported-grub-error-linux/
Fixing “minimal BASH like line editing is supported” Grub error
The process is simple if you follow the steps carefully (not blindly). You may have to change the partition names as per your system.
Step 1: Boot in to the live Linux USB.
Step 2: You need to find out iif your system uses EFI or BIOS. To do that, open the terminal and use the following command to list your partitions:
sudo fdisk -l
Look closely in its output because it could be a huge output. If you see something like EFI, it’s an indication that your system has EFI. This information is important in later stages.
Device Start End Sectors Size Type
/dev/sda1 2048 976895 974848 476M EFI System
/dev/sda2 976896 40038399 39061504 18.6G Linux filesystem
/dev/sda3 40038400 79099903 39061504 18.6G Linux filesystem
/dev/sda4 79099904 468875263 389775360 185.9G Linux filesystem
You need to note two things here. The partition where EFI is installed (if it is installed) and the partition where root partition is installed.
Step 3 (only for non-EFI system): Installing grub on non-EFI system is even easier.
Mount the root partition of Linux:
sudo mount /dev/sda1 /mnt
And then install grub:
sudo grub-install /dev/sd1
Reboot and it should be fine.
當我執行:
sudo grub-install /dev/sd1
這一步的時候,出現以下錯誤:
解決這個錯誤的參考鏈接:
https://www.cnblogs.com/tsreaper/p/chroot-fix-boot.html
然而,在執行第2步:
2. 掛載虛擬文件系統
Linux 系統運行過程中,還需要 /proc、/dev、/run 等虛擬文件系統。參考資料 1 中使用下面這個命令統一完成虛擬文件系統的掛載:
for i in /dev /dev/pts /proc /sys /run; do sudo mount -B $i /mnt$i; done
我在虛擬機中執行這個指令成功了,但是在修復學校服務器時不知道為什么不能成功(但是現在也無法重現這個失敗...)。所以我使用了參考資料 2 中的命令完成虛擬文件系統的掛載:
sudo mount -t proc /proc /mnt/proc sudo mount --rbind /sys /mnt/sys sudo mount --rbind /dev /mnt/dev sudo mount --rbind /run /mnt/run
我后來特地搜索了一下 mount 指令的幾個選項,-B(或者 --bind)可以掛載一個文件系統中已有的子目錄,--rbind 則是遞歸版的 --bind(可以看一下 這篇博客 了解兩者的區別),-t 則是指定掛載的文件系統類型。網上也說 sudo mount -B /proc /mnt/proc 和 sudo mount -t proc /proc /mnt/proc 一般沒什么區別,所以也不太知道發生了什么...如果有知道區別的朋友還請留言賜教。
的時候,出現以下報錯信息:
在絕望之際,以“ubuntu硬盤修復”為關鍵詞進行百度搜索,搜到了下面這個文章:
**********************************************************************
https://blog.csdn.net/magicarm_lw/article/details/80185926
前幾天最擔心的事情發生了,公司里自己的代碼編譯服務器進不去系統了,當時就想到了里面還有一個新功能的代碼沒有上傳,悲劇了。之前有同事的電腦發生過類似的事情,但是由於里面沒有重要的東西,就直接格式化硬盤重裝系統。但是這次有些東西還沒上傳,所以不敢直接格式化重裝系統。
先用U盤制作了一個ubuntu安裝盤,點試用ubuntu進系統,想在系統里面掛載硬盤,把里面要的東西拷貝出來,結果一掛載就報錯,沒成功。
在度娘輸入“ubuntu修復硬盤”,好像有點眉目,看到有命令fsck -y /dev/sda2這個命令,想着死馬當活馬醫,在剛才試用的那個系統里面輸入sudo fsck -y /dev/sda2,看到系統在運行這個命令了,等了半個小時去看了下,顯示已經完成了。重啟了一下,果然好了!哈哈
sudo fsck -y /dev/sda2
**********************************************************************
此時,我想起了我的機器之前開機一直出現的問題:
https://www.cnblogs.com/yibeimingyue/p/14261416.html
此時輸入命令:
sudo fsck -y /dev/sda3
機器一陣狂跑:
上圖中的部分內容如下:
最后竟然出現了固態硬盤的盤符,這下數據有可能有救了!!!
先把數據拷貝出來再說。
2021.11.2
部分文件拷貝出來了,重啟還是進入不了系統,算了,不掙扎了,重裝系統吧。
2021.11.4的掙扎:
https://askubuntu.com/questions/449428/unable-to-locate-package-boot-repair-in-14-04
You can use the following commands to install boot-repair in Ubuntu 14-04:
sudo add-apt-repository ppa:yannubuntu/boot-repair
sudo sh -c "sed -i 's/trusty/saucy/g' /etc/apt/sources.list.d/yannubuntu-boot-repair-trusty.list"
sudo apt-get update
sudo apt-get install -y boot-repair && boot-repair
出現的問題是:
ubuntu@ubuntu:~$ sudo sh -c "sed -i 's/trusty/saucy/g' /etc/apt/sources.list.d/yannubuntu-boot-repair-trusty.list" sed: can't read /etc/apt/sources.list.d/yannubuntu-boot-repair-trusty.list: No such file or directory
這個是最后的掙扎了:
My solution is to use boot-repair disk iso
, it works for 14.04 http://sourceforge.net/projects/boot-repair-cd/files/
要不行,就下定決心重裝系統了。
boot-repair-disk-64bit.iso的使用方法參考下面的鏈接:
https://blog.csdn.net/ccc_cui/article/details/82803846
在選擇從usb啟動后,現在,出現了這個畫面:
點擊Recommended repair之后,出現:
提示可以利用Gparted執行創建BIOS-boot partition, 然后,我點擊:
后,出現:
此時,對着第一個分區sda1右鍵,選擇manage flags.
跳出:
之后,在bios_grub那一項打對勾,然后點擊close.
此時,敲入命令:
sudo fdisk -l
顯示:
重復做這一步:
此時,出現:
這是一個積極的信號,重啟一下看看。
結果是:
開機停在grub界面:
還是不行。
參考下面這個鏈接進行解決:
https://linuxhint.com/grub_rescue_ubuntu_1804/
Using GRUB Rescue to Boot into Ubuntu 18.04 LTS:
In the GRUB Rescue command line interface, you can list the hard drives and partitions you have installed with the following command:
As you can see, I have (hd0), (hd0, gpt1) and (hd0,gpt2) available. (hd0) represents the raw hard drive. (hd0,gpt1) and (hd0,gpt2) are the first and second GPT partitions of (hd0) respectively.
I’ve Ubuntu 18.04 LTS installed on UEFI hardware. So the first partition (hd0,gpt1) is the EFI partition and the second partition (hd0,gpt2) is the root partition. The files required to boot into the operating system is in the /boot directory of (hd0,gpt2) partition in my case. You may have /boot directory in a separate partition, in that case, make changes to the commands as you see fit.
You can list what files you have in a certain partition with ls command from the GRUB Rescue command line interface.
List the files and directories of the root partition (hd0,gpt2) with the following command:
As you can see, the files and directories are listed.
We are interested in the files we have in the /boot directories.
You should find two files in the /boot directory, vmlinuz and initrd as marked in the screenshot below. These files are required in order to boot correctly.
在這一步的時候,我的電腦的界面是:
這說明,我的硬盤里面是丟失了引導文件內核的。
Now set the root variable to point to the root partition (hd0,gpt2) with the following command:
Now you have to use the linux command to make the relative path of vmlinuz file known to GRUB bootloader.
You can do that with the following command:
NOTE: Here root=/dev/sda2 is required. Otherwise you may not be able to boot. /dev/sda2 means, that it is the second partition of the first hard drive. I added a table to help you understand how it works.
GRUB Identifier | Hard Drive | Partition | Linux Identifier |
(hd0) | First | /dev/sda | |
(hd0,gpt1) | First | First | /dev/sda1 |
(hd0,gpt2) | First | Second | /dev/sda2 |
(hd1) | Second | /dev/sdb | |
(hd1,gpt2) | Second | Second | /dev/sdb2 |
(hd1,gpt5) | Second | Fifth | /dev/sdb5 |
Also know that file and directory auto completion with the <Tab> key works in the GRUB command line interface as well, just like it does in a Linux terminal. So you should not have hard time navigating around GRUB command line interface.
Now you have to run the initrd command to make the initrd image know to the GRUB bootloader.
You can do that with the following command:
Now that everything is set, you can run the following GRUB command to boot into your Ubuntu 18.04 LTS operating system.
The boot process should start as you can see from the screenshot below.
You should see the login screen afterward. Login to your Ubuntu 18.04 LTS system.
Now that you’re logged in, run the following command to update the GRUB 2 configuration file:
The GRUB 2 configuration should be updated.
You may also need to re-install GRUB bootloader with the following command:
NOTE: Here /dev/sda is the hard drive where you want to install GRUB bootloader. Usually, it is the hard drive where you have your root partition.
Now that everything is working, you should be able to boot normally. If you still need something fixed, you can do it right now.
Loading Additional Modules:
At times, the GRUB command line interface prompt should be grub rescue> instead of
In that case, you need to run 2 additional commands. They are used to load GRUB modules that are not loaded by default. But are very important to boot the system.
The commands are:
grub rescue> insmod linux
Useful GRUB Rescue Commands:
In this section, I am going to list some of the common GRUB rescue commands that you may need in order to troubleshoot boot problems.
set pager=1 – If the output of any command is long enough that it doesn’t fit the screen, then this commands shows the outputs in a pager, like less in Linux terminal.
lsmod – It lists all the GRUB modules that are loaded.
cat – used to read files.
usb – list all the USB devices attached to your system.
clear – clears all the text from the GRUB command line window.
configfile grub.cfg_filePath – You can add a grub.cfg file using this command.
insmod – load GRUB module.
lspci – list all the attached PCI devices.
ls – list files, directories and block devices of your computer.
Although, this article is geared toward Ubuntu 18.04 LTS, it should work for any other modern Linux distribution that uses GRUB bootloader. Thanks for reading this article.
算了,不折騰了,重裝。
重裝后的ubuntu: