How to free space and clean up your UCS
When using UCS of the course of months or years it can be necessary to free some space from time to time.
This guide will highlight some places and tools that can be used to do that, but please keep in mind:
- Always backup before removing things!
- Think before you delete something that you still might need!
Analysis
UCS environments differ in what is using space depending on installed services/apps, user/group count, usage, …
Therefore you should never blindly copy & paste the following commands without analyzing your server first.
Every UCS will provide you with du
and df
to list used and free space. Another great tool to do this is ncdu
: You can simply install it via univention-install ncdu
and start to analyse with sudo ncdu /
.
A normal installation might look like this:
ncdu 1.13 ~ Use the arrow keys to navigate, press ? for help
--- / -------------------------------------------------------------------------------------
9,6 GiB [##########] /var
8,3 GiB [######## ] /usr
370,5 MiB [ ] /lib
74,7 MiB [ ] /boot
64,1 MiB [ ] /home
46,0 MiB [ ] /opt
38,4 MiB [ ] /root
32,1 MiB [ ] /etc
13,7 MiB [ ] /sbin
11,3 MiB [ ] /bin
1,5 MiB [ ] /run
88,0 KiB [ ] /tmp
16,0 KiB [ ] /dev
e 16,0 KiB [ ] /lost+found
8,0 KiB [ ] /media
4,0 KiB [ ] /lib64
e 4,0 KiB [ ] /srv
e 4,0 KiB [ ] /mnt
. 0,0 B [ ] /proc
0,0 B [ ] /sys
@ 0,0 B [ ] initrd.img
@ 0,0 B [ ] initrd.img.install
@ 0,0 B [ ] vmlinuz
@ 0,0 B [ ] vmlinuz.install
Total disk usage: 18,6 GiB Apparent size: 18,6 GiB Items: 605601
It is possible to navigate directories via the arrow keys so that you can look further into your disk usage.
Guides
There are several guides for clean up and freeing space available here:
Standard UCS
In bigger environments the MDB maxsize can be reached sooner or later for the LDAP, Listener cache or Translog as space is not freed after deletion of objects.
To do so the following guides have useful information - It is necessary to execute the optional steps too (e.g. creating new database files via mdb_copy
). A comparison of both the old and the new MDB file should report the size difference after this “defragmentation”.
- Problem: Prune transaction log
- How-to: clean up the translog from a certain point in time
- How-to: Cleanup LDAP mdb and free used space
UCS@school
Useful commands
Last but not least there are several other things that might pollute your UCS but can be cleaned easily:
Clean unused packages and apt cache
apt autoremove
apt-get clean
univention-prune-kernels
Clean up the group membership cache
/usr/share/univention-group-membership-cache/univention-ldap-cache cleanup
Delete old systemd logs
sudo journalctl --vacuum-time=2d
Remove unused docker resources
docker system prune
UCS internals
UCS keeps several logs in rotation. If some services emitted many logging state, for example after importing many users, the log is kept for some time, so it is advisable to check /var/log/univention
for some bigger gzipped logs.
UCS keeps daily backups of LDAP and UCR: 3.3. LDAP directory — Univention Corporate Server - Manual for users and administrators
These can be moved away to free space too.