1

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!

5
  • Cool! I'll look into how I could configure it.
    – HackXIt
    Jan 12, 2018 at 18:20
  • So... where do I see the output of autofs to troubleshoot? I can't get to the drive contents and it's slightly confusing.
    – HackXIt
    Jan 15, 2018 at 8:26
  • I really need help with this, I can't even get a simple automount to work, meaning to automount the hard drive on a specified directory. My intention is to have it mount once I "access" the directory and unmount when it's been idle for 60 seconds... But it's not working and I can't wrap my head around why. Text in auto.master is /share /etc/auto.ntfs -t=60 and in auto.ntfs is /share -uuid=UUID,fstype=ntfs :dev/sda1
    – HackXIt
    Jan 15, 2018 at 13:54
  • I've tried /dev/sda1 and :/dev/sda1. The :dev/sda1 was a typo. However both of those don't work. I did this according to this, quote If 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).
    – HackXIt
    Jan 15, 2018 at 15:12
  • Fixed it! auto.master: /- /etc/auto.ntfs -t=60 ; auto.ntfs: /sharing -fstype=ntfs :/dev/sda1. According to dmesq | 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.
    – HackXIt
    Jan 15, 2018 at 16:01

1 Answer 1

1

THE SOLUTION!

I've figured it out now. The error messages pointed me in the right direction (again) and digging through google searches I've come across the ntfs-3g package and also the ntfs-config package. The latter provides write ability for NTFS drives and just like that the message

Volume is dirty. Mounting read-only. Run chkdsk and mount in Windows.
didn't appear again. Accessing the shared drive from the windows machine worked after that like a breeze as well.

Another great help was the Nautilus file manager, which made permission handling so much easier by just going to the directory path and selecting "right-click -> Properties" and simply editing the Permissions and Share options from there. (This was clearly the easiest/beginner way possible to do this)

For future reference, here are all my configuration files and also the steps I've taken in the CLI:

auto.master: /- /etc/auto.ntfs -t=60

Linux Manual Page for auto.master

auto.ntfs: /sharing -fstype=ntfs :/dev/sda1

Linux Manual Page for automounter maps

smb.conf:

Edit the standard configuration and comment everything you DON'T need with hashtag or semicolon. Below are things I've edited.

[global]
workgroup = WORKGROUP # This was irrelevant for me but I left it activated
wins support = yes # Tells samba to act as WINS Server
#Recycle bin for mounted drive (useful feature, but not mandatory)
recycle:keeptree = yes
recycle:touch = yes
recycle:versions = y
recycle:maxsize = 0
#======================= Share Definitions =======================
#I've commented evverything here except the one I've created myself, 
#since I didn't want any of those default share definitions.
#Shared network drive
[share]
comment = Pi shared folder
path = /sharing
available = yes
browseable = yes
writeable = Yes
only guest = no
create mask = 0777
directory mask = 0777
force group = sambashare

Helpful Link regarding Server Types

Documenation of samba configuration file

CLI:

$ cd /
$ mkdir sharing

To show information regarding the created directory and it's permissions you can use the $ stat directory/file command

Below are commands for controlling the autofs and samba services. You'll need to restart these whenever you make configuration changes and want them to be applied

$ service autofs {start|forcestart|stop|restart|forcerestart|reload|force-reload|status}
$ /etc/init.d/samba {start|stop|reload|restart|force-reload|status}

After creating the directory, start nautilus by typing $ nautilus and navigate to the directory and edit the Permissions and Share options as mentioned above (the checkboxes are very self-explanatory). I've enabled write-read for local and windows users.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .