-1

I have a server with Ubuntu 20.04 the problem is that disk/dev/vda1 partitiom is full. However, I have almost nothing to install.

How do you know which file or directory is consuming all the space ?

ubuntu@pv-hdh87 ~ $ df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            2.9G     0  2.9G   0% /dev
tmpfs           595M  1.1M  594M   1% /run
/dev/vda1        20G   18G  1.3G  94% /
tmpfs           3.0G     0  3.0G   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           3.0G     0  3.0G   0% /sys/fs/cgroup
/dev/vda15      105M  9.1M   96M   9% /boot/efi
/dev/loop0       72M   72M     0 100% /snap/lxd/16099
/dev/loop1       55M   55M     0 100% /snap/core18/1880
/dev/vdb         98G  4.7G   89G   6% /home
tmpfs           595M     0  595M   0% /run/user/1000
tmpfs           595M     0  595M   0% /run/user/114
/dev/loop3       30M   30M     0 100% /snap/snapd/8790
/dev/loop4       56M   56M     0 100% /snap/core18/1885
/dev/loop5       71M   71M     0 100% /snap/lxd/16922
/dev/loop6       31M   31M     0 100% /snap/snapd/9279
Wasif
  • 281
  • 2
  • 8
20f2c98f50
  • 39
  • 2
  • 10

2 Answers2

1

I think you can try this to get 10 biggest files:

find / -type f | xargs ls -la | awk '{print $5,$9}' | sort -rn | head -n 10
Gerald Schneider
  • 19,757
  • 8
  • 52
  • 79
  • While useful there is also the scenario of a directory containing many files that individually aren’t that large but that collectively can take up a lot of space ... – Bob Sep 22 '20 at 06:48
  • @HermanB : you are right; in that case; i think chage the type of ```find``` command from ```f``` to ```d``` will do the trick – Nguyễn Quang Trung Sep 22 '20 at 07:02
1

du command from the coreutils can be used for that. It can be used like this:

du -h -d 1 /
12G /usr
16K /lost+found
964K    /run
324G    /home
0   /dev
77M /boot
348K    /tmp
326M    /root
0   /sys
2.5G    /opt
16G /var
12K /srv
20K /media
4.0K    /mnt
0   /proc
9.8M    /etc
354G    /

where -h returns human readable output and -d 1 defines the level to summarize.

Depending on the size of a disk the command can take some time to complete. It might make sense to start with checking potential large directories like /var before checking the complete disk like:

du -h -d 1 /var

Henrik Pingel
  • 8,676
  • 2
  • 24
  • 38
  • And if you’re willing to install something not completely standard, the `ncdu` will allow you to graphically drill down to find the largest directories and filed – Bob Sep 22 '20 at 06:50
  • @Henrik Pingel Thank you, here is the file which is full `15G /var/lib` how can I know the size of the subfolders – 20f2c98f50 Sep 22 '20 at 09:55
  • Use a higher value for the d parameter or skip it and run du for the var directory only – Henrik Pingel Sep 22 '20 at 09:57
  • @Henrik Pingel Ok i found out, why is mysql consuming so much space? My site went from 6gb to 14gb in a week. It is not possible. https://pastebin.com/bzHzeiKy – 20f2c98f50 Sep 22 '20 at 10:03