Space filling up on drive after updates

Space on my VM appears to be filling up after updates have been downloaded. It is getting to the point where I no longer have space for further updates.

Maybe try sudo apt autoclean to remove old deb files from archive

Welcome to Ubuntu Discourse :slight_smile:

I moved your post to the correct category; you had wandered into the support area for Spanish speakers :sunglasses:

We need more information:

df -h
lsblk -f
sudo du -h /var/log | sort -hr | head

Please wrap output with code tags when posting back (use </> in the composer after highlighting the text).

Thanks

Typically there’s three things that fill up the system part of your drive:

  1. The cache for deb packages downloaded and installed through apt. These are in /var/cache/apt/ and are kept there in case you want to uninstall and reinstall a package (e.g. to get it’s configuration back to the defaults …). sudo apt autoclean will remove packages that can’t be downloaded anymore (e.g. you tried out a PPA, didn’t like the software, and removed it from your sources; ā€˜autoclean’ should remove those packages from the cache). To clean out the cache completely you use sudo apt clean.
  2. snap backups. snap keeps at least one older version of each installed package in case you want to rollback to an older release of a program e.g. because of a bug introduced in the new version. You can’t stop snap from keeping these and there is no one-shot command to get rid of all the backups. You have to get a detailed list of the snaps with snap list --all and then remove each old version with snap remove --revision RNUM SNAPNAME with RNUM being the revision number and SNAPNAME the name of the snap.
  3. The last thing are log files growing. This is usually a sign of something more going on and quite possibly something bad. Logs are normally rotated after a certain time (meaning the oldest log gets deleted, the newest old log gets compressed, the current log gets closed, and a new log is started; this means you have the current log and the previous log uncompressed and several older logs compressed). If log files grow really large this is a sign that something is putting out a lot of messages and those might be signs of misconfigured software, failing hardware or – especially if the machine is a server accessible from the internet – an attack. Never just delete large logfiles, look at them and try to figure out what made them grow.

That depends on your settings for your package manager. In my case, I use

  • Synaptic

For Synaptic, open the ā€œPreferenceā€ screen, then click on the ā€œFilesā€ tab. There, you will see an option to clean all package files (not really needed after installation).

Otherwise, you can choose one of the settings, depending on your preference. As you can see, I choose to keep all but, for your constrained configuration, you may prefer to use the second choice,

  • Delete downloaded packages after installation

SNAPSHOT__Synaptic__KeepOrPurgePackagFiles

There is a one-shot command.

Tried to download Synaptic Package Manager from software app. Displays ā€˜download failed’.

OK, I stand corrected:

There is no one-shot command in the normal Ubuntu tools but there is a user-contributed script.

After reading through the script I find it somewhat disturbing that you parse the output of ā€˜snap list --all’. One should (almost) never parse output meant for human consumption in a script. It would probably be better to use 'snap debug api ā€˜/v2/snaps/?select=all’ (or use curl and send the API request to the socket in ā€˜/run/’) and parse the JSON you get through ā€˜jq’. Human readable output is subject to change and might be different depending on localisation, an API should be (more) stable.

1 Like

Thanks for your comments. Sure, there are certainly many possible solutions to solve this ā€œproblem.ā€ Currently, however, each user must solve this manually by entering commands into the terminal for each snap. To simplify these processes, we simply create a shell script to automate the execution of sequential commands and enable batch processing. And that is exactly what the script is supposed to be. The script is also locale-independent; where the output is locale-dependent, it falls back with LANG=C to the default locale.

You should be able to download that using the command line approach.


First, do some cleanup:

sudo apt-get purge synaptic

I would recommend a reboot after that, just to make sure there are no ā€œleftoversā€.


Then verify the availability of the package using:

sudo apt search ^synaptic$

In my case on UM 22.04, I get

Sorting... Done
Full Text Search... Done
synaptic/jammy,now 0.90.2build1 amd64 [installed]
  Graphical package manager

Then, to download, enter:

sudo apt-get install synaptic

It appears that your sources are not up to date, 24.04 isn’t jammy.

1 Like

Sorry. Correction applied.

If you are using ā€œapt-get-updateā€ all updates will be stored in ā€œvar/cache/apt/archivesā€. That would include the firmware update which is 600+ Meg. Better to use apt-update which does not store the updates. Just guessing at this.

1 Like

You can go to var/cache/apt/archives and delete them, but don’t delete the ā€œlock dirā€.

@victorylap26748 still waiting to see the output of commands suggested by @rubi1200 those commands will help us get a bigger picture of the layout of your storage.

3 Likes

This only cleans about 200 MB off the disk.

user@user-VirtualBox:~$ df -h
Filesystem      Size  Used Avail Use% Mounted on
tmpfs           597M  1.7M  595M   1% /run
/dev/sda2        25G   20G  4.0G  84% /
tmpfs           3.0G     0  3.0G   0% /dev/shm
tmpfs           5.0M  8.0K  5.0M   1% /run/lock
tmpfs           597M  176K  597M   1% /run/user/1000

user@user-VirtualBox:~$ sudo du -h /var/log | sort -hr | head
[sudo] password for user: 
429M	/var/log
412M	/var/log/journal/d94379dfe6984c59a05b66e5cd79e778
412M	/var/log/journal
1.5M	/var/log/installer
528K	/var/log/apt
180K	/var/log/sysstat
140K	/var/log/unattended-upgrades
84K	/var/log/cups
60K	/var/log/installer/block
24K	/var/log/installer/curtin-install

lsblk -f command just causes a blank flickery screen on the terminal.

I managed to download Synaptic Package Manager on a new clone VM. I selected ā€˜delete downloaded packages after installation’ but it doesn’t free up the space on the disk.

25G is exactly the required minimal space for an Ubuntu installation. This obviously doesn’t leave much for any updates or installations of additional programs. If this is just a VM, you should add 10-20GB to have space to breathe.
On my system - XUbuntu, / and /home on different partitions of a 1T SSD - the root-partition is 100 GB and I have about 65 GB available and slightly more than 25 used (the missing 10 % in those number is the part reserved for the root user to avoid the system going down because it’s unable to write the journal / logs).

3 Likes

In addition to @hdd-gehrke point, which needs to be solved by using your hypervisor to expand the size of your VM image, after backing up of course… do you by chance have any ISOs sitting in your downloads folder? If so, perhaps you can copy it elsewhere to free up some space.

1 Like