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 ?

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Comments

  • Posts: 10

    Hi there,

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

    1. /lib/modules/$KVER
    2. /boot/vmlinuz-$KVER
    3. /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):

    1. set -l old_imgs (ls /lib/modules | grep -Ev "^$(uname -r)\$|arch" | sort)
    2. for old_img in $old_imgs
    3. echo Purging v$old_img...
    4. sudo rm -rI /usr/lib/modules/$old_img \
    5. /boot/vmlinuz-$old_img \
    6. /boot/initramfs-$old_img.img
    7. end
    8. 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.

  • 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.

  • 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

  • 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.

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Welcome!

It looks like you're new here. Sign in or register to get started.
Sign In

Categories

Upcoming Training