Where is a snap stored and how can I change that?

Hi there, as a non-developer, I hope this is the right place to ask it, because I obviousely wasn’t able to find it on the interweb.

  1. On a, lets say, typical ubuntu, where are installed snaps stored / saved?
  2. Another thing is, that pains me, is that old package management systems depend on the developer to either hard code the destination for the insall into it or make extra effort to enable the user to select that destination. As far as I understand it. Therefore I have hope, this might have been considered for snappy.
1 Like
  1. By default they are in /var/lib/snapd/snaps for snaps installed from the store. I don’t know if there is any way to change that and I also don’t know why you would care to change it (see point 2). If you use the “snap try” command, it can of course be anywhere.

  2. Snap actually takes an opposite approach by using virtual namespaces, bind mounts and other kernel features so that developers and users don’t have to worry about install paths. When you launch a snap app, it will always see its install directory in /snap/appname/current, no matter where it’s physically installed. If you’re a developer or a package maintainer and you need to deal with a hardcoded install path, you can safely rely on that one.

2 Likes

Thank you very much jzimm. Unfortunately this topic wasn’t considered in snappy either. Thus I still haven’t found any chance or way to place different applications on different drives / volumens.
After all that years with GNU/Linux, I am still astounded, that people wonder, why that could be usefull. Most power users comming from windows wonder how that simple thing does not work on Linux.
So to answer your question: This is usefull to people who use a lot of large applications with lots of data. A simple example are gamers, where games can ammount to several terrabytes.
Or is there a linux typical work around that I do not know of? No need to answer that, since that does not apply this forums topic.
But I had wished for snappy to be more versatile, like having interchangeable locations for snaps.

To move the snap storage to a separate disc you would set a mount point to your alternative location for either /var/lib/snapd/snaps or one of the parent components of that chain, e.g. /var/lib or /var. The compressed file-system of each snap is stored in that folder in a squashfs file, one for each snap.

To move the user-level storage to a separate disc, which is useful if a snap downloads a large data chunk like steam would do, then you would need to set a mount point to your alternative location for either /home/your-user/snap or a parent component of that chain, e.g. /home.

Note that you can’t use a symbolic link in place of the /var/lib/snapd or $HOME/snap because the apparmor confinement cannot automatically update itself to point to the target of that link, as that would open a security hole.

3 Likes

Wow, cool!, Thanks, daniel! Well that helps me, and thanks for the advice about apparmor. My last hope is, that this will become as easy as windows users are used to it, scince I hope for more migrants to Linux. That goes right into my Tomboy’s clever Tipps section.

May I use mount --bind instead of symlinks as a way to “simulate” them and relocate snap directories in existing filesystems? Should that work?

yes, bind mounting instead of symlinking will work fine

1 Like

Thanks for the reply! :slight_smile:

A post was split to a new topic: Security concerns about user data in ~/snap/

Just thinking, there is another possibility too, using OverlayFS you could keep your snaps between multiple volumes or locations, and just make them “appear” under /var/lib/snapd/snaps. Same thing for the data directories.

Disclaimer: I haven’t actually tried this so I’m not sure whether AppArmor would be fine with that.