輕鬆刪除 Proxmox VE 系統上舊的/未使用的內核

每次更新PVE內核都不會自己刪除因此占用boot分區

現在有了PVE Kernel Cleaner這供工具就很方便

這是一個GITHUB項目是jordanhillis主導的

項目網址: https://github.com/jordanhillis/pvekclean

使用起來很簡單

先到PVE的命令列執行下面的指令

apt update 
apt install cron curl -y
curl -o pvekclean.sh https://raw.githubusercontent.com/jordanhillis/pvekclean/master/pvekclean.sh
chmod +x pvekclean.sh
./pvekclean.sh

執行後會出現以下內容

出現這句 Can we install PVE Kernel Cleaner to your /usr/local/sbin for easier access [y/N] 時要輸入Y

                                                 
    █▀▀█ ▀█ █▀ █▀▀   █ █ █▀▀ █▀▀█ █▀▀▄ █▀▀ █     
    █  █  █▄█  █▀▀   █▀▄ █▀▀ █▄▄▀ █  █ █▀▀ █      
    █▀▀▀   ▀   ▀▀▀   ▀ ▀ ▀▀▀ ▀ ▀▀ ▀  ▀ ▀▀▀ ▀▀▀   
                                                 
    █▀▀ █   █▀▀ █▀▀█ █▀▀▄ █▀▀ █▀▀█               
    █   █   █▀▀ █▄▄█ █  █ █▀▀ █▄▄▀  ⎦˚◡˚⎣ v2.0.2 
    ▀▀▀ ▀▀▀ ▀▀▀ ▀  ▀ ▀  ▀ ▀▀▀ ▀ ▀▀               
       By Jordan Hillis [jordan@hillis.email]    
___________________________________________

Usage: pvekclean.sh [OPTION1] [OPTION2]...

  -k, --keep [number]   Keep the specified number of most recent PVE kernels on the system
                        Can be used with -f or --force for non-interactive removal
  -f, --force           Force the removal of old PVE kernels without confirm prompts
  -rn, --remove-newer   Remove kernels that are newer than the currently running kernel
  -s, --scheduler       Have old PVE kernels removed on a scheduled basis
  -v, --version         Shows current version of pvekclean
  -r, --remove          Uninstall pvekclean from the system
  -i, --install         Install pvekclean to the system
  -d, --dry-run         Run the program in dry run mode for testing without making system changes
___________________________________________

 OS: Debian GNU/Linux 12 (bookworm)
 Boot Disk: 1% full [336K/511M used, 511M free] 
 Current Kernel: 6.8.8-2-pve
___________________________________________

[-] Can we install PVE Kernel Cleaner to your /usr/local/sbin for easier access [y/N] Y
[*] Installed PVE Kernel Cleaner to /usr/local/sbin/pvekclean
[*] Run the command "pvekclean" to begin using this program.
[-] Run the command "pvekclean -r" to remove this program at any time.

再來我們先reboot確定現在是已經執行最新的內核(預設是都會執行最新,如果你有指令開機內核請先修改回預設)

我們在執行以下指令

pvekclean -r

執行後會出現以下內容

出現這句 Are you sure that you would like to remove pvekclean? [y/N] 時要輸入Y

                                                 
    █▀▀█ ▀█ █▀ █▀▀   █ █ █▀▀ █▀▀█ █▀▀▄ █▀▀ █     
    █  █  █▄█  █▀▀   █▀▄ █▀▀ █▄▄▀ █  █ █▀▀ █      
    █▀▀▀   ▀   ▀▀▀   ▀ ▀ ▀▀▀ ▀ ▀▀ ▀  ▀ ▀▀▀ ▀▀▀   
                                                 
    █▀▀ █   █▀▀ █▀▀█ █▀▀▄ █▀▀ █▀▀█               
    █   █   █▀▀ █▄▄█ █  █ █▀▀ █▄▄▀  ⎦˚◡˚⎣ v2.0.2 
    ▀▀▀ ▀▀▀ ▀▀▀ ▀  ▀ ▀  ▀ ▀▀▀ ▀ ▀▀               
       By Jordan Hillis [jordan@hillis.email]    
___________________________________________

Usage: pvekclean [OPTION1] [OPTION2]...

  -k, --keep [number]   Keep the specified number of most recent PVE kernels on the system
                        Can be used with -f or --force for non-interactive removal
  -f, --force           Force the removal of old PVE kernels without confirm prompts
  -rn, --remove-newer   Remove kernels that are newer than the currently running kernel
  -s, --scheduler       Have old PVE kernels removed on a scheduled basis
  -v, --version         Shows current version of pvekclean
  -r, --remove          Uninstall pvekclean from the system
  -i, --install         Install pvekclean to the system
  -d, --dry-run         Run the program in dry run mode for testing without making system changes
___________________________________________

 OS: Debian GNU/Linux 12 (bookworm)
 Boot Disk: 1% full [336K/511M used, 511M free] 
 Current Kernel: 6.8.8-2-pve
___________________________________________

[-] Are you sure that you would like to remove pvekclean? [y/N] Y
[*] Successfully removed PVE Kernel Cleaner from the system!
[-] Sorry to see you go :(

只要看到Successfully removed PVE Kernel Cleaner from the system!就代表已經把舊內核已經全部移除乾淨了

以上操作為首次手動清除,以後只要cron服務有正常運作pvekclean就都會自動幫你清除舊內核!讓你解放雙手

歡迎到討論區跟其他人討論喔

討論區連結

分享你的喜愛

晴れた空

0