Debian 更换 Cloud内核

    305

Debian 更换 Cloud内核可降低内存占用

前言

Debain 12

# 原内核
root@ser2954483427:~# uname -r
6.1.0-10-amd64

内存 2G【系统显示1.92G】 在Debian12初始化后内存使用 htop查看 Mem占用在92-93M 使用 free -m查看 Mem占用

             total        used       free      shared    buff/cache   available
Mem:         1967         239        1497        1         375        1728
Swap:          0           0           0

apt 更新

apt update -y && apt dist-upgrade -y

查看系统现有内核

dpkg -l|grep linux-image
root@ser2954483427:~# dpkg -l|grep linux-image
ii  linux-image-6.1.0-10-amd64     6.1.37-1                       amd64        Linux 6.1 for 64-bit PCs (signed)
ii  linux-image-6.1.0-9-amd64      6.1.27-1                       amd64        Linux 6.1 for 64-bit PCs (signed)
ii  linux-image-amd64              6.1.37-1                       amd64        Linux for 64-bit PCs (meta-package)

查看最新 cloud 内核

apt-cache search linux-image | grep cloud
root@ser2954483427:~# apt-cache search linux-image | grep cloud
linux-headers-6.1.0-18-cloud-amd64 - Header files for Linux 6.1.0-18-cloud-amd64
linux-headers-6.1.0-22-cloud-amd64 - Header files for Linux 6.1.0-22-cloud-amd64
linux-image-6.1.0-18-cloud-amd64-dbg - Debug symbols for linux-image-6.1.0-18-cloud-amd64
linux-image-6.1.0-18-cloud-amd64-unsigned - Linux 6.1 for x86-64 cloud
linux-image-6.1.0-22-cloud-amd64-dbg - Debug symbols for linux-image-6.1.0-22-cloud-amd64
linux-image-6.1.0-22-cloud-amd64-unsigned - Linux 6.1 for x86-64 cloud
linux-image-cloud-amd64-dbg - Debugging symbols for Linux cloud-amd64 configuration (meta-package)
linux-image-6.1.0-18-cloud-amd64 - Linux 6.1 for x86-64 cloud (signed)
linux-image-6.1.0-22-cloud-amd64 - Linux 6.1 for x86-64 cloud (signed)
linux-image-cloud-amd64 - Linux for x86-64 cloud (meta-package)
linux-headers-6.1.0-16-cloud-amd64 - Header files for Linux 6.1.0-16-cloud-amd64
linux-image-6.1.0-16-cloud-amd64-dbg - Debug symbols for linux-image-6.1.0-16-cloud-amd64
linux-image-6.1.0-16-cloud-amd64-unsigned - Linux 6.1 for x86-64 cloud
linux-image-6.1.0-16-cloud-amd64 - Linux 6.1 for x86-64 cloud (signed)
linux-headers-6.10.6+bpo-cloud-amd64 - Header files for Linux 6.10.6+bpo-cloud-amd64
linux-headers-6.9.10+bpo-cloud-amd64 - Header files for Linux 6.9.10+bpo-cloud-amd64
linux-headers-6.9.7+bpo-cloud-amd64 - Header files for Linux 6.9.7+bpo-cloud-amd64
linux-image-6.10.6+bpo-cloud-amd64-dbg - Debug symbols for linux-image-6.10.6+bpo-cloud-amd64
linux-image-6.10.6+bpo-cloud-amd64-unsigned - Linux 6.10 for x86-64 cloud
linux-image-6.9.10+bpo-cloud-amd64-dbg - Debug symbols for linux-image-6.9.10+bpo-cloud-amd64
linux-image-6.9.10+bpo-cloud-amd64-unsigned - Linux 6.9 for x86-64 cloud
linux-image-6.9.7+bpo-cloud-amd64-dbg - Debug symbols for linux-image-6.9.7+bpo-cloud-amd64
linux-image-6.9.7+bpo-cloud-amd64-unsigned - Linux 6.9 for x86-64 cloud
linux-image-6.10.6+bpo-cloud-amd64 - Linux 6.10 for x86-64 cloud (signed)
linux-image-6.9.10+bpo-cloud-amd64 - Linux 6.9 for x86-64 cloud (signed)
linux-image-6.9.7+bpo-cloud-amd64 - Linux 6.9 for x86-64 cloud (signed)

安装 Cloud 内核

apt install linux-headers-6.1.0-18-cloud-amd64  \
    linux-image-cloud-amd64 -y

或者使用官方源的简单安装,不安装内核头文件只安装内核

apt install linux-image-cloud-amd64 -y

更新引导文件

update-grub

关机重启

reboot

验证是否安装成功

uname -r
# 输入以下 cloud内核
root@ser2954483427:~# uname -r
6.1.0-22-cloud-amd64

验证内存占用

使用 htop查看 Mem占用在75-76M 使用 free -m查看 Mem占用

root@ser2954483427:~# free -m
               total        used        free      shared  buff/cache   available
Mem:            1979         194        1813           0          90        1784
Swap:              0           0           0

卸载旧内核

此时的 linux-image-6.1.0-10-amd64 与【第二步:查看系统现有内核】查看的版本一致

dpkg --get-selections | grep linux
apt autoremove --purge linux-image-6.1.0-10-amd64
apt autoremove --purge linux-image-6.1.0-9-amd64
apt autoremove
apt autoclean

后记

关于 freehtop内存占用不一的情况参考以下博文

消息盒子

# 暂无消息 #

只显示最新10条未读和已读信息