/boot 磁碟空間不足時要刪除哪個核心版本?

/boot 磁碟空間不足時要刪除哪個核心版本?

在 Ubuntu 20.04 上執行時,嘗試更新時出現 /boot 磁碟空間不足錯誤訊息。

The upgrade needs a total of 228 M free space on disk '/boot'. Please free at least an additional 24,8 M of disk space on '/boot'.

在我的 /boot 資料夾中,我有以下檔案:

/boot
total 460452
drwx------ 3 root root      4096 Jan  1  1970 efi
-rw-r--r-- 1 root root    184884 Aug 18  2020 memtest86+_multiboot.bin
-rw-r--r-- 1 root root    184380 Aug 18  2020 memtest86+.elf
-rw-r--r-- 1 root root    182704 Aug 18  2020 memtest86+.bin
drwx------ 2 root root     16384 Feb  2  2021 lost+found
-rw------- 1 root root   6219821 Jan  6 17:21 System.map-5.15.0-58-generic
-rw-r--r-- 1 root root    262181 Jan  6 17:21 config-5.15.0-58-generic
-rw------- 1 root root  11450528 Jan  6 17:21 vmlinuz-5.15.0-58-generic
-rw-r--r-- 1 root root 217500477 Jan 20 06:33 initrd.img-5.15.0-58-generic
-rw------- 1 root root   6221223 Jan 25 10:27 System.map-5.15.0-60-generic
-rw-r--r-- 1 root root    262215 Jan 25 10:27 config-5.15.0-60-generic
-rw------- 1 root root  11458344 Jan 25 10:29 vmlinuz-5.15.0-60-generic
lrwxrwxrwx 1 root root        25 Feb  9 06:53 vmlinuz.old -> vmlinuz-5.15.0-58-generic
lrwxrwxrwx 1 root root        25 Feb  9 06:53 vmlinuz -> vmlinuz-5.15.0-60-generic
lrwxrwxrwx 1 root root        28 Feb  9 06:53 initrd.img.old -> initrd.img-5.15.0-58-generic
lrwxrwxrwx 1 root root        28 Feb  9 06:53 initrd.img -> initrd.img-5.15.0-60-generic
-rw-r--r-- 1 root root 217514515 Feb  9 06:53 initrd.img-5.15.0-60-generic
drwxr-xr-x 4 root root      4096 Feb  9 06:54 grub

命令“uname -a”返回:

uname -a
Linux balazskocsis 5.15.0-60-generic #66~20.04.1-Ubuntu SMP Wed Jan 25 09:41:30 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

當我列出 dpkg 軟體包時,我得到:

dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d'
linux-generic-hwe-20.04
linux-headers-5.15.0-58-generic
linux-headers-5.8.0-63-generic
linux-headers-generic-hwe-20.04
linux-hwe-5.15-headers-5.15.0-58
linux-hwe-5.8-headers-5.8.0-63
linux-image-5.15.0-58-generic
linux-image-generic-hwe-20.04
linux-libc-dev:amd64
linux-modules-5.15.0-58-generic
linux-modules-extra-5.15.0-58-generic

我相信我需要使用 purge 命令清理內核版本 5-15.0-58:

sudo apt-get -y purge linux-modules-5.15.0-58-generic

但我不太確定。

如果我解釋正確的話:

lrwxrwxrwx 1 root root        25 Feb  9 06:53 vmlinuz.old -> vmlinuz-5.15.0-58-generic
lrwxrwxrwx 1 root root        25 Feb  9 06:53 vmlinuz -> vmlinuz-5.15.0-60-generic

目前版本是5.15.0-60,5.15.0-58的可以刪除。

考慮到 /boot 資料夾清單和 uname -a 的輸出,刪除 5.15.0-58 版本是否安全?

答案1

如果您確定核心版本 5.15.0-60 正常運作,那麼您可以刪除核心版本 5-15.0-58。

在我的系統上,舊核心的以下檔案會自動刪除:

linux-modules-extra-5.15.0-xx-generic
linux-modules-5.15.0-xx-generic
linux-image-5.15.0-xx-generic
linux-headers-5.15.0-xx-generic
linux-headers-5.15.0-xx

所以你可以運行:

sudo apt remove --purge linux-modules-extra-5.15.0-58-generic linux-modules-5.15.0-58-generic linux-image-5.15.0-58-generic linux-headers-5.15.0-58-generic linux-headers-5.15.0-58

但是,請注意,透過這樣做,您拆除安全網安裝了備份核心(前一個),並且只會有一個工作內核在系統上。

從長遠來看,擴充/boot分割區是更明智的做法,這樣 Ubuntu 就可以在安裝了 2 個工作核心的情況下正常運作。

相關內容