Welcome to the Linux Foundation Forum!

Wastage of memory due to multiple compiled kernels copies .

Hello ,
During the course , I had compiled some 7-8 kernels by that i mean different versions or the same kernel version multiple times due to some issues , so now these copies of the compiled kernels stay in my memory and are taking up a lot of space (almost ~70GB) . Is there a way i can delete a copy or any of the kernel version that i am not using right now ?
Also how much storage do you keep reserved for kernel development in your system ?

Comments

  • imanseyed
    imanseyed Posts: 10

    Hi there,

    If you have installed them, you just need to delete them from these paths:

    /lib/modules/$KVER
    /boot/vmlinuz-$KVER
    /boot/initr*-$KVER
    

    This is how I do it on Arch Linux using fish (I just keep my most recent build and the linux package kernel):

    set -l old_imgs (ls /lib/modules | grep -Ev "^$(uname -r)\$|arch" | sort)
    for old_img in $old_imgs
        echo Purging v$old_img...
        sudo rm -rI /usr/lib/modules/$old_img \
            /boot/vmlinuz-$old_img \
            /boot/initramfs-$old_img.img
    end
    sudo grub-mkconfig -o /boot/grub/grub.cfg
    

    If you are working with different Linux trees, you can reduce disk usage by adding each tree as a new remote and fetching, instead of cloning the entire tree again. This roughly minimizes the size of each tree (normally 5–6 GB) to around ~1.5 GB per new remote. Unfortunately, there's no way around needing at least 30~40 GB for kernel development if you are actively working on different subsystems with different trees. Especially if you are keeping your different builds.

  • hannelotta
    hannelotta Posts: 3

    If you're using Ubuntu or Debian, there are apt-get commands to remove kernel versions (purge). It might be a better option than removing folder contents manually. Make sure you're not removing a kernel you are currently using.

  • imanseyed
    imanseyed Posts: 10

    @hannelotta said:
    If you're using Ubuntu or Debian, there are apt-get commands to remove kernel versions (purge). It might be a better option than removing folder contents manually. Make sure you're not removing a kernel you are currently using.

    Note that apt can't detect custom kernels/initramfs images installed using /sbin/installkernel (i.e., via make install). It only manages kernels installed from the repositories, and removes them based on the file list found in:
    /var/lib/dpkg/info/<packagename>.list

  • hannelotta
    hannelotta Posts: 3

    @imanseyed You are right! I just realized the custom installed kernels are not listed with dpkg --list | grep linux-image. Thanks for the clarification.

Categories

Upcoming Training