zgwLinux

   :: 首页  ::  :: 联系 ::  :: 管理
  33 Posts :: 0 Stories :: 3 Comments :: 0 Trackbacks

  写这篇文章一是为了对遇到同样问题的人提供一个参考,二来也是为了自己便于总结和查阅。希望大神勿喷。

  好了,废话不多说了,转入正题。

  前几天给自己的电脑装了个Ubuntu16.04LTS,自己顺手就把里边的软件什么的升级了一下。不知怎么地把内核升级到了4.8.0-26-generic,然后电脑就USB老出毛病(在开机之前插上优盘的话可以读出优盘,开机后插上就没反应,但USB可以有电)。耳机也不能用了,喇叭也没声音。自己也不懂怎么回事,就各种百度,Google。网上好多人说是内核和硬件不兼容,一般把显卡驱动卸载了就好了。我试了一下没有成功。后来注意到开机的时候提示Failed to start Load Kernel Modules。然后就转战内核方向。

  看到也有网友遇到相似问题,并提出了解决方法(http://askubuntu.com/questions/809199/failed-to-start-load-kernel-modules-ubuntu-16-04)。然而我的问题并未如愿解决。然后想到了修改启动配置文件,更改系统默认加载的内核。

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+, serial 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查看,内核即为想要的内核。

   

然而我的没成功,没办法,只能卸载内核了=========》》看到有牛人的方法(http://www.linuxidc.com/Linux/2016-05/131143.htm),顺便就使用了,在此不再做赘述。

  我在恢复模式用低版本内核进入系统后,检查不到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.cfg.bak.zgw
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
        set root='hd0,msdos1'
        if [ x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1  88421677-a988-4ff9-bf29-6c56aa4a9027
        else
          search --no-floppy --fs-uuid --set=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
        set root='hd0,msdos1'
        if [ x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1  88421677-a988-4ff9-bf29-6c56aa4a9027
        else
          search --no-floppy --fs-uuid --set=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 --class 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
        set root='hd0,msdos1'
        if [ x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1  88421677-a988-4ff9-bf29-6c56aa4a9027
        else
          search --no-floppy --fs-uuid --set=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 nomodeset 
        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
        set root='hd0,msdos1'
        if [ x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1  88421677-a988-4ff9-bf29-6c56aa4a9027
        else
          search --no-floppy --fs-uuid --set=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
        set root='hd0,msdos1'
        if [ x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1  88421677-a988-4ff9-bf29-6c56aa4a9027
        else
          search --no-floppy --fs-uuid --set=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
        set root='hd0,msdos1'
        if [ x$feature_platform_search_hint = xy ]; then
          search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1  88421677-a988-4ff9-bf29-6c56aa4a9027
        else
          search --no-floppy --fs-uuid --set=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 nomodeset 
        echo    '载入初始化内存盘...'
        initrd    /initrd.img-4.8.0-22-generic
    }

 

10.总结,经过大半个下午的折腾,终于可以正常使用了。我感觉直接执行第7步就可以。只是个人感觉而已,并没有经过实践检验。第一次写博客,如有不足请大家多加指正。引用了两个链接,参考了许多网友的想法,如涉及原创者版权问题,请及时联系,必当第一时间修改。

posted on 2016-12-27 20:32  zgwLinux  阅读(...)  评论(...编辑  收藏