Free disk space

Hello.I have 50gb of disk space and 33.67 in use. The 4 websites I have in total are about 7.5gb. How can I see the approximately 26gb that are taking up space, in which folders - files? I don’t think the 26gb is from virtualmin? Can I use a command from ssh?

Webmin version 2.111 Usermin version 2.010
Virtualmin version 7.10.0


disk2

What OS?

Did you use the minimal version of the OS?

It could just be the OS.

The server is running ubuntu 22.04

I’d first check the log files to make sure they are being rotated and deleted properly.

cd /var/log
ls -lSh | less
That will sort them by size.

man du is your friend.

1 Like

Run this command
du -hs * | sort -hr

It lists all sub-directories and their sizes, sorted by size. You will know which of your directories are consuming the most space.

2 Likes

It only shows me these results.

root@cp:~# du -hs * | sort -hr
9.5M csf
2.2M csf.tgz
332K virtualmin-install.log
196K Maildir
20K snap
root@cp:~#

Run it from some other directory

Do the same command but in a different directory all you are getting are results from the roots home directory try doing cd / before you run the du command

1 Like

This command also produces the correct results.
I only have one 4.5gb in the folder home/backups backup file. The remaining gb;

root@cp:~# cd /var/log
root@cp:/var/log# ls -lSh | less
total 112M
-rw-r----- 1 syslog adm 45M Jun 30 00:01 kern.log.1
-rw-r----- 1 syslog adm 22M Jun 30 00:00 syslog.1
-rw-r----- 1 syslog adm 7.8M Jun 9 00:01 kern.log.4.gz
–w----r-- 1 root root 7.6M Jun 9 00:01 syslog.4.gz
-rw-r----- 1 syslog adm 7.6M Jun 30 15:24 syslog
-rw-r----- 1 syslog adm 5.9M Jun 23 00:01 kern.log.2.gz
-rw-r----- 1 syslog adm 5.1M Jun 30 15:24 kern.log
-rw-r----- 1 syslog adm 4.3M Jun 16 00:00 kern.log.3.gz
-rw-r----- 1 syslog adm 1.7M Jun 30 00:00 mail.log.1
-rw-r----- 1 syslog adm 1.1M Jun 23 00:00 mail.log.2.gz
-rw-r----- 1 syslog adm 671K Jun 30 00:01 auth.log.1
-rw-r----- 1 syslog adm 665K Jun 16 00:00 syslog.3.gz
-rw-r–r-- 1 root root 353K May 31 18:59 dpkg.log.1
-rw-r----- 1 syslog adm 291K May 12 18:40 cloud-init.log
-rw-rw---- 1 root utmp 291K May 24 19:40 btmp.1
-rw-rw-r-- 1 root utmp 286K Jun 30 15:21 lastlog
-rw-r–r-- 1 root root 242K Jun 29 06:58 dpkg.log
-rw-r----- 1 syslog adm 233K Jun 9 00:00 mail.log.4.gz
-rw-r----- 1 root adm 223K May 24 14:59 fail2ban.log.1
-rw-r----- 1 syslog adm 196K Jun 16 00:00 mail.log.3.gz
-rw-r----- 1 syslog adm 143K Jun 30 15:24 mail.log
-rw-r–r-- 1 root root 112K May 29 23:30 ubuntu-advantage.log.1
–w----r-- 1 root root 106K May 18 23:56 fail2ban.log.2.gz
-rw-rw-r-- 1 root utmp 99K Jun 30 15:21 wtmp
-rw-r----- 1 syslog adm 58K Jun 30 15:21 auth.log
-rw-r----- 1 syslog adm 53K Jun 16 00:00 auth.log.3.gz
-rw-r----- 1 syslog adm 52K Jun 9 00:01 auth.log.4.gz
-rw-r----- 1 root adm 52K Jun 9 00:21 dmesg.0
-rw-r----- 1 root adm 52K Jun 27 22:25 dmesg
-rw-r----- 1 syslog adm 44K Jun 23 00:01 auth.log.2.gz
-rw-r----- 1 syslog adm 41K Jun 16 09:37 syslog.2.gz
-rw-r–r-- 1 root root 39K May 31 19:11 alternatives.log.1
-rw-r----- 1 root adm 29K May 12 18:40 cloud-init-output.log
-rw-r–r-- 1 root root 28K Jun 30 00:01 alternatives.log
-rw-r----- 1 root adm 16K Jun 6 16:19 dmesg.1.gz
-rw-r----- 1 root adm 16K May 30 10:51 dmesg.3.gz
-rw-r----- 1 root adm 15K May 29 23:38 dmesg.4.gz
-rw-r----- 1 root adm 15K May 30 14:03 dmesg.2.gz
-rw-r–r-- 1 root root 7.0K Jun 30 15:21 procmail.log
-rw------- 1 root root 4.6K Jun 30 00:00 lfd.log.1.gz
drwxr-x— 2 root adm 4.0K Jun 30 00:01 apache2
drwxr-xr-x 2 root root 4.0K Jun 29 06:58 apt
drwxr-xr-x 2 clamav clamav 4.0K Jun 30 00:01 clamav
drwxr-xr-x 2 root root 4.0K Feb 13 15:47 dist-upgrade
drwxr-sr-x+ 3 root systemd-journal 4.0K May 12 18:09 journal
drwxr-xr-x 2 landscape landscape 4.0K May 12 18:14 landscape
drwx------ 2 root root 4.0K Jun 30 00:01 letsencrypt
drwxr-s— 2 mysql adm 4.0K May 12 18:22 mysql
drwx------ 2 root root 4.0K May 12 18:09 private
drwxr-xr-x 2 root root 4.0K Jun 30 00:01 proftpd
drwxr-x— 2 root adm 4.0K Jun 1 00:00 unattended-upgrades
drwx–x–x 2 root root 4.0K Jun 30 00:01 virtualmin
-rw-r–r-- 1 root root 2.8K Jun 23 19:30 fontconfig.log

Depending on the age of your system journal log can grow over time. Below you can use these commands to see how big the log is and prune it a bit if needed.

To view space used by journal
journalctl --disk-usage

Restirct number of log files
sudo journalctl --vacuum-files=5

to remove old logs from journal
sudo journalctl --vacuum-time=7d

Restrict log size - They can get pretty high as up to 12GB
sudo journalctl --vacuum-size=1G

Another culprit can be the number of old kernels left after a new kernel update.
If you run apt-get update you may sometimes see additional lines indicating old kernels not being used by the system and will give you a command to remove them.

Hope this helps a bit

1 Like

I ran all its commands, it deleted about 2.5gb, I have run apt-get update several times. What is the command to remove any old kernels?

Apt autoremove but be carefull read exactly what apt is going to remove, if in doubt don’t do it and post up what apt wants to remove before you do it

I ran the command and from what I understand there is nothing to delete.

root@cp:~# apt autoremove
Reading package lists… Done
Building dependency tree… Done
Reading state information… Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
root@cp:~#

You can just do this:

du -xh --max-depth=1 /

The max-depth parameter says how many levels of directory to traverse (and -x says one-filesystem, so it won’t traverse any other filesystems…so if you have multiple partitions or volumes, you’ll need to do this on all of them, but you don’t want to include virtual filesystems and such). So, just find the biggest directory in / and then do it with a larger depth on that directory. e.g., if you find the biggest directory is /home (pretty common):

du -xh --max-depth=2 /home

Where disk is being used is not a mystery. Use the tools you have to find where usage is happening.

1 Like

What should I do now? How can I see the home folder in detail?

root@cp:~# du -xh --max-depth=1 /
4.5G /usr
257M /boot
16G /home
28M /etc
5.5G /var
16K /lost+found
4.0K /opt
15M /root
4.0K /media
92K /tmp
24K /snap
12K /srv
4.0K /mnt
32G /
root@cp:~#

Maybe just re-read my comment, because I literally already answered that exact question, with an example.

nothing to remove then, so your boot partition will have plenty of space

Virtualmin’s file manager has a superpower which we have all forgotten to mention thus far: select one or more directories in Virtualmin’s File Manager, right click on one of the selected directories and mouse-over on (the edge of) Properties till you see Calculate Size. Hit it to see numbers next to all the selected directories.

It shows the space occupied by the directory and all its files and subdirectories. One could drill down using Virtualmin’s GUI till one finds the directory which is using up the disk space that it should not.

We were harassing poor @dimgr with CLI commands when there was an easy way to do everything that he wanted in Webmin / Virtualmin File Manager.

3 Likes

@calport Very cool suggestion, GUI is always better for us (i.e. me) Windows users.

After look at the file manager settings you can also select stuff and then press the space bar to calculate size but this seems a bit inconsistent, unless I am using it wrong.

image

surly there should be an option (I know there isn’t) for file manager to do that calculation by default, a simple on/off toggle would do, rather than banging the space bar a few times to get the sizes of the directories displayed, mind you this is off topic I may open a new thread