Reinstalling Ubuntu effects on Snaps

With the common partitioning of Linux, there is typically one root directory (/) and one home directory (/home). On my current system, it seems like the snaps are located on both partitions at the snap directory (/snap) and on a directory in my home directory (/home/<user>/snap ).

So the question comes at what happens when I want to do a complete reinstall of Ubuntu but I want to keep my home directory as is? Do I have to re-install my snaps because of the location at /snap (or /var/lib/snapd)?

The default ubuntu install has always only created a single big partition with everythig on it …

If you do a / and /home split during install you did this by picking manual partitioning in the installer.

Not sure about the backup location, but i’d guess /var/lib/snapd and /var/snap should be enough …

Sorry, I was not talking about the default partitioning of Linux, but a common strategy (As that is also what I have). I plan on doing a full reinstall of my whole system soon (reformat everything), and setting up the same 2 partitions. I made some mistakes (new to Linux) and want to start fresh again. I also heard that creating a /home partition is safer in case I want to reinstall Linux again but want to keep my /home partition as is.

That’s kind of my end goal … the ability to wipe and re-install on my root directory while keeping my home directory and my snaps.

Recently, I learned about snaps and was interested in using snap as much as possible, but I also saw that some snap data is located off of my home partition (directory) and in the partition of my root directory at /var/lib/snapd and /snap.

This would mean that I cannot keep my snaps if I want to reformat my root directory but keep my home directory, right?

Edit: Is all the important snap data on my home directory, but temporary data for my current “session” is stored on the root directory? Or is there important data on the root directory that cannot deleted with reinstalling the snap?

The snaps themselves are kept under /var, and mounted to /snap (or elsewhere under /var in some distributions). The snap’s user data is often kept in ~/snap (I say often and not always because if a snap is classic, or it has the home interface, then it could be set up to save them in ~/Documents or wherever).

If you have separate partitions for the system and for your home, and you format the system partition, you need to reinstall all the applications. Some of them might be snaps.

HTH.

1 Like

Got it. Thanks for the help.

I suppose there are ways of keeping the apps by splitting more directories into another partition on two, but that isn’t really done a lot, and I don’t think I really want to worry about sizing all these different partitions.

I will have to try to find the one article I read about this approach and see what they do to overcome having to reinstall everything or if that is what they do.

my point was that your new install should pick proper sizes here if you want to keep this split setup. if you dont use /var separately, make sure to pick / big enough since all snap bits apart from your personal user data will go there and snaps are usually a bit bigger than .deb packaged apps.

1 Like

I am evolving my understanding of all this…

The general idea of a snap is that it is self-contained and it can work on any Linux distro. You can take the exact same snap and have it work the same on Ubuntu and Fedora, etc. However, it seems like (according to my understanding of the conversation here) that when the snaps are installed, then they are “heavily” tied to the OS.

If you want to switch distros, then you could have created a /home partition to allow your documents, etc to be used on the new distros. However, that does not seem to be the same for snaps. If you swap distros, then you will have to reinstall all the apps (i.e. it is “heavily” tied to the OS).

Is this correct? If that is correct, then it seems to kind of go against the usability of the software to a degree.

CC: @niemeyer

Again, if this is all true, then shouldn’t there be a way to mitigate having to reinstall all the apps. Such as having all snaps live in a specific directory that can be partitioned away from root? Some way of spliting the OS from the snaps?

well, the new distro will come with a bunch of apps. Some of them might be snaps, some of them might not be. Any that are missing you’ll have to install. I’m not sure why you thought it would be different.

Snaps are not installed per-user, which is what you seem to think.

You are correct that my understanding of snaps is very basic.

Since using Windows and recently Ubuntu, I have always had the understanding that the apps are tied to the OS. Reinstall or swap distros, and then you have to reinstall the missing apps. This is because app data has to be placed in specific areas of the OS.

The difference all came with the idea that these are self-contained apps that don’t revolve around the hoping the developer places every file in the correct area. Their understanding of the directory hierarchy and general knowledge don’t matter anymore. That is because they are more “sandboxed” (if you will) That led me to wondering why they are still tied to the OS and can’t be separated.

If the only pushback is that the new distro will have its own snaps, then it becomes a technical solution. An idea that might be plausible to overcome this is something like 2 snap directories with specific priorities. One that is tied to the OS that doesn’t have to be partitioned away (low priority), and one that can be partitioned away so it can be used on multiple distros (high priority).

I know my knowledge in this is lower, but what am I missing where this can’t happen?

the bit you might be missing, or misunderstanding (and truly it should be completely invisible to you as a user, and only become known when it fails) is that there is a significant amount of glue between the OS and the self-contained snaps, that would get wiped together with the OS itself. Further, at least part of this glue is potentially OS-specific.

That’s not to say we couldn’t make it work as you imagine; a lot of the tech behind snaps originate in the Ubuntu Phone, where apps were indeed installed per user. However we learned that the complications that brings were not really worth it, and the feature can be safely deferred… so it was.

HTH.

1 Like

I agree it should be invisible to me as a user. I am just trying to understand what I can and can’t do because it had not been really explained and seemed to make sense to a degree.

This last comment by @chipaca seems to explain that to a good enough degree.

Thanks!