Lakka-LibreELEC icon indicating copy to clipboard operation
Lakka-LibreELEC copied to clipboard

switch - access denied when trying to mount NAS share for roms etc.

Open jdalmanza opened this issue 1 year ago • 10 comments

when following the steps to mount a NAS share for roms as described in the lakka documentation: https://www.lakka.tv/doc/Serving-ROMs-from-a-NAS/

When you reach the step to enable the storage-{path}.mount service you get an Access denied error:

Lakka:~ # systemctl enable storage-nas.mount Failed to enable unit: Access denied

This issue is present on 4.3 and still an issue in the 5.x nightly builds (tested on 15-JAN nightly build)

jdalmanza avatar Jan 15 '24 17:01 jdalmanza

Thank you for the report!

Ntemis avatar Jan 15 '24 18:01 Ntemis

@Ntemis , i tried this on the 17-JAN build and got he same results logset attached, please let me know if you need anything else log-2024-01-24-00.51.52.zip

jdalmanza avatar Jan 24 '24 01:01 jdalmanza

Searching for this issue yields results relating to selinux, but I don't think that applies here. Still, you can try to run systemctl daemon-reexec before the enable command and see if that helps.

synthic avatar Feb 05 '24 16:02 synthic

lakka (official): devel-20240123161432-37de45a (Switch.aarch64)

lakka-switch:~ # ls /storage/.config/system.d/ README multi-user.target.wants openvpn.service.sample cifs.mount.sample nfs.mount.sample storage-nas.mount lakka-switch:~ # systemctl daemon-reexec lakka-switch:~ # systemctl enable storage-nas.mount Failed to enable unit: Access denied

lakka-switch:~ # cat /storage/.config/system.d/storage-nas.mount [Unit] Description=cifs mount script Requires=network-online.service After=network-online.service Before=retroarch.service

[Mount] What=//xxx.xxx.xxx.xxx/retroarch Where=/storage/nas Options=username=xxx,password=xxx,rw Type=cifs

[Install] WantedBy=multi-user.target lakka-switch:~ #

@synthic This exact file works on all my other lakka devices 4.3 and 5.x the switch build is the only one that fails

jdalmanza avatar Feb 05 '24 17:02 jdalmanza

ow! missed the switch part. Reopening and assigning to the proper person

Ntemis avatar Feb 06 '24 04:02 Ntemis

lakka (official): devel-20240123161432-37de45a (Switch.aarch64)

lakka-switch:~ # ls /storage/.config/system.d/ README multi-user.target.wants openvpn.service.sample cifs.mount.sample nfs.mount.sample storage-nas.mount lakka-switch:~ # systemctl daemon-reexec lakka-switch:~ # systemctl enable storage-nas.mount Failed to enable unit: Access denied

lakka-switch:~ # cat /storage/.config/system.d/storage-nas.mount [Unit] Description=cifs mount script Requires=network-online.service After=network-online.service Before=retroarch.service

[Mount] What=//xxx.xxx.xxx.xxx/retroarch Where=/storage/nas Options=username=xxx,password=xxx,rw Type=cifs

[Install] WantedBy=multi-user.target lakka-switch:~ #

@synthic This exact file works on all my other lakka devices 4.3 and 5.x the switch build is the only one that fails

This works for me, just need to set protocol version in options line..... testing against samba version packaged in libreelec/lakka, the needed protocol version is 2.1, though that is depending on your server.

Options=username=xxx,password=xxx,rw,vers=2.1 was the only required change

Oh, I missed the enable part..... yeah, no idea why that isnt working, though if I had to guess, it has to do with the fact it is trying to change permissions on a file on a fat partition, which it cant.

you can start the service manually, but probably will never be able to enable it on boot, due to this limitation, without creating a new image, and including the mount in the image.....

Actually.... I might be able to work around this issue, though, I cant promise it will work, if it tries to connect mount before wifi comes up, I would still expect it to fail on boot.

GavinDarkglider avatar Mar 17 '24 04:03 GavinDarkglider

Ok, figured out what is going on here....... Not really sure how to fix it properly though..... I might be able to hack something together, but this comes down to how systemd enables services(Creates Symlinks in a bunch of folders, to the service/mount file). Unfortunatly, fat32/exfat do not support symbolic links at all, hince the access denied when trying to enable it.

This issue has probably existed since the first version of lakka on the switch(Before I re-ported/upstreamed), and no one noticed it, because no one else was trying to add systemd unit files to storage and enable them. lol.

That being said, I am going to test some stuff, and see if I can work around the issue for you, probably wont be the cleanest fix ever, but the other option is moving storage to a proper linux partition on the SDcard which kind of ruins the magic of what lakka does for the average switch user. That and for something like libreelec, that will be absolutly needed for things like VPN bring up...... so .....

GavinDarkglider avatar Mar 17 '24 17:03 GavinDarkglider

actually that makes a lot of sense about the symlinks. So, let's say that the switch version cannot mount a nas share like a service as the other builds do, how hard would it be to offer an easy way to easily mount a cifs/samba share via the gui. i figure folks that know what they are doing can probably mount manually via the command line or even maybe edit the fstab if that is allowed. I'm willing to close this out with that explanation as-is and maybe turn it into a feature request for a gui enabled nas mount function?

jdalmanza avatar Mar 17 '24 17:03 jdalmanza

actually that makes a lot of sense about the symlinks. So, let's say that the switch version cannot mount a nas share like a service as the other builds do, how hard would it be to offer an easy way to easily mount a cifs/samba share via the gui. i figure folks that know what they are doing can probably mount manually via the command line or even maybe edit the fstab if that is allowed. I'm willing to close this out with that explanation as-is and maybe turn it into a feature request for a gui enabled nas mount function?

The reality is, this should be fixed, to keep uniformity with all builds. While I agree with you this should be added to the gui, which is also possible, and then have it start the services for systemd, if the user enables them at boot time......

that is kind of a dirty hack though. Currently, you should be able to use the mount file you created....... systemctl start storage-nas.mount you just cant set it to start on boot.

GavinDarkglider avatar Mar 17 '24 18:03 GavinDarkglider

The not so pretty way to work around this would be to call a script in this file: https://github.com/libretro/Lakka-LibreELEC/blob/Lakka-v5.x/packages/lakka/retroarch_base/retroarch/scripts/retroarch-config

then you can put the systemctl command in a script on your sdcard, and still start it before retroarch starts. That being said, it would still need a new image, so let me play with some more messed up, but also more uniform options, that might fix the issue, as that would be ideal.

The more uniform way is to see if mergerfs's newish symlink support works across file systems, and to do some trickery in initramfs...... in which case, I can create the symlinks in an ext4 based image, and overlay the filesystems like we do with the retroarch configs. which in therory should "properly" fix the issue. Assuming I understand how this new support actually works. lol.

GavinDarkglider avatar Mar 17 '24 18:03 GavinDarkglider