I have a Raspberry Pi with samba installed. I've looked into autofs and saw the potential of automounting an external harddrive upon accessing it over the network by my windows machine.
Appearantly the provided auto.smb
configuration is intended for a samba client application, but my intention is the other way around. I want the Server to automount my harddrive whenever I access it over the network and automatically unmount it after 5mins or so. Plus the fstype should be set to NTFS.
From my current understanding of autofs
what I need to do is create a configuration file, let's name it auto.ntfs
:
contents of auto.ntfs
:
driveA -uuid="UUID of my drive",fstype=ntfs,verbose=1 :/dev/sda1
Then I need to add that configuration into the auto.master
like so PATH MAP -options
To specify, my PATH is /share
so I would add /share /etc/auto.ntfs -t=60
into /etc/auto.master
to successfully automount my external harddrive into that directory every time I access it over the network.
Did I understand the way this works correctly and what should I do about the configuration file? Are there any things I need to consider doing this? Is it possible?
I'd like to have the possibility on this answered. (no I don't want other solutions than samba and yes it has to be NTFS)
UPDATE
I've added the configuration file. My problem now is that the contents of the drive are not shown as I'm trying to locally access the drive for it to be automounted just to test the feature itself.
auto.master:
/share /etc/auto.ntfs -t=60
auto.ntfs:
/share -uuid=E820DC6120DC3870,fstype=ntfs :/dev/sda1
This doesn't work. When I go into the /share directory I can't see the contents of the drive. Here's an output of $ service autofs status
:
Jan 15 13:57:04 raspberrypi automount[529]: key ":" not found in map source(s).
Jan 15 13:57:04 raspberrypi automount[529]: failed to mount /share/:
Jan 15 13:57:04 raspberrypi automount[529]: re-reading map for /share
FIX for above
For people that are interested in this question in the future, the above got fixed by checking the dmesg
related messages, which pointed me at the actual cause of the problem instead of just saying that it doesn't work. This command can be helpful to find it out:
$ dmesg -w | grep ntfs
(you can grep for other message types if that's different for you)
The issue was that the option -uuid
was not supported.
My final configuration now looks like this:
auto.master:
/- /etc/auto.ntfs -t=60
auto.ntfs:
/sharing -fstype=ntfs :/dev/sda1
After all this bugfixing, it comes to the final topic at hand: Samba
Currently my problem is that whenever the drive gets mounted it changes the permissions inappropriately. I've created the shared directory using nautilus-share
, since I can simply check the appropriate options there.
Here is a snippet of $ stat sharing/
when autofs is disabled:
Access: (0777/drwxrwxrwx) Uid: ( 0/ root) Gid: ( 0/ root)
Here is a snippet of same command when autofs is enabled:
Access: (0500/dr-x------) Uid: ( 0/ root) Gid: ( 0/ root)
The access is edited upon mount, according to this dmesg message:
ntfs: (device sda1): load_system_files(): Volume is dirty. Mounting read-only. Run chkdsk and mount in Windows.
ntfs: (device sda1): load_system_files(): $LogFile is not clean. Will not be able to remount read-write. Mount in Windows.
I don't know what to do now. Where did I go wrong? I'm thinking that I might need to configure the permissions in the configuration file of autofs, but I'm unsure due to the message above.
I would be open on suggestions of changing the partition format to something more appropriate if ntfs is NOT suggested to be used as a shared mount!
auto.master
is/share /etc/auto.ntfs -t=60
and inauto.ntfs
is/share -uuid=UUID,fstype=ntfs :dev/sda1
/dev/sda1
and:/dev/sda1
. The:dev/sda1
was a typo. However both of those don't work. I did this according to this, quoteIf the filesystem to be mounted begins with a / (such as local /dev entries or smbfs shares) a : needs to be prefixed (e.g. :/dev/sda1).
/- /etc/auto.ntfs -t=60
; auto.ntfs:/sharing -fstype=ntfs :/dev/sda1
. According todmesq | tail
the provided uuid option was causing the issue, since it didn't recognize the command. I'll need to figure out how to do that properly... So locally it works now yes. I'll check out how to get samba working tomorrow, need to go.