Ubuntu16.04修改内核启动

更新时间:2023-06-15 01:07:44 阅读: 评论:0

Ubuntu16.04修改内核启动
  写这篇⽂章⼀是为了对遇到同样问题的⼈提供⼀个参考,⼆来也是为了⾃⼰便于总结和查阅。希望⼤神勿喷。
  好了,废话不多说了,转⼊正题。
  前⼏天给⾃⼰的电脑装了个Ubuntu16.04LTS,⾃⼰顺⼿就把⾥边的软件什么的升级了⼀下。不知怎么地把内核升级到了4.8.0-26-generic,然后电脑就USB⽼出⽑病(在开机
之前插上优盘的话可以读出优盘,开机后插上就没反应,但USB可以有电)。⽿机也不能⽤了,喇叭也没声⾳。⾃⼰也不懂怎么回事,就各种百度,Google。⽹上好多⼈说是内
核和硬件不兼容,⼀般把显卡驱动卸载了就好了。我试了⼀下没有成功。后来注意到开机的时候提⽰Failed to start Load Kernel Modules。然后就转战内核⽅向。
grep menuentry /boot/grub/grub.cfg
1.该命令显⽰内核的启动顺序,⽐如:
zgw@zgw-ThinkPad:~$ grep menuentry /boot/grub/grub.cfg
if [ x"${feature_menuentry_id}" = xy ]; then
menuentry_id_option="--id"
menuentry_id_option=""
export menuentry_id_option
menuentry 'Ubuntu' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-5bce3795-da96-4c6f-bed2-67d37185a77d' {
submenu 'Ubuntu ⾼级选项' $menuentry_id_option 'gnulinux-advanced-5bce3795-da96-4c6f-bed2-67d37185a77d' {
menuentry 'Ubuntu,Linux 4.8.0-26-lowlatency' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.4.0-45-lowlatency-advanced-5bce3795-da96-4c6f-bed2-67d37185a77d' {
menuentry 'Ubuntu, with Linux 4.8.0-26-lowlatency (upstart)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.4.0-45-lowlatency-init-upstart-5bce3795-da96-4c6f-bed2-67d37185a77d'
menuentry 'Ubuntu, with Linux 4.8.0-26-lowlatency (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.4.0-45-lowlatency-recovery-5bce3795-da96-4c6f-bed2-67d37185a77d'    menuentry 'Ubuntu,Linux 4.8.0-26-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.4.0-45-generic-advanced-5bce3795-da96-4c6f-bed2-67d37185a77d' {
menuentry 'Ubuntu, with Linux 4.8.0-26-generic (upstart)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.4.0-45-generic-init-upstart-5bce3795-da96-4c6f-bed2-67d37185a77d' {
menuentry 'Ubuntu, with Linux 4.8.0-26-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.4.0-45-generic-recovery-5bce3795-da96-4c6f-bed2-67d37185a77d' {
menuentry 'Ubuntu,Linux 4.4.0-21-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.4.0-21-generic-advanced-5bce3795-da96-4c6f-bed2-67d37185a77d' {
menuentry 'Ubuntu, with Linux 4.4.0-21-generic (upstart)' --class ubuntu --class gnu-linux --class gnu -
-class os $menuentry_id_option 'gnulinux-4.4.0-21-generic-init-upstart-5bce3795-da96-4c6f-bed2-67d37185a77d' {
menuentry 'Ubuntu, with Linux 4.4.0-21-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.4.0-21-generic-recovery-5bce3795-da96-4c6f-bed2-67d37185a77d' { menuentry 'Memory test (memtest86+)' {
menuentry 'Memory test (memtest86+, rial console 115200)' {
2. 假设你要以4.4.0-21内核版本启动,则将⽂件/etc/default/grub中 
GRUB_DEFAULT=0
改为
GRUB_DEFAULT=6
或者改为
GRUB_DEFAULT=”Ubuntu,Linux 4.4.0-21-generic“
保存后
3. 然后使⽤命令sudo update-grub
4.重新启动后输⼊uname -r查看,内核即为想要的内核。
  我在恢复模式⽤低版本内核进⼊系统后,检查不到4.8.0-26-generic内核,不知道是什么原因。命令如下:
dpkg -l | tail -n +6| grep -E 'linux-image-[0-9]+'| grep -Fv $(uname -r)
四季月份划分
最后没办法,抱着死马当活马医的想法。
5.直接把/boot/中4.8.0-26相关的⽂件及⽂件夹全部删除。命令如下:
sudo rm -rf *4.8.0-26*
6.然后修改了配置⽂件:/boot/grub/grub.cfg
sudo cp /etc/boot/grub/grub.cfg /etc/boot/grub/grub.w
sudo vim  /etc/boot/grub/grub.cfg
7.找到如下代码块(我的为148,149⾏):
linux    /vmlinuz-4.8.0-26-generic root=UUID=5bce3795-da96-4c6f-bed2-67d37185a77d ro  quiet splash $vt_handoff
initrd    /initrd.img-4.8.0-26-generic
将其改为⾃⼰想使⽤的内核,我的如下:
linux    /vmlinuz-4.4.0-45-generic root=UUID=5bce3795-da96-4c6f-bed2-67d37185a77d ro  quiet splash $vt_handoff
initrd    /initrd.img-4.5.0-45-generic
8.然后重启电脑就可以了,如若不⾏,请找如下代码块(我的为151⾏)。
submenu 'Ubuntu ⾼级选项' $menuentry_id_option 'gnulinux-advanced-5bce3795-da96-4c6f-bed2-67d37185a77d'
9.将此⾏代码下的与4.8.0-26相关的代码全部删除(我的为152~263⾏)然后重启就可以了。
menuentry 'Ubuntu,Linux 4.8.0-26-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.8.0-26-generic-advanced-5bce3795-da96-4c6f-bed2-67d37185a77d' {
recordfail
load_video
gfxmode $linux_gfx_mode
insmod gzio
if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi
insmod part_msdos
insmod ext2
t root='hd0,msdos1'
if [ x$feature_platform_arch_hint = xy ]; then
arch --no-floppy --fs-uuid --t=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1  88421677-a988-4ff9-bf29-6c56aa4a9027
el
arch --no-floppy --fs-uuid --t=root 88421677-a988-4ff9-bf29-6c56aa4a9027
fi
echo    '载⼊ Linux 4.8.0-26-generic ...'
linux    /vmlinuz-4.8.0-26-generic root=UUID=5bce3795-da96-4c6f-bed2-67d37185a77d ro  quiet splash $vt_handoff
echo    '载⼊初始化内存盘...'
initrd    /initrd.img-4.8.0-26-generic
}
menuentry 'Ubuntu, with Linux 4.8.0-26-generic (upstart)' --class ubuntu --class gnu-linux --class gnu -
-class os $menuentry_id_option 'gnulinux-4.8.0-26-generic-init-upstart-5bce3795-da96-4c6f-bed2-67d37185a77d' {
recordfail
load_video
gfxmode $linux_gfx_mode
正祖insmod gzio
if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi
insmod part_msdos
我心中的榜样作文insmod ext2
t root='hd0,msdos1'
if [ x$feature_platform_arch_hint = xy ]; then
arch --no-floppy --fs-uuid --t=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1  88421677-a988-4ff9-bf29-6c56aa4a9027
el
arch --no-floppy --fs-uuid --t=root 88421677-a988-4ff9-bf29-6c56aa4a9027
fi
echo    '载⼊ Linux 4.8.0-26-generic ...'
linux    /vmlinuz-4.8.0-26-generic root=UUID=5bce3795-da96-4c6f-bed2-67d37185a77d ro  quiet splash $vt_handoff init=/sbin/upstart
echo    '载⼊初始化内存盘...'
initrd    /initrd.img-4.8.0-26-generic
}
menuentry 'Ubuntu, with Linux 4.8.0-26-generic (recovery mode)' --class ubuntu --class gnu-linux --cl
ass gnu --class os $menuentry_id_option 'gnulinux-4.8.0-26-generic-recovery-5bce3795-da96-4c6f-bed2-67d37185a77d' {        recordfail
load_video
insmod gzio
if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi
insmod part_msdos
insmod ext2
t root='hd0,msdos1'
if [ x$feature_platform_arch_hint = xy ]; then
arch --no-floppy --fs-uuid --t=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1  88421677-a988-4ff9-bf29-6c56aa4a9027
枸杞泡酒el
arch --no-floppy --fs-uuid --t=root 88421677-a988-4ff9-bf29-6c56aa4a9027
fi
echo    '载⼊ Linux 4.8.0-26-generic ...'
linux    /vmlinuz-4.8.0-26-generic root=UUID=5bce3795-da96-4c6f-bed2-67d37185a77d ro recovery nomodet
echo    '载⼊初始化内存盘...'
initrd    /initrd.img-4.8.0-26-generic
}
menuentry 'Ubuntu,Linux 4.8.0-22-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.8.0-22-generic-advanced-5bce3795-da96-4c6f-bed2-67d37185a77d' {
recordfail
load_video
二级运动员标准
gfxmode $linux_gfx_mode
insmod gzio
if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi
insmod part_msdos
insmod ext2
t root='hd0,msdos1'
if [ x$feature_platform_arch_hint = xy ]; then
煸炒arch --no-floppy --fs-uuid --t=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1  88421677-a988-4ff9-bf29-6c56aa4a9027
el
arch --no-floppy --fs-uuid --t=root 88421677-a988-4ff9-bf29-6c56aa4a9027
fi
echo    '载⼊ Linux 4.8.0-22-generic ...'
linux    /vmlinuz-4.8.0-22-generic root=UUID=5bce3795-da96-4c6f-bed2-67d37185a77d ro  quiet splash $vt_handoff
echo    '载⼊初始化内存盘...'
initrd    /initrd.img-4.8.0-22-generic
}
menuentry 'Ubuntu, with Linux 4.8.0-22-generic (upstart)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.8.0-22-generic-init-upstart-5bce3795-da96-4c6f-bed2-67d37185a77d' {
recordfail
load_video
gfxmode $linux_gfx_mode
insmod gzio
if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi
insmod part_msdos
insmod ext2
t root='hd0,msdos1'
if [ x$feature_platform_arch_hint = xy ]; then
国破家亡arch --no-floppy --fs-uuid --t=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1  88421677-a988-4ff9-bf29-6c56aa4a9027
el
arch --no-floppy --fs-uuid --t=root 88421677-a988-4ff9-bf29-6c56aa4a9027
fi
echo    '载⼊ Linux 4.8.0-22-generic ...'
linux    /vmlinuz-4.8.0-22-generic root=UUID=5bce3795-da96-4c6f-bed2-67d37185a77d ro  quiet splash $vt_handoff init=/sbin/upstart
echo    '载⼊初始化内存盘...'
initrd    /initrd.img-4.8.0-22-generic
}
menuentry 'Ubuntu, with Linux 4.8.0-22-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.8.0-22-generic-recovery-5bce3795-da96-4c6f-bed2-67d37185a77d' {        recordfail
load_video
insmod gzio
if [ x$grub_platform = xxen ]; then insmod xzio; insmod lzopio; fi
insmod part_msdos
insmod ext2
t root='hd0,msdos1'
if [ x$feature_platform_arch_hint = xy ]; then
arch --no-floppy --fs-uuid --t=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1  88421677-a988-4ff9-bf29-6c56aa4a9027
el
arch --no-floppy --fs-uuid --t=root 88421677-a988-4ff9-bf29-6c56aa4a9027
fi
echo    '载⼊ Linux 4.8.0-22-generic ...'
linux    /vmlinuz-4.8.0-22-generic root=UUID=5bce3795-da96-4c6f-bed2-67d37185a77d ro recovery nomodet
echo    '载⼊初始化内存盘...'
initrd    /initrd.img-4.8.0-22-generic
}
10.总结,经过⼤半个下午的折腾,终于可以正常使⽤了。我感觉直接执⾏第7步就可以。只是个⼈感觉⽽已,并没有经过实践检验。第⼀次写博客,如有不⾜请⼤家多加指正。
lol卡特琳娜
引⽤了两个链接,参考了许多⽹友的想法,如涉及原创者版权问题,请及时联系,必当第⼀时间修改。

本文发布于:2023-06-15 01:07:44,感谢您对本站的认可!

本文链接:https://www.wtabcd.cn/fanwen/fan/89/1038869.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:内核   问题   启动
相关文章
留言与评论(共有 0 条评论)
   
验证码:
推荐文章
排行榜
Copyright ©2019-2022 Comsenz Inc.Powered by © 专利检索| 网站地图