Skip to content

Instantly share code, notes, and snippets.

@AdamWhittingham
Created December 17, 2015 17:38
Show Gist options
  • Save AdamWhittingham/ebe7de6981685ae1d3bb to your computer and use it in GitHub Desktop.
Save AdamWhittingham/ebe7de6981685ae1d3bb to your computer and use it in GitHub Desktop.
Recover Ubuntu inode exhaustion when apt-get broken
When inodes run out, Ubuntu can fail to install the latest kernel but can still have a dependency on it (via a pacakage like `kernel-generic`)
This leads to an error message when trying to run any `apt-get` commands about a missing dependency requiring you to run `apt-get -f install` with no args to grab the missing dep.
Doing this will fail though, as there are no inodes left...
To resolve this, you can artificially drop the number of inodes by zipping up files.
A great candidate for this is the old kernals in `/usr/src`.
1. Check the current running kernal version with `uname -r`
2. Select a couple of kernal versions in `/usr/src` which do *NOT* have the same version number as the running one, nor are the most recent.
3. Compress these kernal directories with `tar -zcf /var/tmp/<kernel-version>.tar.gz` and `tar -zcf /var/tmp/<kernel-version>-generic.tar.gz`
4. Remove the kernel folders we just backed up to free up some inodes (`rm -r <kernel-version>`)
5. Run `apt-get -f install` to fix the missing dep.
6. Run `apt-get autoremove` to now strip out more of the old kernels and resolve the issue!
If you run into problems with the `autoremove` of the backed up kernel, you can untar (`tar xf <kernel-version>.tar.gz`) and restore the files and re-run the apt command.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment