with lsof) and force them to close this files (e.g by stopping the application or by killing the processes). You can try to find out the relevant processes (e.g. But for the filesystem their blocks are still in use until the proceses close the files. Therefore this files were removed from the directory and du can't see them. Some processes are using a file that was already deleted. There can be different reasons for his phenomena. If the du output is much smaller, then som files are not shown in any directory tha du inspects. If the du output is larger then you have missed a subdirectory where another filesystem is mounted. If you still haven't enough space than you can repeat step 4 in the larges subdirectories which are displayed at the bottom of the list.īut what happened if the du output is not approximately the available space displayed by df? It won't solve your problem if you delete them. Don't bother about the small directories on the top of the output. If you have found a large file/directory that you don't need anymore you can remove it in an appropriate way. The largest files/subdirectories will be shown at the bottom of the output. The -k option forces du to output the sie in kilobyte without any unit. To find the largest subdirectories of a directory /./dir use du -sk /./dir/*|sort -n If so, you can start to find the large files/directories of the /myfilesystem filesystem to clean up. Now check if the du of the visible files is approximately the size of the used space displayed by df. Then you have to use some workarounds to find the du of your filesystem. Solaris) do not know the -x option for du. The -x option may be used to guarantee that only the files that are member of this filesystems are taken into account. If so, the following speps must be adapted to this situation.įind out how much space is used by the files of this filesystem du -sh /myfilesystem check the df output if there are filesystems mounted on subdirs of /myfilesystems. Assume that the full filesystem is /myfilesystem. You only waste time if you investigate filesystems that have enough space. Will list all filesystem, their size and their free space. I don't know Ubuntu and can't check my answer but post here my answer based on my experience as unix admin long time ago.įind out which filesystem runs out of space df -h Just append this to the end of the command: | sort -h You can sort the output of the du command so that the highest value is at the bottom. Skip directories on different file systems Man page description of that flag: -x, -one-file-system If you know which drive is the issue and it has other mounted drives on top of it that you don't want to waste time including in your search, you could add the -x flag to your du command. If you absolutely don't want any of the K valued directories showing up you'd want to up your regex game to be more creative and complex. The grep I provided could result in the occasional "K" value being returned if the name of the directory or file has a capital G or M.While the above command will certainly do the trick, I had some constructive criticism in the comments below that pointed out some things you could also include. That should lead you to the problem children! So for example, if /var was the biggest you could do it like this next: du -cha -max-depth=1 /var | grep -E "M|G" After you find the biggest ones you can then run the command inside of that directory in order to narrow your way down the culprit. However, it should still provide valid output for the rest of the directories in root. You may get some errors on /proc, /sys, and/or /dev since they are not real files on disk. If your disks are big enough, you could add |T as well to include Terabyte amounts. The grep is to limit the returning lines to those which return with values in the Megabyte or Gigabyte range. I start by running this as root or with sudo: du -cha -max-depth=1 / | grep -E "M|G" However, if you need to do it from CLI, this is my preferred method: As always in Linux, there's more than one way to get the job done.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |