0

I was running a bash script which created a 14G file in the tmp directory , I deleted it still I cant find the directory or file which is large.

My output for df -h


Filesystem      Size  Used Avail Use% Mounted on
udev            474M     0  474M   0% /dev
tmpfs            99M   11M   88M  11% /run
/dev/vda1        25G   25G     0 100% /
tmpfs           491M     0  491M   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           491M     0  491M   0% /sys/fs/cgroup
/dev/vda15      105M  3.9M  101M   4% /boot/efi
/dev/loop0       90M   90M     0 100% /snap/core/7917
/dev/loop1       55M   55M     0 100% /snap/lxd/12211
/dev/loop2       94M   94M     0 100% /snap/core/8935
/dev/loop3       68M   68M     0 100% /snap/lxd/14194
tmpfs            99M     0   99M   0% /run/user/0
/dev/loop4       55M   55M     0 100% /snap/core18/1705
/dev/loop5       49M   49M     0 100% /snap/gtk-common-themes/1474
/dev/loop6      153M  153M     0 100% /snap/chromium/1071
tmpfs            99M     0   99M   0% /run/user/1000

My output for du -sh in / directory

du: cannot access './proc/19935/task/19935/fd/4': No such file or directory
du: cannot access './proc/19935/task/19935/fdinfo/4': No such file or directory
du: cannot access './proc/19935/fd/3': No such file or directory
du: cannot access './proc/19935/fdinfo/3': No such file or directory
4.7G    .

I cant install ncdu or any other tools since the disk is full , considering the summarized size after du -sh where is the rest of the space out of 25GB

My lsb-release

DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=19.10
DISTRIB_CODENAME=eoan
DISTRIB_DESCRIPTION="Ubuntu 19.10"

Output for du -sh /*/

119M    /bin/
97M /boot/
0   /dev/
5.9M    /etc/
212M    /home/
682M    /lib/
4.0K    /lib32/
4.0K    /lib64/
4.0K    /libx32/
16K /lost+found/
4.0K    /media/
4.0K    /mnt/
4.0K    /opt/
du: cannot access '/proc/20791/task/20791/fd/4': No such file or directory
du: cannot access '/proc/20791/task/20791/fdinfo/4': No such file or directory
du: cannot access '/proc/20791/fd/3': No such file or directory
du: cannot access '/proc/20791/fdinfo/3': No such file or directory
0   /proc/
72K /root/
11M /run/
30M /sbin/
1.9G    /snap/
4.0K    /srv/
0   /sys/
17M /tmp/
845M    /usr/
768M    /var/
  • Ubuntu 19.04 is EOL or end-of-life (http://fridge.ubuntu.com/2020/01/23/ubuntu-19-04-disco-dingo-end-of-life-reached-on-january-23-2020/) thus off-topic on this site (https://askubuntu.com/help/on-topic) unless your question is specific to help moving to a supported release of Ubuntu. Use a LTS or long-term-support release if you don't like release-upgrading every 6-9 months. https://help.ubuntu.com/community/EOLUpgrades (You tagged an EOL release; you'll need to re-install if you don't fix your space issue first, but you can re-install using 'something-else' & no format, it's fast) – guiverc Apr 05 '20 at 09:53
  • it was my mistake , its running 19.10 – Joel Deleep Apr 05 '20 at 09:59
  • did you run du -sh with root permission? – phuclv Apr 05 '20 at 10:04
  • @phuclv yes , i was root while executing the command. I cant find the reason for the difference in du -sh in the / directory and df -h eating all the space – Joel Deleep Apr 05 '20 at 10:05
  • 1
  • @N0rbert, no I can't install any tools right now since the disk is full, I need to know why the results seem different, basically, it should be same when checked under the / directory – Joel Deleep Apr 05 '20 at 10:45
  • @GabrialJohnas you need to run du -sh /*/ to get the size of each sub folder. And try to clean old kernels and /tmp first. No more disk space: How can I find what is taking up the space? – phuclv Apr 05 '20 at 10:49
  • @phuclv I have updated the question with the respective output, there is no old kernel, it was installed today. – Joel Deleep Apr 05 '20 at 10:59
  • did the creating script stop? because if the handle is still opened then file will still exists even if you unlink it – phuclv Apr 05 '20 at 11:48
  • du -sh /*/ will list only directories but not files due to the trailing slash at the end of the command. Some space might be occupied by swapfile. Please check with du -sh /* again, this will also list files which may exist in the /-directory. – mook765 Apr 05 '20 at 13:16
  • @mook765 nothing different as phuclv the file still exists, but unable to find it – Joel Deleep Apr 05 '20 at 13:27
  • Do you use a swap-file or a swap partition? You can check with swapon -s. Did you ever reboot since you deleted that file in the /tmp-directory? – mook765 Apr 05 '20 at 13:30
  • no swap-file, i think the script is still creating tmp file , I can see a file with increasing size, I can only reboot after the script completes successfully or fails . I think a reboot might fix , not sure, will check and update – Joel Deleep Apr 05 '20 at 13:40
  • @phuclv - The disk is back after the script is completed – Joel Deleep Apr 06 '20 at 00:57
  • @GabrialJohnas so that's exactly what I thought – phuclv Apr 06 '20 at 01:26

2 Answers2

2

The POSIX standard allows you to remove a file while it's still being opened. Only when all processes opening the file has closed then the file is actually deleted

The unlink() function shall remove a link to a file. If path names a symbolic link, unlink() shall remove the symbolic link named by path and shall not affect any file or directory named by the contents of the symbolic link. Otherwise, unlink() shall remove the link named by the pathname pointed to by path and shall decrement the link count of the file referenced by the link.

When the file's link count becomes 0 and no process has the file open, the space occupied by the file shall be freed and the file shall no longer be accessible. If one or more processes have the file open when the last link is removed, the link shall be removed before unlink() returns, but the removal of the file contents shall be postponed until all references to the file are closed.

https://pubs.opengroup.org/onlinepubs/009695399/functions/unlink.html

So if the running process in the script is still opening the file the space is still consumed and you can't observe it until the process closes the file or is killed

phuclv
  • 628
  • 1
  • 8
  • 38
  • no issues now, i was wondering why this is eating up space even though its not showing in the du summary. After the process was complete everything was back to normal. – Joel Deleep Apr 06 '20 at 02:55
0

How about something like:

du -h -t 500M -a /

Usage:

-h, --human-readable
              print sizes in human readable format (e.g., 1K 234M 2G)

-t, --threshold=SIZE exclude entries smaller than SIZE if positive, or entries greater than SIZE if negative

-a, --all write counts for all files, not just directories

phuclv
  • 628
  • 1
  • 8
  • 38
CentaurusA
  • 2,672