Using symlinks will fail on rbind-ing /var/snap into a snap-specific tmp dir:
sudo snap install lxd
error: cannot perform the following tasks:
- Run configure hook of "lxd" snap if present (run hook "configure": cannot perform operation: mount --rbind /var/snap /tmp/snap.rootfs_IMy4UQ//var/snap: Permission denied)
Using bind mounts failed for me too in a different way (not sure why, but likely because of nested bind-mounting).
/etc/fstab:
/mnt/sc1/var-snap/ /var/snap/ none defaults,bind 0 0
/mnt/sc1/var-lib-snapd/ /var/lib/snapd none defaults,bind 0 0
I have a hardware RAID-5 with a lot of space available represented as a single block device. Having partitions with separate file systems on it for /var/snap and /var/lib/snapd isn’t great because I have to manage partition size in advance.
I solved it for now using btrfs with separate subvolumes used for snap purposes.
/etc/fstab:
UUID=ae30a62b-db2f-4e50-ad63-e8c81bcf7781 /var/snap btrfs subvol=snap 0 0
UUID=ae30a62b-db2f-4e50-ad63-e8c81bcf7781 /var/lib/snapd btrfs subvol=snapd 0 0
There is a trade-off in this as if I lose the RAID for some reason I will no longer be able to use snapd. Still, having all data stored on rootfs isn’t suitable as it is a small-size SSD device in my case and I need to be able to store a lot of data on a separate device.
To my mind this would be quite common on routers or other small devices that have a limited amount of space in their internal flash memory so it deserves a feature or at least documentation for better UX.