4

I prevously removed snapd, however, the /snap directory is still there, and consumes a lot of space. How to remove it?

I tried sudo rm -rf /snap, but that says

rm: cannot remove '/snap/path/to/file': Read-only file system

for all files in the directory.

I really did not understand why I could not delete those files even as a superuser, despite snapd already being uninstalled.

Archisman Panigrahi
  • 25,210
  • 17
  • 90
  • 185
  • I'm not a snap user but it seems `/snap` was mounted as a small loop device which uses squashfs. And squashfs is read-only filesystem. Related to my comment: [Small snap loop devices visible in gnome-disk-utility OR what is the function of snap ubuntu-core](https://askubuntu.com/questions/834093/) – Kulfy Jun 23 '20 at 05:20

1 Answers1

6

I found it.

sudo apt autoremove --purge snapd

Note: autoremove is optional. It removes the dependencies which were explicitly required for snapd, and this will free up some space.

Archisman Panigrahi
  • 25,210
  • 17
  • 90
  • 185
  • 1
    `autoremove` is overkill there, it will remove all packages (not just those pulled by `snapd`) `that were automatically installed to satisfy dependencies for other packages and are now no longer needed as dependencies` ([manpage](http://manpages.ubuntu.com/manpages/focal/en/man8/apt.8.html)). There might be other packages in the OP's system that were automatically installed, no longer needed but still in use. The answer should take care of just the original problem. – Eduardo Trápani Jun 23 '20 at 05:06
  • 1
    `that were automatically installed to satisfy dependencies for other packages and are now no longer needed as dependencies` --- autoremove only removes them only if those other packages are removed. If something is no longer needed, removing that won't break the system. Suppose C is dependency for both A and B. You have uninstalled B. `autoremove` won't remove C unless you manually remove A as well. – Archisman Panigrahi Jun 23 '20 at 05:08
  • Say you do: `apt-get install lynx snapd`. That will also pull `lynx-common`. Now, remove just `lynx` and your system will still have `lynx-common`, ready to be autoremoved because it is not a dependency anymore. Your command above, at this time, will purge `snapd` **and** remove `lynx-common`. That's quite a side effect for a one-liner meant to take care of just `snapd`. – Eduardo Trápani Jun 23 '20 at 05:26
  • Isn't snap required to run Gnome desktop environment on Ubuntu Desktop? – Artur Meinild Mar 11 '22 at 13:24
  • 1
    @ArturMeinild No, you can run Gnome without snap. – Archisman Panigrahi Mar 11 '22 at 17:54