THobson
Posts: 14
Joined: Wed Aug 07, 2019 4:13 pm

Writing to an External Drive from the network

Tue Dec 03, 2019 4:08 pm

I have, I thought, a very simple project but it is proving strangely difficult. I want to be able to have read/write access to an external drive connected to a pi4 from my Mac using Finder and via a little Python program I have written that runs on the Mac. I do not want a NAS solution where a specific hard drive is dedicated to this purpose, I want to be able to plug and play several external drives singly or collectively to the pi4

I have gone through the steps set out here:
https://pimylifeup.com/raspberry-pi-afp ... ent-20409
and as a result I am able to ‘see’ an external drive connected to the pi4 from Finder on my Mac and also from the Python backup program I have written which runs on the Mac. By ‘seeing’ I mean I can see what is there and I can read everything, I just cannot write to the drive. I have messed around with permissions for the relevant folders but that has not helped.

My /etc/netatalk/afp.conf file contains:

[Homes]
based regex = /home

[My AFP Volume]
path = /media/pi
read only = false

It feels like such a simple step to get write access to the drive but it is eluding me.

By the way I am a bit of a newbie when it comes to the pi so to help me you would need to be a bit more explicit than you would for other people here.

Many thanks

THobson
Posts: 14
Joined: Wed Aug 07, 2019 4:13 pm

Re: Writing to an External Drive from the network

Fri Dec 06, 2019 12:46 am

I am not sure if it is allowed here to comment on your own post, but I am curious.

Previously when I have asked questions here I have had many very helpful replies, very quickly. Do I take it from the lack of any replies to my question that it is not possible to gain write access to an external drive connected to the usb3 port of a pi 4 from a machine elsewhere on the network?

ejolson
Posts: 5640
Joined: Tue Mar 18, 2014 11:47 am

Re: Writing to an External Drive from the network

Fri Dec 06, 2019 1:14 am

THobson wrote:
Fri Dec 06, 2019 12:46 am
I am not sure if it is allowed here to comment on your own post, but I am curious.

Previously when I have asked questions here I have had many very helpful replies, very quickly. Do I take it from the lack of any replies to my question that it is not possible to gain write access to an external drive connected to the usb3 port of a pi 4 from a machine elsewhere on the network?
You could export the physical drive from the Pi using iSCSI and the Mac should have a client to mount that. Given the different marketing segments, I suspect there are relatively few Mac owners who also use Pi computers.

renice123
Posts: 237
Joined: Tue Oct 15, 2019 3:56 pm

Re: Writing to an External Drive from the network

Fri Dec 06, 2019 7:09 am

Good day! I think this question does not concern many people. By tradition, Linux systems often use NFS (or any other protocols with this or that functionality) precisely to prohibit accidental or intentional writing to network file systems. Yes, security policy is sometimes annoying, but it’s security - the better the security, the more uncomfortable for the user. Therefore, creating a python script with the ability to write to a network drive seems to be a global Linux security violation, and naturally, you will have to configure access rights and so on.
Python itself is a language that provokes errors (as it was, for example, with the Ada language), it can hardly be considered a uniquely successful decision to write a program to access a network drive in this language. Although this is a programmer's decision. But you definitely have to solve security issues if you want to create a “Linux solution”, and not just a program for yourself =)
It's nice to see that there are more and more active Linux users and novice programmers trying to create their own solutions! I wish you success!

THobson
Posts: 14
Joined: Wed Aug 07, 2019 4:13 pm

Re: Writing to an External Drive from the network

Fri Dec 06, 2019 11:23 am

renice123 wrote:
Fri Dec 06, 2019 7:09 am
Good day! I think this question does not concern many people. By tradition, Linux systems often use NFS (or any other protocols with this or that functionality) precisely to prohibit accidental or intentional writing to network file systems. Yes, security policy is sometimes annoying, but it’s security - the better the security, the more uncomfortable for the user. Therefore, creating a python script with the ability to write to a network drive seems to be a global Linux security violation, and naturally, you will have to configure access rights and so on.
Python itself is a language that provokes errors (as it was, for example, with the Ada language), it can hardly be considered a uniquely successful decision to write a program to access a network drive in this language. Although this is a programmer's decision. But you definitely have to solve security issues if you want to create a “Linux solution”, and not just a program for yourself =)
It's nice to see that there are more and more active Linux users and novice programmers trying to create their own solutions! I wish you success!
Thank you. I do like this forum. Everyone is so polite.

I wrote my first code as an undergraduate in 1970 and I have been a closet coder ever since but the last time I wrote code as part fo paid employment was in the early 1980s. I recently bought my grandson a Kano laptop which introduced me to the Pi, from there I went on to Pi controlled robots that use Python as as the control language, and from there to using Python more generally. For home use Python is a beautiful language and appears to be being used more and more in professional applications, so I have no problem with my choice of language.

In our household we have several Windows machines, several Macs and a couple of NAS boxes. For the purpose of having an offsite backup I have written a program that will do an incremental backup of all the devices to an external drive connected to one of the Macs. That works well but I thought it would be neat if I could run the program on a Mac but write to an external drive connected to a Pi4 (my equipment is sufficiently old that the USB3 on the Pi4 is the fastest interface I have). My plan now is to run the program on the Pi4 as that will have write access to its own USB drive and will only need read access to the other devices. I am sure somewhere in this forum I can find how to read from a device knowing its IP address, username and password.

You say that my question will not concern many people. I am genuinely curious, I thought my requirement was a fairly simple one that others would have cracked sometime ago. So what sort of things do people use their Pis for if not things like this? That is a genuine question as I am on the lookout for interesting projects in my retirement years.

ejolson
Posts: 5640
Joined: Tue Mar 18, 2014 11:47 am

Re: Writing to an External Drive from the network

Fri Dec 06, 2019 3:12 pm

THobson wrote:
Fri Dec 06, 2019 11:23 am
That works well but I thought it would be neat if I could run the program on a Mac but write to an external drive connected to a Pi4 (my equipment is sufficiently old that the USB3 on the Pi4 is the fastest interface I have).
You are right, mounting a physical drive through the network is easily done, just not common around here. To follow up my post on iSCSI, which should do what you want, here is a link

https://en.m.wikipedia.org/wiki/ISCSI

Try a web search on

mac iscsi initiator

for specific information on settings up the Macintosh as a client.
Last edited by ejolson on Fri Dec 06, 2019 3:21 pm, edited 1 time in total.

renice123
Posts: 237
Joined: Tue Oct 15, 2019 3:56 pm

Re: Writing to an External Drive from the network

Fri Dec 06, 2019 3:20 pm

It seems to me that you are an experienced Linux user, so I am not comfortable giving advice.
And Apple computers are not very popular in our country, that's why I’ve only met with Mac OS all my life a few times (and that’s because I was fond of BeOS). However, here they write that you can configure your Mac to work with NFS https://www.cyberciti.biz/faq/apple-mac ... -tutorial/
I wrote that the “security policy” is important for Linux and that’s why standard solutions (say, using NFS) are preferable to writing your own program from scratch.
Perhaps if you set up NFS sharing on two computers, you can efficiently and quickly organize backups on PRI4
I also use NFS for backup, however, I copy from PRI4 to the "big computer". This allows me not to store important information on PRI4, but to automatically transfer all the data from the PRI4 home directory to the hard disk of the remote computer.
PS I am also a senior citizen and now carried away by sound experiments with Raspberry. I really like this little nimble computer, as if I were in my childhood again =)
They say that Raspberry was conceived as a computer for children, but it seems that adult men experience from Raspberry the youthful joy of learning new things.

ejolson
Posts: 5640
Joined: Tue Mar 18, 2014 11:47 am

Re: Writing to an External Drive from the network

Fri Dec 06, 2019 3:28 pm

renice123 wrote:
Fri Dec 06, 2019 3:20 pm
And Apple computers are not very popular in our country, that's why I’ve only met with Mac OS all my life a few times (and that’s because I was fond of BeOS).
I think the reason the person making the original post wants to mount a block network device rather than NFS is to be able to format the remote disk with an Apple filesystem that supports backups using timemachine. If this is is the case, then iSCSI can make a physical disk on the Pi appear as if it were connected to the Macintosh, for example.

While iSCSI sounds like a complicated solution for sharing logical volumes on a partitioned RAID array in the data center, it is not difficult to set up and can export a single physical drive just as easily.

ejolson
Posts: 5640
Joined: Tue Mar 18, 2014 11:47 am

Re: Writing to an External Drive from the network

Fri Dec 06, 2019 3:41 pm

renice123 wrote:
Fri Dec 06, 2019 3:20 pm
They say that Raspberry was conceived as a computer for children, but it seems that adult men experience from Raspberry the youthful joy of learning new things.
My impression is there are grownups of all genders from many countries who participate on this forum. Some are not native English speakers, and so things can sound a little strange sometimes to someone for whom English was their mother tongue. At the same time, it is nice to hear what many different people do with their Pi computers.

I have also noticed there are relatively few school-aged children on this forum and have remarked how strange it is that
the Pi is for children while the forum appears to be for grownups. I guess it is not so strange, because the children can ask their Pi-related questions in school while the grownups can't. Moreover some of the grownups are actually teachers who need to know the answers to the children's questions.

Return to “Troubleshooting”