刀云网这里记录下修改步骤,方便自己和其他鸡友操作。
1. 查看当前内核的启动顺序
运行:$ cat /boot/grub/grub.cfg
,查看当前内核的启动顺序:
### BEGIN /etc/grub.d/00_header ###
if [ -s $prefix/grubenv ]; then
set have_grubenv=true
load_env
fi
if [ "${next_entry}" ] ; then
set default="${next_entry}"
set next_entry=
save_env next_entry
set boot_once=true
else
set default=0
fi
### BEGIN /etc/grub.d/10_linux ###
function gfxmode {
set gfxpayload="${1}"
}
set linux_gfx_mode=
export linux_gfx_mode
menuentry 'Debian GNU/Linux' --class debian --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-d689cedc-8dc2-4ebb-919f-fe47b628db44' {
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 d689cedc-8dc2-4ebb-919f-fe47b628db44
else
search --no-floppy --fs-uuid --set=root d689cedc-8dc2-4ebb-919f-fe47b628db44
fi
echo 'Loading Linux 4.19.0-1-amd64 ...'
linux /boot/vmlinuz-4.19.0-1-amd64 root=UUID=d689cedc-8dc2-4ebb-919f-fe47b628db44 ro quiet
echo 'Loading initial ramdisk ...'
initrd /boot/initrd.img-4.19.0-1-amd64
}
submenu 'Advanced options for Debian GNU/Linux' $menuentry_id_option 'gnulinux-advanced-d689cedc-8dc2-4ebb-919f-fe47b628db44' {
menuentry 'Debian GNU/Linux, with Linux 4.19.0-1-amd64' --class debian --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.19.0-1-amd64-advanced-d689cedc-8dc2-4ebb-919f-fe47b628db44' {
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 d689cedc-8dc2-4ebb-919f-fe47b628db44
else
search --no-floppy --fs-uuid --set=root d689cedc-8dc2-4ebb-919f-fe47b628db44
fi
echo 'Loading Linux 4.19.0-1-amd64 ...'
linux /boot/vmlinuz-4.19.0-1-amd64 root=UUID=d689cedc-8dc2-4ebb-919f-fe47b628db44 ro quiet
echo 'Loading initial ramdisk ...'
initrd /boot/initrd.img-4.19.0-1-amd64
}
menuentry 'Debian GNU/Linux, with Linux 4.19.0-1-amd64 (recovery mode)' --class debian --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.19.0-1-amd64-recovery-d689cedc-8dc2-4ebb-919f-fe47b628db44' {
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 d689cedc-8dc2-4ebb-919f-fe47b628db44
else
search --no-floppy --fs-uuid --set=root d689cedc-8dc2-4ebb-919f-fe47b628db44
fi
echo 'Loading Linux 4.19.0-1-amd64 ...'
linux /boot/vmlinuz-4.19.0-1-amd64 root=UUID=d689cedc-8dc2-4ebb-919f-fe47b628db44 ro single
echo 'Loading initial ramdisk ...'
initrd /boot/initrd.img-4.19.0-1-amd64
}
menuentry 'Debian GNU/Linux, with Linux 4.18.0-3-amd64' --class debian --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.18.0-3-amd64-advanced-d689cedc-8dc2-4ebb-919f-fe47b628db44' {
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 d689cedc-8dc2-4ebb-919f-fe47b628db44
else
search --no-floppy --fs-uuid --set=root d689cedc-8dc2-4ebb-919f-fe47b628db44
fi
echo 'Loading Linux 4.18.0-3-amd64 ...'
linux /boot/vmlinuz-4.18.0-3-amd64 root=UUID=d689cedc-8dc2-4ebb-919f-fe47b628db44 ro quiet
echo 'Loading initial ramdisk ...'
initrd /boot/initrd.img-4.18.0-3-amd64
}
menuentry 'Debian GNU/Linux, with Linux 4.18.0-3-amd64 (recovery mode)' --class debian --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.18.0-3-amd64-recovery-d689cedc-8dc2-4ebb-919f-fe47b628db44' {
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 d689cedc-8dc2-4ebb-919f-fe47b628db44
else
search --no-floppy --fs-uuid --set=root d689cedc-8dc2-4ebb-919f-fe47b628db44
fi
echo 'Loading Linux 4.18.0-3-amd64 ...'
linux /boot/vmlinuz-4.18.0-3-amd64 root=UUID=d689cedc-8dc2-4ebb-919f-fe47b628db44 ro single
echo 'Loading initial ramdisk ...'
initrd /boot/initrd.img-4.18.0-3-amd64
}
}
2. 修改grub文件
假设要修改为4.18.0-3
内核启动, 修改文件/etc/default/grub
,运行:sudo vim /etc/default/grub
:
GRUB_DEFAULT=0 修改为
GRUB_DEFAULT="Advanced options for Debian GNU/Linux>Debian GNU/Linux, with Linux 4.18.0-3-amd64"
其中Advanced options for Debian GNU/Linux
是一级菜单,Debian GNU/Linux, with Linux 4.18.0-3-amd64
是二级菜单, 中间用>
连接。
3. 更新修改后的grub
sudo update-grub
这时候重新cat /boot/grub/grub.cfg
可以看到已经更新了,然后reboot
重启后, 用uname -r
就可以看到当前使用的内核已经成功更换。
文章出处:CNBoy 四海部落,刀云转载
刀云免责声明
1、帖子原作者须承担一切因本文发表而直接或间接导致的民事或刑事法律责任。
2、本帖部分内容转载自其它媒体,但并不代表本站赞同其观点和对其真实性负责。
3、如本帖侵犯到任何版权问题,请立即告知本站,本站将及时予与删除并致以最深的歉意。
签名:这个人很懒,什么也没有留下!