4

Disk Capacity 256.1 GB

Ubuntu 22.04.1 LTS OS Type 64-bit GNOME Version 42.4 Windows System Wayland

I am running out of disk space. My computer keeps telling me so.

Can I delete usr or var? there folders are 6 and 11 GB, respectively. That's a lot of disk space.

Here are the results of sudo du -hxd1 /var

108K    /var/tmp
4.0K    /var/local
4.8G    /var/lib
4.0K    /var/crash
132K    /var/spool
4.0K    /var/mail
4.0K    /var/metrics
1.6G    /var/log
4.0K    /var/opt
16K /var/ipp-usb
11M /var/snap
5.6M    /var/backups
58M /var/cache
6.4G    /var

Here are the results of df -h

Filesystem      Size  Used Avail Use% Mounted on
tmpfs           771M  2.7M  768M   1% /run
/dev/nvme0n1p3   19G   19G     0 100% /
tmpfs           3.8G     0  3.8G   0% /dev/shm
tmpfs           5.0M  4.0K  5.0M   1% /run/lock
/dev/nvme0n1p5  203G   67G  126G  35% /home
/dev/nvme0n1p1  483M   32M  451M   7% /boot/efi
tmpfs           771M  2.4M  769M   1% /run/user/1001
/dev/nvme0n1p2  4.4G  3.1G  1.4G  69% /media/michael/PQSERVICE

Here are the results of journalctl --disk-usage

Archived and active journals take up 1.5G in the file system.
12
  • 3
    Deleting /usr is pretty much equivalent to deleting the OS. /var, might depend. If you have huge log files in /var/log, you can try compressing, moving or deleting them, though you should probably check what the logs are for them to get so large. Add the output of sudo du -hxd1 /var, please.
    – muru
    Oct 6 at 2:06
  • 1
    Without knowing details of your OS, we'd only be guessing. We don't know what product (Ubuntu Core?, Ubuntu Desktop?, Ubuntu Server? a Desktop flavor? etc), nor what release. We don't even know if you allocated above/at/above the minimum disk (25GB for Ubuntu Desktop for example) thus may suggest increasing disk size etc... If you aren't going to reboot your machine, update or change any running program, deleting /usr/ & /var/ may be fine, but depending on your usage of the system & expected life the consequences maybe be severe! We cannot know, knowing nothing about your OS/system/use
    – guiverc
    Oct 6 at 2:10
  • How much disk space did you allocate, the recommended minimum for Ubuntu 22.04 LTS Desktop was 25GB, so did you allocate that minimum or something larger? The more apps you add to your system, let alone some usage, more disk space maybe your answer. You've not provided full details, but I'd explore how much you allocated to your / first. Did you allocate all 256GB to / if so why is 17GB a concern?
    – guiverc
    Oct 6 at 2:55
  • Add the output of df -h as well, please.
    – muru
    Oct 6 at 3:00
  • 2
    You allocated 19GB, where the minimum was 25GB for Ubuntu Desktop (help.ubuntu.com/community/Installation/SystemRequirements) so I assume you didn't plan on adding any applications to your system, and I suggest your usage is the problem, not allocating the recommended minimum for an installed system that is used into the future & updates are expected. I suggest you should instead be asking to increase disk partition size; though do note - many desktop users can exist on 19GB you use (I just cannot; it'll depend how you use your system, what you add etc)
    – guiverc
    Oct 6 at 3:11

2 Answers 2

12

Definitely no. Deleting /usr or /var will break your system!

The best choice (if possible) is to install Ubuntu on a larger disk partition. I don't know how to clean up /usr, but /var usually filled up with journal log, Flatpak & Snap apps.

Open terminal (Ctrl+Alt+T) and run this command to check journalctl log size (usually 4GB in my case):

journalctl --disk-usage

Then you may clean up and set a lower log size via: sudo journalctl --rotate && sudo journalctl --vacuum-size=100M.

List all install flatpak packages via flatpak list --app and remove unused via flatpak uninstall --delete-data app-id. List all snap apps via snap list and remove unused via snap remove packagename.

You may also search for and open Disk Usage Analyzer tool to check out who are eating your disk space and remove them accordingly. And here are a few tips to clean up your disk space.

3
  • sudo apt install flatpak gives me ``` Reading package lists... Error! E: Write error - write (28: No space left on device) E: IO Error saving source cache E: The package lists or status file could not be parsed or opened. ``` Oct 6 at 3:19
  • 1
    You don't have any flatpak apps installed, if the command does not exist and prompts you to install it via apt command. so just skip it.
    – Merilyn Ne
    Oct 6 at 3:50
  • 1
    Re cleaning up /usr: For most users, in most cases, the greatest possible savings is some combination of sudo apt autoremove and/or uninstalling software that you are no longer using. The apt autoremove command is usually safe, but it could theoretically break things if you've installed other software "manually" (e.g. by compiling a tarball). If all your software was installed through apt install or similar commands, then autoremove shouldn't remove anything you actually care about, in most reasonable cases.
    – Kevin
    Oct 7 at 1:35
0

You could try switching your filesystem to btrfs and enabling compression. This usually saves, depending on the files on the disk, a good amount of disk space.

But you should not delete /var or /usr as this will break your system.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.