0

I created a fresh VM, however I started facing space issues as soon as it got created. From the du and lsblk command I see /dev/mapper/centos-root is occupying a lot of space. I tried running tree command on root to filter all files occupying large space. But the command takes forever.

How do I figure out what exactly is occupying space and delete them from system.

Here is the output of command.

[root@hpmaincs mapper]# lsblk --output NAME,KNAME,TYPE,SIZE,MOUNTPOINT
NAME            KNAME TYPE  SIZE MOUNTPOINT
fd0             fd0   disk    4K
sda             sda   disk  100G
├─sda1          sda1  part    1G /boot
└─sda2          sda2  part   99G
  ├─centos-root dm-0  lvm    50G /
  ├─centos-swap dm-1  lvm   7.9G [SWAP]
  └─centos-home dm-2  lvm  41.1G /home
sdb             sdb   disk  100G
sr0             sr0   rom  1024M
[root@hpmaincs mapper]# df -H
Filesystem                                     Size  Used Avail Use% Mounted on
/dev/mapper/centos-root                         54G   54G   21k 100% /
devtmpfs                                       8.4G     0  8.4G   0% /dev
tmpfs                                          8.4G     0  8.4G   0% /dev/shm
tmpfs                                          8.4G  801M  7.6G  10% /run
tmpfs                                          8.4G     0  8.4G   0% /sys/fs/cgroup
/dev/sda1                                      1.1G  228M  836M  22% /boot
/dev/mapper/centos-home                         45G   38M   45G   1% /home
ytr.itm.com:/Media                             34T   26T  8.0T  77% /root/cvmedia
tmpfs                                          1.7G     0  1.7G   0% /run/user/0
0

1 Answer 1

1

Use a proper disk space analyzer. The most barebones one, du, is probably installed by default. You could use it like this:

$ sudo du --one-file-system --human-readable --max-depth=1 /
4.5G    /usr
38M     /etc
46G     /var
8.5K    /backup
188K    /mnt
118M    /opt
50G     /

In my example we see /var is big, so let’s go there (with short options this time):

$ sudo du -xhd1 /var
1.7G    /var/lib
22K     /var/net-snmp
8.5K    /var/local
236M    /var/log
8.5K    /var/empty
31K     /var/db
75K     /var/syslog
8.5K    /var/games
6.6M    /var/state
44G     /var/cache
313K    /var/smbversion
212K    /var/tmp
332K    /var/spool
22K     /var/named
8.5K    /var/opt
46G     /var

Lots of cached stuff!

A more user-friendly solution is ncdu, an interactive version of du:

$ ncdu -x /
ncdu 2.3 ~ Use the arrow keys to navigate, press ? for help
--- / --------------------------------------------------------------------------
   45.1 GiB [###########] /var
    4.5 GiB [#          ] /usr
  117.1 MiB [           ] /opt
   37.9 MiB [           ] /etc
  187.5 KiB [           ] /mnt
e   8.5 KiB [           ] /backup
    4.5 KiB [           ]  dead.letter
@ 512.0   B [           ]  sbin
@ 512.0   B [           ]  lib64
@ 512.0   B [           ]  lib
@ 512.0   B [           ]  bin
>   0.0   B [           ] /tmp
>   0.0   B [           ] /tank
>   0.0   B [           ] /sys
>   0.0   B [           ] /srv
>   0.0   B [           ] /run
>   0.0   B [           ] /root
>   0.0   B [           ] /proc
>   0.0   B [           ] /keys
>   0.0   B [           ] /home
>   0.0   B [           ] /hd2
*Total disk usage:  49.7 GiB   Apparent size:  53.2 GiB   Items: 344,334

You can interactively drill down, and you get a relative size indicator (although boring in my example).

ncdu is available in most distributions’ package feeds, but seeing how your partition is full, you wouldn’t be able to install it.

Using -x/--one-file-system is important on both, because you are concerned with a specific filesystem and nothing else. If you don’t use it, it will start scanning the multi-terabyte network resource mounted at /root/cvmedia!

2
  • just like in windows I can merge the partitions, how can I merge root, swap and home partitions here? Commented Dec 14, 2023 at 10:47
  • It’s actually more like “Just like in Windows, you cannot merge partitions”. You can get rid of /home as a separate partition and because of LVM you can even use that space for /. You’ll have to do it manually though. There is no merging. Swap is something else altogether. // But maybe attempt to clean up instead, 50 GiB is a tremendous amount of data.
    – Daniel B
    Commented Dec 14, 2023 at 13:27

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .