Score:4

should I delete var or usr directories

mp flag

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.
muru avatar
us flag
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.
guiverc avatar
cn flag
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 avatar
cn flag
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?
muru avatar
us flag
Add the output of `df -h` as well, please.
mp flag
@guiverc, "How much disk space did you allocate?" I have no idea. I am not even knowledgable enough to know that there is a program called Desktop. How can I explore how much I allocated?
guiverc avatar
cn flag
You allocated 19GB, where the minimum was 25GB for Ubuntu Desktop (https://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)
mp flag
How do you know that I allocated 19GB? Is it from the line that states "fact that /dev/nvme0n1p3 19G 19G 0 100% /"
guiverc avatar
cn flag
Yep, you allocated 19GB for / which is where the Ubuntu Desktop installed to, which includes all apps you'll add, upgrades etc. If you upgrade regularly (*and not let upgrades accumulate*) you can get by with less, but it's at a higher-maintenance burden. Many 3rd party bloggers don't upgrade systems, don't add apps (they only want to review it - 8.6GB is listed as that's needed for that as they'll *nuke & install* their next OS post review), but some package types use more space than others, so I feel more space is just easier. My system has 27GB but I wish I'd given 32GB
mp flag
Guiverc, Thanks. Your last comment is a very helpful addition to your comments. I think you are right, the next step is to ask how to increase disk partition size.
GACy20 avatar
sa flag
Do you have docker installed? If so maybe try a [`docker prune`](https://docs.docker.com/config/pruning/). Docker can easily consume gigabytes in unused images or unused volumes.
mp flag
@GAXy20, How can I determine if docker is installed?
us flag
@GACy20 Docker images would show up under `/var/lib/docker` and this is not listed in the poster's `du`. `/var/backups` is the largest offender so that would be the first place to prune.
Score:13
sy flag

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.

mp flag
`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. ```
Merilyn Ne avatar
sy flag
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.
ua flag
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.
Score:0
do flag

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.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.