# Problem: clearing up disk space



## vaskark (Apr 17, 2021)

I recently upgraded to the 13.0-RELEASE and everything went fine. But now when I check my disk space (`df`):



> Filesystem     Size    Used   Avail Capacity  Mounted on
> /dev/ada0p2     16G    9.2G    5.1G    64%    /
> devfs          1.0k    1.0k      0B   100%    /dev
> procfs         4.1k    4.1k      0B   100%    /proc



I only have 2 window managers installed and not that many packages (498). I do have ports installed but have only built one package from it (one of the formentioned wm's). Using `du` is not helping very much. I've already cleared /var/crash/ and have used `pkg autoremove` and `pkg clean`.

Can someone point me in the right direction? It doesn't seem normal that I'm sitting at 9.2 GB of used disk space.
Thanks.


----------



## tux2bsd (Apr 17, 2021)

For a quick comparison, I have an upgraded 12.2->13.0 install with a similar installation profile sitting at 5.4G.


----------



## tux2bsd (Apr 17, 2021)

`du -xh -d 0 /* | sort -h`

(updated after ct85711 comment)

(updated again after realising the 0 was right)


----------



## ct85711 (Apr 17, 2021)

A suggestion on when using du, you can set the depth (totaling everything up to that level) that it reports.

So doing `du -h -d 1` does a depth of one, so it totals subdirectories to your current level. (the -h is to display in human readable like Megs, Gigs, etc...)


----------



## tux2bsd (Apr 17, 2021)

p.s.     -x      File system mount points are not traversed.

The -d switch is good to know about.  Ah, -s is different bsd vs not-bsd


----------



## Phishfry (Apr 18, 2021)

`freebsd-update` stores a roll-back that can be cleaned. Usually around 2 gigs and lots of small files.
/var/db/freebsd-update/files

Also you mentioned a WM port that you compiled. Have you cleaned that build?
`make clean` and then delete the ports /work directory.


----------



## tux2bsd (Apr 18, 2021)

Phishfry said:


> /var/db/freebsd-update/files (can be cleaned)


Thanks.

I realised my use of du was still not the bsd way, was still doing it the '-s' way from not-bsd.  the -d needed 0, not 1.


```
root@eeepc:~ # df -h
Filesystem            Size    Used   Avail Capacity  Mounted on
zroot/ROOT/default     98G    3.2G     95G     3%    /
root@eeepc:~ # du -h -x -d 0 /* | sort -h | tail -5
7.6M    /rescue
8.1M    /lib
162M    /boot
1.3G    /var
1.7G    /usr
```


----------



## vaskark (Apr 22, 2021)

Sorry for the late reply. Email notifications weren't working.

I cleaned /var/db/freebsd-update/files and went from 8.5 GB to 7.5 GB. So that's great. Still seems high, though.

The port of the wm I installed had been cleaned already, but it was a trifle. Wasn't causing any space problems.

Results of du:


```
du -xh -d 0 /* | sort -h
  0B    /home
  0B    /proc
  0B    /sys
3.5K    /dev
4.0K    /entropy
4.0K    /mnt
4.0K    /net
8.0K    /COPYRIGHT
8.0K    /media
 32K    /tmp
264K    /libexec
288K    /root
1.3M    /bin
3.1M    /etc
6.6M    /sbin
 13M    /rescue
 15M    /lib
295M    /boot
309M    /var
6.4G    /usr
```


----------



## Brian546 (Apr 22, 2021)

du -h -d1 /usr/lib

You may have the debug files installed (which takes up a ridiculous amount of space).


----------



## drhowarddrfine (Apr 22, 2021)

Do `pkg clean -ay`
Also delete everything in `/usr/ports/distfiles/`


----------



## vaskark (Apr 22, 2021)

Brian546 said:


> du -h -d1 /usr/lib
> 
> You may have the debug files installed (which takes up a ridiculous amount of space).



Here's what I found:


```
$ du -h -d 1 /usr/lib

4.0K    /usr/lib/compat
232K    /usr/lib/i18n
 93M    /usr/lib/clang
 24K    /usr/lib/engines
 24K    /usr/lib/libxo
148K    /usr/lib/dtrace
443M    /usr/lib/debug
 16K    /usr/lib/flua
960M    /usr/lib
```

Not as big a contributor as I was hoping. Is it safe to just delete these manually?


----------



## vaskark (Apr 22, 2021)

drhowarddrfine said:


> Do `pkg clean -ay`
> Also delete everything in `/usr/ports/distfiles/`



I already used `pkg clean` and I don't have a distfiles directory.


----------



## jb_fvwm2 (Apr 22, 2021)

Brian546 said:


> du -h -d1 /usr/lib
> 
> You may have the debug files installed (which takes up a ridiculous amount of space).


This thread enabled me to save some space: `find . -type f -name  " *.debug" -exec /bin/rm -v {} \;` and the system still works good.  I don't recall from which directory it was run though.


----------



## Phishfry (Apr 22, 2021)

`find / -name '*.core' -exec /bin/rm -v {} \;`
Delete all core dumps


----------



## vaskark (Apr 23, 2021)

Phishfry said:


> `find / -name '*.core' -exec /bin/rm -v {} \;`
> Delete all core dumps



Didn't find anything


----------



## Deleted member 67440 (Apr 23, 2021)

zpaqfranz dir / /s /os


----------



## T-Daemon (Apr 24, 2021)

vaskark said:


> I only have 2 window managers installed and not that many packages (498).





vaskark said:


> `6.4G /usr`


Not the number of packages are decisive but how big are they. Running `pkg info -sa | sort -hk2` will show the total size of files installed by each package, sorted after size ascending. pkg-info(8). To display the disk space occupied of all installed packages: pkg-stats(8).

Besides du(1) sysutils/ncdu is an excellent tool to inspect the disk usage of a file system. It has functions to view and manipulate the found results. To name a few features: The results can be sorted after different properties, files and directories deleted, a shell spawned. For more options see ncdu(1).


----------



## vaskark (Apr 24, 2021)

Phishfry said:


> T-Daemon said:
> 
> 
> > Not the number of packages are decisive but how big are they. Running `pkg info -sa | sort -hk2` will show the total size of files installed by each package, sorted after size ascending. pkg-info(8). To display the disk space occupied of all installed packages: pkg-stats(8).
> ...



Thanks for the advice. I'll see if I can lose some of this stuff.


----------



## Jose (Apr 24, 2021)

Has anyone tried sysutils/agedu? I stumbled upon it looking for sysutils/jdiskreport.


----------



## T-Daemon (Apr 24, 2021)

vaskark said:


> I'll see if I can lose some of this stuff.



If you want to lose some packages, with pkg-query(8) you can list all packages with no reverse dependencies (packages which are not required by other packages). The following command is a modified example from pkg-query(8) including the flat size of the packages and sorted ascending:

`pkg query -e '%#r = 0' '%o %sh' | sort -hk2`

After deleting packages from the list run pkg-autoremove(8) afterwards.


----------

