Personal notes on how to save disk space on my Ubuntu system.

Table of Contents

Docker

Pruning old images and containers

docker image prune
docker container prune

systemd journal

Checking disk usage

$ journalctl --disk-usage
Archived and active journals take up 2.3G in the file system.

Retaining last N days

journalctl --vacuum-time=10d

Snaps

Removing old versions

Snap retains older versions of installed snaps.

$ snap list --all
Name                                  Version                           Rev    Tracking         Publisher          Notes
audacity                              3.1.3                             1032   latest/stable    diddledani✪        disabled
audacity                              3.1.3                             1051   latest/stable    diddledani✪        -
bare                                  1.0                               5      latest/stable    canonical✓         base
chromium                              108.0.5359.124                    2254   latest/stable    canonical✓         disabled
chromium                              109.0.5414.74                     2271   latest/stable    canonical✓         -
…

This list can be used to remove older disabled versions

#!/bin/bash
#Removes old revisions of snaps
#CLOSE ALL SNAPS BEFORE RUNNING THIS
set -eu
LANG=en_US.UTF-8 snap list --all | awk '/disabled/{print $1, $3}' |
    while read snapname revision; do
        snap remove "$snapname" --revision="$revision"
    done

Retaining fewer old versions

sudo snap set system refresh.retain=2

Removing the cache

rm /var/lib/snapd/cache/*

Stack (Haskell)

It is safe to remove .stack/.

TODO Quicklisp

How to remove older versions of systems? Is it safe?

Date: 2023-01-22 Sun 00:00

Author: Stefano Rodighiero

Created: 2023-01-30 Mon 11:28

Validate