How remove old PVE Images

informant

Renowned Member
Jan 31, 2012
802
11
83
Hi all, how can i remove old PVE images:

Code:
Found linux image: /boot/vmlinuz-2.6.32-25-pve
Found initrd image: /boot/initrd.img-2.6.32-25-pve
Found linux image: /boot/vmlinuz-2.6.32-24-pve
Found initrd image: /boot/initrd.img-2.6.32-24-pve
Found linux image: /boot/vmlinuz-2.6.32-23-pve
Found initrd image: /boot/initrd.img-2.6.32-23-pve
Found linux image: /boot/vmlinuz-2.6.32-22-pve
Found initrd image: /boot/initrd.img-2.6.32-22-pve
Found linux image: /boot/vmlinuz-2.6.32-21-pve
Found initrd image: /boot/initrd.img-2.6.32-21-pve
Found linux image: /boot/vmlinuz-2.6.32-20-pve
Found initrd image: /boot/initrd.img-2.6.32-20-pve
Found linux image: /boot/vmlinuz-2.6.32-19-pve
Found initrd image: /boot/initrd.img-2.6.32-19-pve
Found linux image: /boot/vmlinuz-2.6.32-18-pve
Found initrd image: /boot/initrd.img-2.6.32-18-pve
Found linux image: /boot/vmlinuz-2.6.32-17-pve
Found initrd image: /boot/initrd.img-2.6.32-17-pve
Found linux image: /boot/vmlinuz-2.6.32-16-pve
Found initrd image: /boot/initrd.img-2.6.32-16-pve

regards
 
# dpkg -r pve-kernel-2.6.32-16-pve
# dpkg -r pve-kernel-2.6.32-17-pve
# dpkg -r pve-kernel-2.6.32-18-pve
...
 
Biggest Thankls @dietmar.

Can you include a option, to remove automatical old images and only last 3 images aren´t delete?

regards
 
You will have to use Script to achieve that. I dont think there is a single Linux command which will auto delete based on criteria. Below is a sample code that you can start with. Test it before you put it in action:

if [[ $(ls /boot/vmlinuz*.* | wc -l) > 10 ]]then
find /boot/vmlinuz*.* ! -newer $(ls -t | sed '11!d') -exec rm {} \; fi

This example keeps 10 files then deletes older files. You can just switch 10 to 3. But... DO EXPERIMENT FIRST ON TEST FOLDER!!