Disk space awareness

The snap daemon, snapd, can check whether there is enough free disk space before performing the following space-requiring operations:

  • snap installation: checks storage required to download a snap
  • snap refresh and update: checks storage required to download updates and to store previous snap revisions
  • snap removal: checks storage required to create the automatic snapshot generated when the last revision of a snap is removed (unless disabled)

:information_source: Disk space awareness is currently an experimental feature and requires snapd version 2.47+ .

When enabled, snapd checks whether there is enough space in /var/lib/snapd to complete an operation, such as enough space to store a requested snap to download. If there isn’t enough space, an error is returned and the operation is not performed:

$ snap install foo
error: cannot install "foo" due to low disk space

The error output can also include a hint on how a space requirement could be mitigated, such as suggesting the --purge flag with snap remove to disable the automatic snapshot generation:

$ snap remove foo
error: cannot remove "foo" due to low disk space, use --purge to avoid creating a snapshot

The REST API will also return an insufficient-disk-space Error kind object when disk space awareness is enabled and an error is encountered.

Enable disk space awareness

To enable disk space awareness, set one or more of the following experimental feature flags to true:

  • experimental.check-disk-space-install
  • experimental.check-disk-space-refresh
  • experimental.check-disk-space-remove

To enable the pre-install check, for example, use the following command:

$ snap set system experimental.check-disk-space-install=true

See System options for more details on setting and disabling options.

2 Likes

Is this feature still experimental? Seems like it’s had enough time to stabilize.

It’s 2024, and I also wonder if this is experimental.

I also would like a link (at the bottom of this page) to a page explaining how to get disk space when / gets full.

1 Like

I would suggest to add something like:

Snapcraft: freeing some disk space used by building (files generated by " --debug " argument):

/var/snap/multipass/common/data/multipassd/vault/instances/
$ multipass list
$ multipass delete snap-instance-name
$ multipass purge

More details about removing unused libraries would be welcome.

Added later: I got back a lot of space in my root after uninstalling LXD (‘snap remove lxd --purge’).

1 Like

Hello! Thanks for raising this. These long-standing experimental features are less than ideal, and the snapd team has been trying to address this by first understanding what works needs to be done, and then scheduling this work.

We’re currently looking for feedback, which we’ll then use to prioritise and plan the work:

1 Like