A more graceful way for snapd to fail when /snap is missing

Yup, ok that seems to hold true.

ls -la  /mnt/containers/snap/
total 263052
drwxr-xr-x 3 root root        70 Nov 13 16:52 .
drwxr-xr-x 4 root root       127 Nov  5 23:05 ..
-rw-r--r-- 1 root root  87089152 Nov 13 16:47 core_3247.snap
drwxr-xr-x 2 root root         6 Sep 26 18:41 partial
-rw-r--r-- 1 root root 182276096 Nov 13 16:52 warzone2100_12.snap

and

mount |grep snap
/dev/mapper/vg_ssd-snap on /mnt/containers type xfs (rw,relatime,attr2,inode64,noquota)
/mnt/containers/snap/core_3247.snap on /snap/core/3247 type squashfs (ro,nodev,relatime)
tmpfs on /run/snapd/ns type tmpfs (rw,nosuid,noexec,relatime,size=3270728k,mode=755)
nsfs on /run/snapd/ns/core.mnt type nsfs (rw)
/mnt/containers/snap/warzone2100_12.snap on /snap/warzone2100/12 type squashfs (ro,nodev,relatime)

So I guess I should really retitle this post to

A more graceful way for snapd to fail when /snap or /var/lib/snapd/snaps is missing.

A symlink will likely not work because of confinemnt. You need a mount or a bind mount at the very least. You can add a systemd mount unit to do the right thing.

A symlink will likely not work because of confinemnt. You need a mount or a bind mount at the very least. You can add a systemd mount unit to do the right thing.

Hmm atm I am sysytemd.mount /mnt/containers I have both flatpak and snap folders there. I spose I could just create a couple more LV’s and mount the separately but talk about added complexity.

You don’t need a partition, a bind mount will suffice and will be always working (unlike a symlink).

You don’t need a partition, a bind mount will suffice

Hmm ok that sounds plausible. It is all to do with timing really. Snapd starts up as soon as systemd.pre-mount finishes and root is mounted, meaning if /var/lib/snapd/snaps is not there it barfs.

I don’t spose snapd is smart enough to just check /var/lib/snapd/snaps for any realtime changes is it? Otherwise I could just leave snaps empty and bindmount over it later in the boot process and restart snapd

You can just say Before=snapd.service

You can just say Before=snapd.service

I already do that. I was just mulling over putting a lazy script unit in to do the bind mounts after it.

many snaps ship services and snapd generates a systemd service file on install … they would all fall flat on their face

if you would do realtime stuff here that would require a lot of additional plumbing to manage the services etc …

Meh… decided to keep it obvious. Edited /etc/fstab and added x-systemd.requires= and x-systemd.before= mount options.

means don’t really have to worry about change to systemd units , reboots etc.

Ok feel free to close the topic if you want. Think I have gotten the answer I need now.

FYI: I made this patch to snapd as a side-effect of this conversation: https://github.com/snapcore/snapd/pull/4210

We will now actively inform users casually browsing the filesystem about what is in /snap

FYI: I made this patch to snapd as a side-effect of this conversation: https://github.com/snapcore/snapd/pull/4210

We will now actively inform users casually browsing the filesystem about what is in /snap

Nice. Thanks!