IT数码 购物 网址 头条 软件 日历 阅读 图书馆
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
图片批量下载器
↓批量下载图片,美女图库↓
图片自动播放器
↓图片自动播放器↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁
 
   -> 系统运维 -> 03 | 更换ubuntu 的内核 -> 正文阅读

[系统运维]03 | 更换ubuntu 的内核

1 查看磁盘的使用

1.1 执行:fdisk -l

root@prd-devel-00:~# fdisk  -l
Disk /dev/xvda: 80 GiB, 85899345920 bytes, 167772160 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 220A9CAE-DBE1-4257-B914-ED96A7341E70

Device     Start       End   Sectors Size Type
/dev/xvda1  2048      4095      2048   1M BIOS boot
/dev/xvda2  4096 167770111 167766016  80G Linux filesystem

Disk /dev/xvdb: 50 GiB, 53687091200 bytes, 104857600 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xb5162423

Device     Boot Start       End   Sectors Size Id Type
/dev/xvdb1       2048 104857599 104855552  50G 83 Linux

Disk /dev/xvdc: 80 GiB, 85899345920 bytes, 167772160 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x30a2dd50

Device     Boot   Start       End   Sectors  Size Id Type
/dev/xvdc1         2048   1953791   1951744  953M 83 Linux
/dev/xvdc2      1953792 167770111 165816320 79.1G 83 Linux

1.2 查看是否有挂载:df -h

root@prd-devel-00:~# df  -h
Filesystem      Size  Used Avail Use% Mounted on
udev            7.8G     0  7.8G   0% /dev
tmpfs           1.6G  772K  1.6G   1% /run
/dev/xvda2       79G   35G   41G  46% /
tmpfs           7.9G     0  7.9G   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           7.9G     0  7.9G   0% /sys/fs/cgroup
/dev/xvdb1       49G  355M   47G   1% /data
tmpfs           1.6G     0  1.6G   0% /run/user/0

2 安装linux-image-4.15.0.112-generic

2.1 第一次安装

apt-get install linux-image-4.15.0.112-generic

提示:
E: dpkg was interrupted, you must manually run ‘dpkg --configure -a’ to correct the problem.

通过执行

dpkg --configure -a

在这里插入图片描述
根据1中磁盘使用情况,选中【xvda】,点击【OK】

Installing for i386-pc platform.                                                                                                                                                                                                           
Installation finished. No error reported.
Sourcing file `/etc/default/grub'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.15.0-144-generic
Found initrd image: /boot/initrd.img-4.15.0-144-generic
Found linux image: /boot/vmlinuz-4.15.0-143-generic
Found initrd image: /boot/initrd.img-4.15.0-143-generic
Found linux image: /boot/vmlinuz-4.15.0-142-generic
Found initrd image: /boot/initrd.img-4.15.0-142-generic
Found linux image: /boot/vmlinuz-4.15.0-112-generic
Found Ubuntu 16.04.7 LTS (16.04) on /dev/xvdc2
done
Processing triggers for linux-image-4.15.0-112-generic (4.15.0-112.113) ...
/etc/kernel/postinst.d/initramfs-tools:
update-initramfs: Generating /boot/initrd.img-4.15.0-112-generic
/etc/kernel/postinst.d/x-grub-legacy-ec2:
Searching for GRUB installation directory ... found: /boot/grub
Searching for default file ... found: /boot/grub/default
Testing for an existing GRUB menu.lst file ... found: /boot/grub/menu.lst
Searching for splash image ... none found, skipping ...
Found kernel: /boot/vmlinuz-4.15.0-144-generic
Found kernel: /boot/vmlinuz-4.15.0-143-generic
Found kernel: /boot/vmlinuz-4.15.0-142-generic
dpkg-query: error: package 'grub-legacy-ec2' is not installed
run-parts: /etc/kernel/postinst.d/x-grub-legacy-ec2 exited with return code 10
dpkg: error processing package linux-image-4.15.0-112-generic (--configure):
 installed linux-image-4.15.0-112-generic package post-installation script subprocess returned error exit status 1
Processing triggers for mime-support (3.60ubuntu1) ...
Processing triggers for initramfs-tools (0.130ubuntu3.13) ...
update-initramfs: Generating /boot/initrd.img-4.15.0-144-generic
Errors were encountered while processing:
 linux-image-4.15.0-112-generic
root@prd-devel-00:~# 

2.2 第二次安装

执行:

apt-get install linux-image-4.15.0.112-generic

2.3 /etc/default/grub(没有修改前)

root@prd-devel-00:~# cat  /etc/default/grub
# 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="maybe-ubiquity"
GRUB_CMDLINE_LINUX=""

# 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"

2.4 修改/etc/default/grub

2.4.1 /etc/default/grub(第一次修改)

注意:#把GRUB_DEFAULT=0 修改成Ubuntu, with Linux 4.15.0-112-generic

root@prd-devel-00:~# vim   /etc/default/grub
# 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_DEFAULT="Ubuntu, with Linux 4.15.0-112-generic"
GRUB_TIMEOUT_STYLE=hidden
GRUB_TIMEOUT=0
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="maybe-ubiquity"
GRUB_CMDLINE_LINUX=""

# 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"
~
"/etc/default/grub" 34L, 1265C written                                                                                                                                                                          
root@prd-devel-00:~# 

2.4.2 执行sudo update-grub

执行:
sudo update-grub

root@prd-devel-00:~# sudo update-grub
Sourcing file `/etc/default/grub'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.15.0-144-generic
Found initrd image: /boot/initrd.img-4.15.0-144-generic
Found linux image: /boot/vmlinuz-4.15.0-143-generic
Found initrd image: /boot/initrd.img-4.15.0-143-generic
Found linux image: /boot/vmlinuz-4.15.0-142-generic
Found initrd image: /boot/initrd.img-4.15.0-142-generic
Found linux image: /boot/vmlinuz-4.15.0-112-generic
Found initrd image: /boot/initrd.img-4.15.0-112-generic
Warning: Please don't use old title `Ubuntu, with Linux 4.15.0-112-generic' for GRUB_DEFAULT, use `Advanced options for Ubuntu>Ubuntu, with Linux 4.15.0-112-generic' (for versions before 2.00) or `gnulinux-advanced-38face64-c681-40da-bd85-89e309309888>gnulinux-4.15.0-112-generic-advanced-38face64-c681-40da-bd85-89e309309888' (for 2.00 or later)
Found Ubuntu 16.04.7 LTS (16.04) on /dev/xvdc2

2.4.3 /etc/default/grub(第二次修改)

root@prd-devel-00:~# vim /etc/default/grub
# 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_DEFAULT='gnulinux-advanced-38face64-c681-40da-bd85-89e309309888>gnulinux-4.15.0-112-generic-advanced-38face64-c681-40da-bd85-89e309309888'
GRUB_TIMEOUT_STYLE=hidden
GRUB_TIMEOUT=0
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="maybe-ubiquity"
GRUB_CMDLINE_LINUX=""

# 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"

"/etc/default/grub" 34L, 1356C written                                                                                                                                                                          
root@prd-devel-00:~#

2.4.4 执行sudo update-grub

sudo update-grub

2.5 重启服务reboot

3 验证

查看内核:uname -r
在这里插入图片描述

注意:遇到内核没有更新过来,那就需要多重启几次。

4 安装过程中遇到问题

4.1 提示:E: Sub-process /usr/bin/dpkg returned an error code (1)

在这里插入图片描述
解决方法:

cd /var/lib/dpkg/
sudo mv info/ info-bak
sudo mkdir info
sudo apt-get update
sudo apt-get -f install
sudo mv info/* info-bak/
sudo rm -rf info
sudo mv info-bak info
  系统运维 最新文章
配置小型公司网络WLAN基本业务(AC通过三层
如何在交付运维过程中建立风险底线意识,提
快速传输大文件,怎么通过网络传大文件给对
从游戏服务端角度分析移动同步(状态同步)
MySQL使用MyCat实现分库分表
如何用DWDM射频光纤技术实现200公里外的站点
国内顺畅下载k8s.gcr.io的镜像
自动化测试appium
ctfshow ssrf
Linux操作系统学习之实用指令(Centos7/8均
上一篇文章      下一篇文章      查看所有文章
加:2022-09-13 11:56:34  更:2022-09-13 11:58:26 
 
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁

360图书馆 购物 三丰科技 阅读网 日历 万年历 2024年11日历 -2024/11/25 21:28:52-

图片自动播放器
↓图片自动播放器↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  IT数码