ubuntu18.04 LTS解决/boot空间不足

1. 查看磁盘占用情况

df -h 

Filesystem      Size  Used Avail Use% Mounted on
/dev/nvme0n1p5  181M  141M   27M  85% /boot
/dev/nvme0n1p8   71G   26G   41G  39% /home
/dev/nvme0n1p1   96M   48M   49M  50% /boot/efi
tmpfs           1.6G   16K  1.6G   1% /run/user/121
tmpfs           1.6G   44K  1.6G   1% /run/user/1000

发现/boot确实占用率很高。

2. uname -a (查看当前使用的内核版本)

lenmom@M1701:~$ uname -a
Linux M1701 4.15.0-43-generic #46-Ubuntu SMP Thu Dec 6 14:45:28 UTC 2018 x86_64 

3.查看已安装的内核版本

lenmom@M1701:~$ dpkg --get-selections |grep linux
binutils-x86-64-linux-gnu            install
console-setup-linux                install
libselinux1:amd64                install
linux-base                    install
linux-firmware                    install
linux-generic                    install
linux-headers-4.15.0-39                install
linux-headers-4.15.0-39-generic            install
linux-headers-4.15.0-43                install
linux-headers-4.15.0-43-generic            install
linux-headers-generic                install
linux-image-4.15.0-29-generic            deinstall
linux-image-4.15.0-39-generic            install
linux-image-4.15.0-43-generic            install
linux-image-generic                install
linux-libc-dev:amd64                install
linux-modules-4.15.0-29-generic            deinstall
linux-modules-4.15.0-39-generic            install
linux-modules-4.15.0-43-generic            install
linux-modules-extra-4.15.0-29-generic        deinstall
linux-modules-extra-4.15.0-39-generic        install
linux-modules-extra-4.15.0-43-generic        install
linux-signed-generic                install
linux-sound-base                install
pptp-linux                    install
syslinux                    install
syslinux-common                    install
syslinux-legacy                    install
util-linux                    install

能看到已经安装的版本,其中带image的一般就是旧版本,其中

a)deinstall代表是已经删除的旧版本
b)  install是还没有删除的旧版本内核​​

4. 删除多余的内核文件

通过uname -a可以查看到当前正在使用的内核版本,把不是当前版本的处于install状态的image-xxx-generic文件卸载掉,对于本例中linux-modules-extra-4.15.0-39-generic是多余的内核文件,正在使用的是linux-modules-extra-4.15.0-43-generic,开始卸载。

卸载命令为sudo apt-get remove linux-modules-xxx-generic,其中xxx为要卸载的内核版本号

lenmom@M1701:~$ sudo apt-get remove linux-modules-4.15.0-39-generic
Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following packages will be REMOVED:
  linux-image-4.15.0-39-generic linux-modules-4.15.0-39-generic
0 upgraded, 0 newly installed, 2 to remove and 105 not upgraded.
1 not fully installed or removed.
After this operation, 74.6 MB disk space will be freed.
Do you want to continue? [Y/n] y
(Reading database ... 187447 files and directories currently installed.)
Removing linux-image-4.15.0-39-generic (4.15.0-39.42) ...
I: /vmlinuz.old is now a symlink to boot/vmlinuz-4.15.0-43-generic
I: /initrd.img.old is now a symlink to boot/initrd.img-4.15.0-43-generic
/etc/kernel/postrm.d/initramfs-tools:
update-initramfs: Deleting /boot/initrd.img-4.15.0-39-generic
/etc/kernel/postrm.d/zz-update-grub:
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.15.0-43-generic
Found initrd image: /boot/initrd.img-4.15.0-43-generic
Found Windows Boot Manager on /dev/nvme0n1p1@/EFI/Microsoft/Boot/bootmgfw.efi
Adding boot menu entry for EFI firmware configuration
done
Removing linux-modules-4.15.0-39-generic (4.15.0-39.42) ...
Setting up initramfs-tools (0.130ubuntu3.5) ...
update-initramfs: deferring update (trigger activated)
Processing triggers for initramfs-tools (0.130ubuntu3.5) ...
update-initramfs: Generating /boot/initrd.img-4.15.0-43-generic
W: APT had planned for dpkg to do more than it reported back (6 vs 10).
   Affected packages: initramfs-tools:amd64

5. 使用du -h再次查看/boot空间

lenmom@M1701:~$ df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/nvme0n1p5  181M   75M   94M  45% /boot
/dev/nvme0n1p8   71G   26G   41G  39% /home
/dev/nvme0n1p1   96M   48M   49M  50% /boot/efi
tmpfs           1.6G   16K  1.6G   1% /run/user/121
tmpfs           1.6G   44K  1.6G   1% /run/user/1000

我们发现,/boot空间的确已经释放出来了。

猜你喜欢

转载自www.cnblogs.com/lenmom/p/10301155.html
今日推荐