/usr/src is eating up all inodes

11,057

Solution 1

Try this.

Open a terminal and enter:

~$ cd /usr/src
/usr/src$ ls

You will see something like this:

total 16K
drwxr-xr-x 24 root root 4,0K Σεπ  29 22:35 linux-headers-3.2.0-54/
drwxr-xr-x  7 root root 4,0K Σεπ  29 22:35 linux-headers-3.2.0-54-generic/
drwxr-xr-x  3 root root 4,0K Σεπ  29 22:56 nvidia-319-319.32/

The output may (and will) differ according to your set up.

Take a close look at the folders named linux-headers-*. These are the headers from all your linux images that you have installed. If you have too many of them, they will take up A LOT of space and inodes. You only need to keep the latest one you boot from.

Let's say you have an older kernel, eg. 3.2.0-53. To remove it, type:

sudo apt-get remove --purge linux-image-3.2.0-53-generic linux-headers-3.2.0-53 linux-headers-3.2.0-53-generic

for each one of them.

If all of the above fail, then try to delete the OLDER KERNEL headers' folders manually:

sudo rm -rf /usr/src/linux-headers-3.2.0-53{,-generic}

Solution 2

You can try Ubuntu Tweak to clean old kernels. First install it using these commands

sudo add-apt-repository ppa:tualatrix/ppa
sudo apt-get update
sudo apt-get install ubuntu-tweak

Run the program and then:

  1. Select the "Janitor" tab
  2. Select the "Old Kernel" checkbox
  3. Select kernel versions to remove (keep 2 at leats - just in case)
  4. Press "Clean"

enter image description here

Solution 3

I just had the same issue

On Ubuntu Linux 16.04.1 it seems that sudo apt autoremove will clean up all the unnecessary /usr/src/linux-headers- files and free the corresponding inodes

Share:
11,057
klingone
Author by

klingone

Updated on September 18, 2022

Comments

  • klingone
    klingone over 1 year

    It seems /usr/src (apparently old kernels) used up all my inodes:

    Filesystem             Inodes  IUsed     IFree IUse% Mounted on
    /dev/sda4              489600   489600       0  100% /
    devtmpfs               219658      539  219119    1% /dev
    none                   219844      474  219370    1% /run
    none                   219844        3  219841    1% /run/lock
    none                   219844        8  219836    1% /run/shm
    /dev/sda6             5963776     8361 5955415    1% /home
    

    I tried everything to remove/purge, etc. the old kernels, without success. dpkg is not working anymore. I tried a few manual commands, but 12.04 gives me nothing. apt-get, etc. is not possible due to lack of space on the hard drive, which is not the problem obviously. However I cannot install or remove anything! I read a lot about users with the same problem, but their solutions are not working for me.

    Please help. Thanks a lot!

    • Admin
      Admin over 10 years
      Boot from a live cd/usb and run some filesystem checks. 'df -i' gives you inode usage. You can remove manually (or move to safe location) some files that are in the offending folders to free inodes. Then try again as per my answer to clean up.
    • Admin
      Admin over 10 years
      Try booting in single-user mode, that might give you more control.
    • Admin
      Admin over 10 years
      @klingone - you appear to have multiple accounts. Please register one of these accounts. Then click the contact-us link at the bottom of this page to request that your other accounts are merged. Once done, you'll be able to re-edit your question with further details. Thanks.
  • klingone
    klingone over 10 years
    Hi there and thanks for the info. Used the command(s) above but failed to install, saying there is no space left on device. Also software center is damaged and wants to be repaired but is also unable to do that. Apt-get autoclean is not working and it is suggested to use command sudo dpkg --configure -a to solve the problem which leads me back to where I started since there is no more space on the device left.. What else could I try? I'm pretty sure it's the inodes in /usr/src due to almost 300.000 files from former kernels installed...thanks again for help.
  • gov
    gov over 9 years
    100% usage of inodes does not mean the hard-drive is full of files.