I have an external HDD (ext4) connected to my Raspberry Pi, which seems to mount via OSMC’s automounting and is automatically shared via Samba. My fstab and smb.conf both look fresh and unedited, and I don’t remember ever setting those up on this particular box, anyway. The drive gets mounted to /media as the root user; and as far as I know, root login is disabled, as well as remote login as root. Totally vanilla install, I believe.
On the other end, I have my Mac desktop with another external HDD (hfs+), which I use as the source for rsync to the external HDD attached to the Raspberry Pi as the destination. This HDD contains several folders/files where the permissions need to be left as-is.
So! The problem comes in when I try to rsync, as the osmc user on the Raspberry Pi doesn’t always have the correct permissions to read/write to the destination drive, since the drive is mounted as root and all the folders and files belong to root.
Obviously I don’t want to enable (remote) root-login, but I’m wondering what the easiest, most foolproof/upgrade-proof method would be here, which also doesn’t interfere with OSMC’s automounting and autosharing via Samba, as I have no idea how either of those works. Should I just mount the drive as the osmc user via fstab? Also, what settings does OSMC’s autmount use by default?
With the drive attached, could please the provide the output of on osmc:
ls -lah /media
@ridgek_lives Also if the drive is permanently attached you could consider using an FSTAB entry, which should resolve the permissions issue.
Hi Tom, thanks for your response. Here it is. The external HDD is “Gemini”.
drwxr-xr-x 7 root root 4.0K Dec 1 20:54 .
drwxr-xr-x 23 root root 4.0K Sep 6 2016 ..
drwxrwxrwx 4 osmc osmc 16K Dec 31 1969 BOOT
drwxrwxrwx 12 root root 4.0K Dec 1 20:47 Gemini
-rw-r--r-- 1 root root 232 Sep 14 09:28 README
drwxrwxrwx 9 osmc osmc 32K Dec 31 1969 RECOVERY
drwxrwxrwx 21 root root 4.0K Dec 31 1969 retropie
drwxrwxrwx 3 root root 1.0K Dec 31 1969 SETTINGS
drwxrwxrwx - these permissions look correct to me, the only thing I suggest trying from the command line:
sudo chown -R osmc:osmc /media/Gemini
Then try rsync again.
Thanks Tom. Does this change the ownership on the drive permanently? It occasionally gets moved around to other machines. I will probably use the uid/gid tags in fstab if that’s the case, even though the Raspberry Pi isn’t always booted with the drive connected.
That will be permanent, until you change again. It’s probably best to set the UID/GIDs to the most commonly used one, and use the fstab setting on other systems.
I wouldn’t necessarily chown -R. My share is owned by osmc:osmc but has backup directories in it owned by root. Works fine.
Okay, that’s what I thought. Thanks, everyone! I think I’ll stick with my original inclination to go with fstab. Does anyone know the default options OSMC’s automount uses? Is there documentation for it somewhere?
Thanks for your help, everyone!
Update: I found out fstab doesn’t support setting drive ownership when mounting ext4, so I ended up chown’ing (non-recursively) the drive after I mounted it. Turns out it mounts with the owner as osmc when using OSMC and when I boot into Raspbian, it sets the owner as pi, and everything else is preserved nicely. Works for me!