融券客 發表於 2020-4-8 23:35:00

Ubuntu下修复grub引导

<div>很多时候,特别是在linux调整分区后,开机重启时会出现</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;error : unknow filesystem</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;grub rescue&gt;</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;的字样,系统就是进不去。这表示你的grub2的配置文件坏了……</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;由于分区调整或分区UUID改变造成grub2不能正常启动,从而进入修复模式了(grub rescue),也称救援模式。</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;在救援模式下只有很少的命令可以用:set &nbsp;, &nbsp;ls , insmod , root , prefix</div>
<div>&nbsp;</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;(1)set &nbsp;查看环境变量,这里可以查看启动路径和分区。</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;(2)ls &nbsp;&nbsp;查看设备</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;(3)insmod &nbsp;加载模块</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;(4)root &nbsp;指定用于启动系统的分区,在救援模式下设置grub启动分区</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;(5)prefix 设定grub启动路径</div>
<div>&nbsp;</div>
<div>具体修复步骤如下:</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; 1、查看分区:grub rescue&gt; ls &nbsp;&nbsp;回车</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;会出现如下字样:</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(hd0) (hd0,msdos9) (hd0,msdos8) (hd0,msdos7) (hd0,msdos6) (hd0,msdos5)&nbsp;(hd0,msdos2)&nbsp;(hd0,msdos1)</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; 注:上面是我的分区设备,每个人可能不一样,但原理都是一样的。</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp;&nbsp;</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; 2、寻找ubuntu所在分区:</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (就是寻找你的Linux系统是装在以上哪个分区里)</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;grub rescue&gt; ls (hd0,msdos1)/</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;若出现unknown filesystem字样,则尝试下一个</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;……</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;若出现的是你的ubuntu主文件夹下的文件夹和文件的名字,那就是的要找的分区了。</div>
<div>&nbsp;</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;3、修改启动分区:</div>
<div>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (假如你找到的启动分区是hd0,msdos8)</div>
<p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; grub rescue&gt;root=(hd0,msdos8)<br>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; grub rescue&gt;prefix=/boot/grub &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; //grub路径设置<br>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; grub rescue&gt;set root=(hd0,msdos8)<br>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; grub rescue&gt;set prefix=(hd0,msdos8)/boot/grub<br>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; grub rescue&gt;insmod normal &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;//启动normal启动</p>
<p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; grub rescue&gt;normal</p>
<p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;之后你就会看到熟悉的启动菜单栏了</p>
<p>&nbsp;</p>
<p>&nbsp;&nbsp;4、进入命令行启动ubuntu</p>
<p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;进入系统启动选项界面后还是进不去,</p>
<p>&nbsp;&nbsp; &nbsp; &nbsp; 因为你还没有真正的修改grub,这个要到ubuntu里修改</p>
<p>&nbsp;</p>
<p>进入系统启动项界面后,按C进入命令行模式</p>
<p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;grub &gt;set root=hd0,msdos8</p>
<p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;grub &gt;set prefix=(hd0,msdos8)/boot/grub</p>
<p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;grub &gt;linux /vmlinuz-xxx-xxx root=/dev/sda8&nbsp;//里边的xxxx可以按Tab键,如果有acpi问题,在最后加一句acpi=off<br>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;grub &gt;initrd /initrd.img-xxx-xxx<br>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp;grub &gt;boot</p>
<p>&nbsp;&nbsp; &nbsp; &nbsp; 这样就可以进入了</p>
<p>&nbsp;</p>
<p>
&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; 5、进入ubuntu修复grub</p>
<p>&nbsp;</p>
<p>&nbsp;在终端里运行 &nbsp; &nbsp; &nbsp; &nbsp;sudo update-grub</p>
<p>&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp;&nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;sudo grub-install /dev/sda</p>
<p><span style="color: rgba(0, 0, 0, 1); font-family: &quot;Trebuchet Ms&quot;, sans-serif">&nbsp;</span></p>
<p>&nbsp;&nbsp; &nbsp; &nbsp; 6、重启,搞定!!</p>
<p>&nbsp;</p>
<p>&nbsp;注:我当时只是修改了1~3步骤,然后在菜单栏就可以进入系统了,且一切正常。</p>
<p>&nbsp;&nbsp; &nbsp; &nbsp; 可惜,在重启时,系统就只有一个光标在左上角不停的闪,咋也进不了系统。后来开机按F2,开机启动项改为硬盘启动就好了</p>
<p>&nbsp;</p>
<p>&nbsp;转自:https://www.cnblogs.com/jins-note/p/9513335.html</p>
<hr>
<p>&nbsp;</p>

</div>
<div id="MySignature" role="contentinfo">
    <div id="AllanboltSignature">
    <p style="border: #330066 1px solid; padding: 10px 10px; font-family: 微软雅黑; font-size: 11px; text-indent: 0em;">
      <span style="margin-left: 10px; font-weight: bold;">作者:AshJo</span>
      <br>
      <span style="margin-left: 10px; font-weight: bold;">出处:https://www.cnblogs.com/ashjo009/</span>
      <br>
      <span style="margin-left: 10px; font-weight: bold; color: red;">本文版权归作者所有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。</span>
    </p>
</div><br><br>
来源:https://www.cnblogs.com/ashjo009/p/12663886.html
頁: [1]
查看完整版本: Ubuntu下修复grub引导