I’ve had an Ubuntu 22.04 setup going for around a year, and over that year I’ve had to increase the size of the partition holding my /var folder multiple times. I’m now up to 20GB and again running into problems, mainly installing new apps, because that partition is again nearly full. I’ve used commands sudo apt clean and sudo journalctl --vacuum-size=500 to temporarily clear up some space, but it doesn’t take long to fill back up, and gets less effective with time, til I have no choice but to expand the partition again.

Am I doing something wrong? Is it normal to need 20GB+ for var? Is there a way to safely reclaim space I don’t know about?

  • Justin@apollo.town
    link
    fedilink
    English
    arrow-up
    1
    ·
    11 months ago

    Install ncdu, then sudo ncdu -x /var it’ll tell you what is taking up space, then if you tell us, we can help you identify how to minimize it and keep it low.

  • pnutzh4x0r@lemmy.ndlug.org
    link
    fedilink
    English
    arrow-up
    1
    ·
    edit-2
    11 months ago

    If you suspect that the issue is journald, you can use the following command to check how much space it is using:

    journalctl --disk-usage
    

    Rather than periodically running journalctl --vacuum-size=500 to free up space, you can just limit the journal by adding the following to a new file such as /etc/systemd/journald.conf.d/size.conf:

    [Journal]
    SystemMaxUse=512M
    

    This will limit the journal from using more than 512MB. That said, if journald is filling up fast, then something is spamming your logs and you could run journalctl -a -f to get a sense of what is being written to your logs.

  • tychosmoose@lemm.ee
    link
    fedilink
    arrow-up
    1
    ·
    11 months ago

    See what’s using the space. This will list any dirs using >100MiB:

    sudo du -h -d 5 -t 100M /var

  • The Doctor@beehaw.org
    link
    fedilink
    English
    arrow-up
    1
    ·
    11 months ago

    There’s a way to figure out what is responsible for using up all of that space. A couple of ways, really. Here’s the one I use, though: du -s -h -x /path/to/ | sort -h -r | head -n 10*

    • du
      • -s - display only a total for each argument
      • -h - human readable values
      • -x - do not cross file systems (in case you have another directory tree mounted under /var, which’ll complicate figuring out what’s in there for this purpose)
    • sort
      • -h - compare human readable numbers (e.g., 1G, 2T)
      • -r - reverse sort (biggest first)
    • head
      • -n 10 (first ten lines or less)
  • Jérôme Flesch@lemmy.kwain.net
    link
    fedilink
    arrow-up
    1
    arrow-down
    1
    ·
    edit-2
    11 months ago

    You can use du -sh to figure out what’s using most of the space. Something along the line of:

    sudo -i
    du -sh /home /usr /var
    du -sh /var/*
    du -sh /var/log/*
    # etc
    

    If it’s one of your log files (likely), you can run something like tail -n 100 /var/log/[culprit] or tail -F /var/log/[culprit] to see what is being flooded in this log file exactly. Then you can try to fix it.