16.04 Disk Usage – Fix ULG Files Taking 25 GB Disk Space

16.04disk-usage

I would like to know what ULG files are on Ubuntu. After trying to find what was using the disk space, I found a directory using 25 GB of 28 GB total, and this directory had 785 ULG files.

Note that I'm working on an Intel Aero RTF, using Ubuntu 16.04, and it can store 28 GB.

Output of du command (the essential part):

root@intel-aero:/var/lib/mavlink-router# du -h /var/lib/mavlink-router/
25G /var/lib/mavlink-router/

Number of files:

root@intel-aero:/var/lib/mavlink-router# find /var/lib/mavlink-router/ -type f | wc -l
785

Partial results of ls:

root@intel-aero:/var/lib/mavlink-router# ls -lh
total 25G
-rw-r--r-- 1 root root   73M May 22 05:45 00000-2018-05-22_05-14-52.ulg
-rw-r--r-- 1 root root   36M May 22 06:00 00001-2018-05-22_05-45-23.ulg
-rw-r--r-- 1 root root  9.0M May 22 05:00 00002-2018-05-22_04-57-05.ulg
-rw-r--r-- 1 root root   11M May 22 05:01 00003-2018-05-22_04-57-05.ulg
-rw-r--r-- 1 root root  117M May 22 05:46 00004-2018-05-22_04-57-05.ulg
-rw-r--r-- 1 root root  220M May 22  2018 00005-2018-05-22_04-57-05.ulg
-rw-r--r-- 1 root root     0 May 22  2018 00006-2018-05-22_06-31-13.ulg
-rw-r--r-- 1 root root     0 May 22  2018 00007-2018-05-22_06-31-14.ulg

df result:

root@intel-aero:/var/lib/mavlink-router# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/root        28G   28G     0 100% /
devtmpfs        1.9G     0  1.9G   0% /dev
tmpfs           1.9G     0  1.9G   0% /dev/shm
tmpfs           1.9G   76M  1.8G   4% /run
tmpfs           1.9G     0  1.9G   0% /sys/fs/cgroup
tmpfs           1.9G   48K  1.9G   1% /var/volatile
tmpfs           1.9G  4.0K  1.9G   1% /tmp
/dev/mmcblk0p1   28M  7.7M   21M  28% /boot
tmpfs           382M     0  382M   0% /run/user/0

So questions are:

  • What type of file is a ULG file? Is it a save, config, … ?
  • Can I remove some of them (or all of them) without any issue later?

Best Answer

According to a similar question in an Intel forum, Disk fills up, large ULG files in /var/lib/mavlink-router, these ULG files are logfiles of the mavlink-router.

There are only two workarounds:

  • Either disable logging:

    Modify /etc/mavlink-router/main.conf and comment out the line below:

    [General]
    #Log=/var/log/mavlink-router
    
  • Or setup a cronjob to delete them regularly once a day:

    0 2 * * * rm /var/lib/mavlink-router/*.ulg && systemctl restart mavlink-router.service
    

At first, I thought logrotate with the following snippet could be of help:

/var/lib/mavlink-router/*.ulg {
    rotate 2
    daily
    missingok
    notifempty
    compress
    sharedscripts
    postrotate
        systemctl restart mavlink-router.service
    endscript
}

But this won't work as intended because the filenames already have a timestamp and number in them, so each file has a different name and logrotate would simply compress them but never delete them. E.g. 00000-2018-05-22_05-14-52.ulg would become 00000-2018-05-22_05-14-52.ulg.1.gz but never get deleted because there won't be another file with that name that claims its place.

See this post for a possible solution with logrotate for files with timestamps in their name.

Related Question