eee@ubuntu:~$ uname -a
Linux ubuntu 5.4.0-42-generic #46~18.04.1-Ubuntu SMP Fri Jul 10 07:21:24 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
eee@ubuntu:~$ cat /proc/version
Linux version 5.4.0-42-generic (buildd@lgw01-amd64-023) (gcc version 7.5.0 (Ubuntu 7.5.0-3ubuntu1~18.04)) #46~18.04.1-Ubuntu SMP Fri Jul 10 07:21:24 UTC 2020
grep menuentry /boot/grub/grub.cfg
eee@ubuntu:~$ 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-d0c48688-7bd6-4369-a667-e5ef3520c6f5' {
submenu 'Advanced options for Ubuntu' $menuentry_id_option 'gnulinux-advanced-d0c48688-7bd6-4369-a667-e5ef3520c6f5' {
menuentry 'Ubuntu, with Linux 5.4.0-42-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-5.4.0-42-generic-advanced-d0c48688-7bd6-4369-a667-e5ef3520c6f5' {
menuentry 'Ubuntu, with Linux 5.4.0-42-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-5.4.0-42-generic-recovery-d0c48688-7bd6-4369-a667-e5ef3520c6f5' {
menuentry 'Memory test (memtest86+)' {
这里可以看到只有一个版本 5.4.0-42版本
sudo apt-get install linux-headers-x.x.x-x-generic linux-image-x.x.x-x-generic
这样会下载安装你需要的内核版本
eee@ubuntu:~$ sudo apt-get install linux-headers-4.18.0-18-generic linux-image-4.18.0-18-generic
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
linux-headers-4.18.0-18 linux-modules-4.18.0-18-generic
Suggested packages:
fdutils linux-hwe-doc-4.18.0 | linux-hwe-source-4.18.0 linux-hwe-tools
The following NEW packages will be installed:
linux-headers-4.18.0-18 linux-headers-4.18.0-18-generic
linux-image-4.18.0-18-generic linux-modules-4.18.0-18-generic
0 upgraded, 4 newly installed, 0 to remove and 269 not upgraded.
Need to get 33.1 MB of archives.
After this operation, 158 MB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://ftp.sjtu.edu.cn/ubuntu bionic-updates/main amd64 linux-headers-4.18.0-18 all 4.18.0-18.19~18.04.1 [10.5 MB]
Get:2 http://ftp.sjtu.edu.cn/ubuntu bionic-updates/main amd64 linux-headers-4.18.0-18-generic amd64 4.18.0-18.19~18.04.1 [1,126 kB]
Get:3 http://ftp.sjtu.edu.cn/ubuntu bionic-updates/main amd64 linux-modules-4.18.0-18-generic amd64 4.18.0-18.19~18.04.1 [13.3 MB]
Get:4 http://ftp.sjtu.edu.cn/ubuntu bionic-updates/main amd64 linux-image-4.18.0-18-generic amd64 4.18.0-18.19~18.04.1 [8,158 kB]
Fetched 33.1 MB in 17s (1,918 kB/s)
Selecting previously unselected package linux-headers-4.18.0-18.
(Reading database ... 181824 files and directories currently installed.)
Preparing to unpack .../linux-headers-4.18.0-18_4.18.0-18.19~18.04.1_all.deb ...
Unpacking linux-headers-4.18.0-18 (4.18.0-18.19~18.04.1) ...
Selecting previously unselected package linux-headers-4.18.0-18-generic.
Preparing to unpack .../linux-headers-4.18.0-18-generic_4.18.0-18.19~18.04.1_amd64.deb ...
Unpacking linux-headers-4.18.0-18-generic (4.18.0-18.19~18.04.1) ...
Selecting previously unselected package linux-modules-4.18.0-18-generic.
Preparing to unpack .../linux-modules-4.18.0-18-generic_4.18.0-18.19~18.04.1_amd64.deb ...
Unpacking linux-modules-4.18.0-18-generic (4.18.0-18.19~18.04.1) ...
Selecting previously unselected package linux-image-4.18.0-18-generic.
Preparing to unpack .../linux-image-4.18.0-18-generic_4.18.0-18.19~18.04.1_amd64.deb ...
Unpacking linux-image-4.18.0-18-generic (4.18.0-18.19~18.04.1) ...
Setting up linux-modules-4.18.0-18-generic (4.18.0-18.19~18.04.1) ...
Setting up linux-headers-4.18.0-18 (4.18.0-18.19~18.04.1) ...
Setting up linux-headers-4.18.0-18-generic (4.18.0-18.19~18.04.1) ...
Setting up linux-image-4.18.0-18-generic (4.18.0-18.19~18.04.1) ...
I: /vmlinuz.old is now a symlink to boot/vmlinuz-5.4.0-42-generic
I: /vmlinuz is now a symlink to boot/vmlinuz-4.18.0-18-generic
I: /initrd.img is now a symlink to boot/initrd.img-4.18.0-18-generic
Processing triggers for linux-image-4.18.0-18-generic (4.18.0-18.19~18.04.1) ...
/etc/kernel/postinst.d/initramfs-tools:
update-initramfs: Generating /boot/initrd.img-4.18.0-18-generic
/etc/kernel/postinst.d/zz-update-grub:
Sourcing file `/etc/default/grub'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.4.0-42-generic
Found initrd image: /boot/initrd.img-5.4.0-42-generic
Found linux image: /boot/vmlinuz-4.18.0-18-generic
Found initrd image: /boot/initrd.img-4.18.0-18-generic
Found memtest86+ image: /boot/memtest86+.elf
Found memtest86+ image: /boot/memtest86+.bin
done
再次查看版本
eee@ubuntu:~$ 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-d0c48688-7bd6-4369-a667-e5ef3520c6f5' {
submenu 'Advanced options for Ubuntu' $menuentry_id_option 'gnulinux-advanced-d0c48688-7bd6-4369-a667-e5ef3520c6f5' {
menuentry 'Ubuntu, with Linux 5.4.0-42-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-5.4.0-42-generic-advanced-d0c48688-7bd6-4369-a667-e5ef3520c6f5' {
menuentry 'Ubuntu, with Linux 5.4.0-42-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-5.4.0-42-generic-recovery-d0c48688-7bd6-4369-a667-e5ef3520c6f5' {
menuentry 'Ubuntu, with Linux 4.18.0-18-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.18.0-18-generic-advanced-d0c48688-7bd6-4369-a667-e5ef3520c6f5' {
menuentry 'Ubuntu, with Linux 4.18.0-18-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.18.0-18-generic-recovery-d0c48688-7bd6-4369-a667-e5ef3520c6f5' {
menuentry 'Memory test (memtest86+)' {
menuentry 'Memory test (memtest86+, serial console 115200)' {
发现多了 4.18.0-18 这个版本
sudo vim /etc/default/grub
eee@ubuntu:~$ sudo vim /etc/default/grub
[sudo] password for eee:
Sorry, try again.
[sudo] password for eee:
# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.
# For full documentation of the options in this file, see:
# info -f grub -n 'Simple configuration'
GRUB_DEFAULT=0 #修改这里
GRUB_TIMEOUT_STYLE=hidden
GRUB_TIMEOUT=0
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet"
GRUB_CMDLINE_LINUX="find_preseed=/preseed.cfg auto noprompt priority=critical locale=en_US"
# Uncomment to enable BadRAM filtering, modify to suit your needs
# This works with Linux (no patch required) and with any kernel that obtains
# the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
#GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"
# Uncomment to disable graphical terminal (grub-pc only)
#GRUB_TERMINAL=console
# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'
#GRUB_GFXMODE=640x480
# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
#GRUB_DISABLE_LINUX_UUID=true
# Uncomment to disable generation of recovery mode menu entries
#GRUB_DISABLE_RECOVERY="true"
# Uncomment to get a beep at grub start
#GRUB_INIT_TUNE="480 440 1"
GRUB_DEFAULT=0 修改成下面(d0c48688-7bd6-4369-a667-e5ef3520c6f5 是用grep menuentry /boot/grub/grub.cfg查看到的命令里)
GRUB_DEFAULT=“gnulinux-advanced-d0c48688-7bd6-4369-a667-e5ef3520c6f5>gnulinux-4.18.0-18-generic-advanced-d0c48688-7bd6-4369-a667-e5ef3520c6f5”
sudo update-grub
eee@ubuntu:~$ sudo update-grub
[sudo] password for eee:
Sourcing file `/etc/default/grub'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.4.0-42-generic
Found initrd image: /boot/initrd.img-5.4.0-42-generic
Found linux image: /boot/vmlinuz-4.18.0-18-generic
Found initrd image: /boot/initrd.img-4.18.0-18-generic
Found memtest86+ image: /boot/memtest86+.elf
Found memtest86+ image: /boot/memtest86+.bin
done
sudo reboot
eee@ubuntu:~$ sudo reboot
eee@ubuntu:~$ uname -a
Linux ubuntu 4.18.0-18-generic #19~18.04.1-Ubuntu SMP Fri Apr 5 10:22:13 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux