Skip to content

Instantly share code, notes, and snippets.

@xnoder
Created December 19, 2016 07:40
Show Gist options
  • Save xnoder/14af58a8f9461cd835195b190437c014 to your computer and use it in GitHub Desktop.
Save xnoder/14af58a8f9461cd835195b190437c014 to your computer and use it in GitHub Desktop.
Zap a deleted file handle holding into disk space
# These commands will help you find and truncate a deleted file handle that is holding onto disk space. Why do my servers
# always fuck with me during the holidays?
# Run this to find files that have one link, which should equal a (deleted) file
$ lsof -nP +L1
# Now, search through /proc to find these deleted files
$ find /proc/*/fd -ls | grep '(deleted)'
/proc/5225/fd/3 -> /var/log/ceph/ceph-mon.st1.log.1\ (deleted)
# Truncate the file. Win free disk space. Woohoo!
$ : > "/proc/$pid/fd/$fd"
$ df -h
# go get a warm beverage you linux wrangling superstar.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment