Hi There.
I struggled with this myself, as i could not find any one clear guide with the requisite steps, so I thought I’d just show everyone exactly what I did to make it work.
I want mine to be in /opt/snapd
Please note, this was on Manjaro, but i see no reason it should not function elsewhere: (given the proper install command, of course)
First, install snapd
sudo pacman -Sy snapd
Then disable snapd and snapd.socket services:
sudo systemctl stop snapd
sudo systemctl disable --now snapd.socket
Then move the snapd folder to the desired location, for me that was in opt
sudo mv /var/lib/snapd /opt/snapd
Then create a new snapd folder in /var/lib/snapd
sudo mkdir /var/lib/snapd
We then mount the dir containing the actual files into the original snapd path, using mount --bind like so:
sudo mount --bind /opt/snapd /var/lib/snapd
Then, to use apps with classic confinement, we need to symlink snap to the root, it’s important though that it’s linked from /var/lib/snapd, this will do the trick:
sudo ln -s /var/lib/snapd/snap /snap
Now we should be good to actually start the snapd service
sudo systemctl enable --now snapd.socket
and finally we need to make certain that the dir mount is performed at every startup, elsewise whatever you install in this session will not work after next reboot. First open fstab (i used nano for this):
(warning though: messing this file up can break your system, so do not touch the existing lines!)
sudo nano /etc/fstab
we add the following line to the end of the /etc/fstab
/opt/snapd /var/lib/snapd none bind 0 0
Reenable snapd services:
sudo systemctl enable --now snapd.socket
sudo systemctl start snapd
And that’s that. To verify that everything works, login to the snap store:
snap login youremail@address.domain
and install some app, since we wish to verify that everything works, including classic confinement, lets go for Visual Studio Code:
snap install vscode --classic
Run the app to make sure it can start:
snap run vscode
Once it has, i advice rebooting and try starting it again. If it worked before reboot, but not after, go back and verify that the line you added to /etc/fstab was correct.
I hope this helps someone. Cheers!