Ubuntu16.04删除多余内核版本同时禁止更新内核

问题:

gzip: stdout: No space left on device
E: mkinitramfs failure cpio 141 gzip 1
update-initramfs: failed for /boot/initrd.img-4.15.0-106-generic with 1.
dpkg: error processing package initramfs-tools (--configure):
 subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
 initramfs-tools
E: Sub-process /usr/bin/dpkg returned an error code (1)

在这里插入图片描述

**

解决方法:

**
发现内核有很多版本

df -h  
查看boot内存使用情况
ckq@ckq:~$ df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            7.8G     0  7.8G   0% /dev
tmpfs           1.6G  9.7M  1.6G   1% /run
/dev/nvme0n1p2   47G   22G   23G  49% /
tmpfs           7.9G  218M  7.6G   3% /dev/shm
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
tmpfs           7.9G     0  7.9G   0% /sys/fs/cgroup
/dev/nvme0n1p7  135G  107G   21G  84% /home
/dev/nvme0n1p6  453M  399M   27M  94% /boot
tmpfs           1.6G   48K  1.6G   1% /run/user/1000
/dev/sda8       453M   46M  380M  11% /media/ckq/50c7dfec-bd99-4854-9c3b-86f345c9af76

查看当前使用的内核版本

 uname -a 
ckq@ckq:~$ uname -a 
Linux ckq 4.13.0-36-generic #40~16.04.1-Ubuntu SMP Fri Feb 16 23:25:58 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

1.查看所有的内核

dpkg --get-selections|grep linux
ckq@ckq:~$ dpkg --get-selections|grep linux
console-setup-linux				install
libselinux1:amd64				install
linux-base					install
linux-firmware					install
linux-generic-hwe-16.04				install
linux-headers-4.13.0-36				install
linux-headers-4.13.0-36-generic			install
linux-headers-4.15.0-106			install
linux-headers-4.15.0-106-generic		install
linux-headers-4.15.0-70				install
linux-headers-4.15.0-70-generic			install
linux-headers-4.15.0-72				install
linux-headers-4.15.0-72-generic			install
linux-headers-4.15.0-99				install
linux-headers-4.15.0-99-generic			install
linux-headers-generic-hwe-16.04			install
linux-image-4.13.0-36-generic			install
linux-image-4.15.0-106-generic			install
linux-image-4.15.0-70-generic			install
linux-image-4.15.0-72-generic			install
linux-image-4.15.0-99-generic			install
linux-image-extra-4.13.0-36-generic		install
linux-image-generic-hwe-16.04			install
linux-libc-dev:amd64				install
linux-modules-4.15.0-106-generic		install
linux-modules-4.15.0-70-generic			install
linux-modules-4.15.0-72-generic			install
linux-modules-4.15.0-99-generic			install
linux-modules-extra-4.15.0-106-generic		install
linux-modules-extra-4.15.0-70-generic		install
linux-modules-extra-4.15.0-72-generic		install
linux-modules-extra-4.15.0-99-generic		install
linux-sound-base				install
pptp-linux					install
syslinux					install
syslinux-common					install
syslinux-legacy					install
util-linux					install

竟然如此多!!!!!!

开始!!!!
2.删除内核

sudo apt-get purge linux-image-4.15.0-99-generic 
sudo apt-get purge linux-headers-4.15.0-99(这个会自动把linux-headers-4.15.0-99-generic删除)
sudo apt-get purge linux-modules-4.15.0-99-generic

例如:

ckq@ckq:~$ sudo apt-get purge linux-image-4.15.0-99-generic 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  chromium-codecs-ffmpeg-extra gstreamer1.0-packagekit
  libqt5multimedia5-plugins linux-headers-4.15.0-70
  linux-headers-4.15.0-70-generic linux-headers-4.15.0-72
  linux-headers-4.15.0-72-generic linux-headers-4.15.0-99
  linux-headers-4.15.0-99-generic linux-image-4.15.0-70-generic
  linux-image-4.15.0-72-generic linux-modules-4.15.0-70-generic
  linux-modules-4.15.0-72-generic linux-modules-4.15.0-99-generic
  linux-modules-extra-4.15.0-70-generic linux-modules-extra-4.15.0-72-generic
  notepadqq-common python3-opengl python3-pyqt5 python3-pyqt5.qtmultimedia
  python3-pyqt5.qtquick python3-pyqt5.qtwebkit python3-sip python3-xlib
  qml-module-qtgraphicaleffects qml-module-qtquick-controls
  qml-module-qtquick2 tesseract-ocr-chi-sim tesseract-ocr-chi-tra
  ttf-wqy-microhei
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
  linux-image-4.15.0-99-generic* linux-modules-extra-4.15.0-99-generic*
0 upgraded, 0 newly installed, 2 to remove and 422 not upgraded.
After this operation, 179 MB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 468471 files and directories currently installed.)
Removing linux-modules-extra-4.15.0-99-generic (4.15.0-99.100~16.04.1) ...
Purging configuration files for linux-modules-extra-4.15.0-99-generic (4.15.0-99.100~16.04.1) ...
Removing linux-image-4.15.0-99-generic (4.15.0-99.100~16.04.1) ...
I: /vmlinuz.old is now a symlink to boot/vmlinuz-4.15.0-72-generic
I: /initrd.img.old is now a symlink to boot/initrd.img-4.15.0-72-generic
/etc/kernel/postrm.d/initramfs-tools:
update-initramfs: Deleting /boot/initrd.img-4.15.0-99-generic
/etc/kernel/postrm.d/zz-update-grub:
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.15.0-106-generic
Found initrd image: /boot/initrd.img-4.15.0-106-generic
Found linux image: /boot/vmlinuz-4.15.0-72-generic
Found initrd image: /boot/initrd.img-4.15.0-72-generic
Found linux image: /boot/vmlinuz-4.15.0-70-generic
Found initrd image: /boot/initrd.img-4.15.0-70-generic
Found linux image: /boot/vmlinuz-4.13.0-36-generic
Found initrd image: /boot/initrd.img-4.13.0-36-generic
Found memtest86+ image: /memtest86+.elf
Found memtest86+ image: /memtest86+.bin
Found Windows 10 (loader) on /dev/sda1
Found Ubuntu 14.04.5 LTS (14.04) on /dev/sda6
done
Purging configuration files for linux-image-4.15.0-99-generic (4.15.0-99.100~16.04.1) ...
rmdir: failed to remove '/lib/modules/4.15.0-99-generic': Directory not empty



ckq@ckq:~$ sudo apt-get purge linux-headers-4.15.0-99
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  chromium-codecs-ffmpeg-extra gstreamer1.0-packagekit
  libqt5multimedia5-plugins linux-headers-4.15.0-70
  linux-headers-4.15.0-70-generic linux-headers-4.15.0-72
  linux-headers-4.15.0-72-generic linux-image-4.15.0-70-generic
  linux-image-4.15.0-72-generic linux-modules-4.15.0-70-generic
  linux-modules-4.15.0-72-generic linux-modules-4.15.0-99-generic
  linux-modules-extra-4.15.0-70-generic linux-modules-extra-4.15.0-72-generic
  notepadqq-common python3-opengl python3-pyqt5 python3-pyqt5.qtmultimedia
  python3-pyqt5.qtquick python3-pyqt5.qtwebkit python3-sip python3-xlib
  qml-module-qtgraphicaleffects qml-module-qtquick-controls
  qml-module-qtquick2 tesseract-ocr-chi-sim tesseract-ocr-chi-tra
  ttf-wqy-microhei
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
  linux-headers-4.15.0-99* linux-headers-4.15.0-99-generic*
0 upgraded, 0 newly installed, 2 to remove and 422 not upgraded.
After this operation, 89.0 MB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 463502 files and directories currently installed.)
Removing linux-headers-4.15.0-99-generic (4.15.0-99.100~16.04.1) ...
Removing linux-headers-4.15.0-99 (4.15.0-99.100~16.04.1) ...





ckq@ckq:~$ sudo apt-get purge linux-modules-4.15.0-99-generic
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages were automatically installed and are no longer required:
  chromium-codecs-ffmpeg-extra gstreamer1.0-packagekit
  libqt5multimedia5-plugins linux-headers-4.15.0-70
  linux-headers-4.15.0-70-generic linux-headers-4.15.0-72
  linux-headers-4.15.0-72-generic linux-image-4.15.0-70-generic
  linux-image-4.15.0-72-generic linux-modules-4.15.0-70-generic
  linux-modules-4.15.0-72-generic linux-modules-extra-4.15.0-70-generic
  linux-modules-extra-4.15.0-72-generic notepadqq-common python3-opengl
  python3-pyqt5 python3-pyqt5.qtmultimedia python3-pyqt5.qtquick
  python3-pyqt5.qtwebkit python3-sip python3-xlib
  qml-module-qtgraphicaleffects qml-module-qtquick-controls
  qml-module-qtquick2 tesseract-ocr-chi-sim tesseract-ocr-chi-tra
  ttf-wqy-microhei
Use 'sudo apt autoremove' to remove them.
The following packages will be REMOVED:
  linux-modules-4.15.0-99-generic*
0 upgraded, 0 newly installed, 1 to remove and 422 not upgraded.
After this operation, 65.0 MB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 434222 files and directories currently installed.)
Removing linux-modules-4.15.0-99-generic (4.15.0-99.100~16.04.1) ...
Purging configuration files for linux-modules-4.15.0-99-generic (4.15.0-99.100~16.04.1) ...

最后使用sudo update-grub更新启动菜单

sudo update-grub

此时再看看自己的boot使用情况:

ckq@ckq:~$ df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            7.8G     0  7.8G   0% /dev
tmpfs           1.6G  9.7M  1.6G   1% /run
/dev/nvme0n1p2   47G   19G   26G  42% /
tmpfs           7.9G  340M  7.5G   5% /dev/shm
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
tmpfs           7.9G     0  7.9G   0% /sys/fs/cgroup
/dev/nvme0n1p7  135G  107G   21G  84% /home
/dev/nvme0n1p6  453M  138M  288M  33% /boot
tmpfs           1.6G   60K  1.6G   1% /run/user/1000

使用率33% ,nice 马飞!!!!

最后分析了 应该是自己当时没有关闭内核的自动更新,但是打开文档之后 发现我已经禁止内核更新了, 这就有点闷逼。
打开内核配置文件:

sudo gedit /etc/apt/apt.conf.d/10periodic

将其改成如下:

APT::Periodic::Update-Package-Lists "0";
APT::Periodic::Download-Upgradeable-Packages "0";
APT::Periodic::AutocleanInterval "0";
APT::Periodic::Unattended-Upgrade "0";

将其修改成 :0

参考
参考

  • 2
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值