Preface
I picked the title on purpose so that nobody can give me grief about systemd being a complete suite.
What's this about?
There are certain things I'd like to start automatically on Linux, whether on my server or my laptop.
interserver.net has a great deal when it comes to VPS with lots of storage. For my purposes it's more than enough.
So I went and bought a server there with 2TB of storage.
The idea is to use this server purely as FTP storage.
And so I don't have to mount the storage manually over and over again, I wanted to figure out how exactly I can mount said storage to /home/cashmere/archive/ in usermode.
Where exactly is the problem?
In one of my earlier blog posts, I already had a go at this topic.
That method still works perfectly fine.
Still, privately I work a lot more with ssh, so I just wanted to mount it automatically with that.
Let's get to the actual problem
Among other things I read through the SSHFS - ArchWiki and the SSHFS - NixOS Wiki, hoping to finally find a solution to a problem I've had for a long time. (See the date of the first blog post.)
Over and over I tried to set everything up correctly, and over and over my automount failed.
On the one hand it's of course down to my skill issue, I'll be honest, and on the other hand I personally absolutely don't see why I should have to learn systemd automounts and services just to find a way to start programs or scripts automatically.
Let's look at the problem a bit more closely
Every time I tried to start or automate systemd.automount, it mostly failed for the following reasons:
- Insufficient folder permissions
- Insufficient user permissions
- Mounting to
/home/cashmere/archivewas not allowed
It personally made no sense to me, since I can mount it in my shell without any problems and automatically.
Besides my existing SSH keys, I created another passkey without a password, so that it can still be mounted securely, without a password prompt and without a user password.
I also created a dedicated entry in my /.ssh/config that assigns exactly the right private key to my mount:
Host archivebox
IdentitiesOnly yes
User cashmere
HostName 0.0.0.0
IdentityFile /home/cashmere/.ssh/archivebox
Now when I typed the command sshfs archivebox:/home/cashmere/ /home/cashmere/archive/ into my shell, it worked without any problems.
So just for fun I thought to myself: "Come on, take exactly that command, exactly like this, throw it into my riverwm init and restart the machine. Does the mount still work automatically?"
And lo and behold, it worked.
After that, just for fun, I searched for a video on how you even start something like this automatically in usermode on Linux. Of course I knew how to start things for a window manager, but because of the unnecessary complexity of systemd.automount, I would never have even considered that you can automate sshfs with it too.
Here too Distrotube once again has a great video, 3 years old, where he explains in detail how to start scripts and programs automatically as a user.
What do we learn from this?
-
Have I finally automated my mount now? No, BUT I saved it as an alias. I also tested that alias and it worked!! So in theory I could do it, and I even had it working in practice!
-
Will I ever use
systemd.automount? Not right now, because it's dead unnecessary to go through that much effort for something this trivial. I have absolutely nothing against systemd, I use it all the time and in many cases it's often helpful. Still, I think in usermode small scripts are often enough, and they spare you the effort of automount.