# Sharing files between two RPi devices on the same network

**URL:** <https://discourse.nodered.org/t/sharing-files-between-two-rpi-devices-on-the-same-network/75684>\
**Category:** Share Your Projects\
**Created:** [24 February 2023 12:37 UTC](https://discourse.nodered.org/t/sharing-files-between-two-rpi-devices-on-the-same-network/75684 "2023-02-24T12:37:19Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)\
**Post date:** [24 February 2023 12:37 UTC](https://discourse.nodered.org/t/sharing-files-between-two-rpi-devices-on-the-same-network/75684/1 "2023-02-24T12:37:19Z")

</div>

A couple of my students have been using the 'pdfmake' node to create a PDF version of a text-based newsletter. Another student has been using the Telegram node to send messages and photos to a mobile phone. I suggested to them... _"why don't you combine what you have done?"_  
_"How about sending the PDF to your colleague who could published it to one or more mobile phones?"_  
They jumped at this idea, especially when I said you could just FTP the file from one Pi to the other.

When we were doing a review session this week I ( **foolishly** ) said... _"you know you could have done a file-share between the two devices"_. Their reaction was... _"tell us more"._

So this coming week I'll be explaining the 'mount' command to them.

I've quickly written a step-by-step tutorial on how to do that for them.

If you would like to, you can preview the material here (via this link)...  
[http://resources-area.co.uk/node-red-flows/sharing\_files.pdf](http://resources-area.co.uk/node-red-flows/sharing_files.pdf)

**EDIT:** This tutorial was written for my IoT students in their school environment where 'pi' is the user.  
As @zenofmud has pointed out to me.. “If either of the Pi’s user names is not ‘pi’ make sure to change it in the various commands within the Tutorial otherwise things won't work.”

---

<div class="post-metadata">

**Author:** ![Buckskin](https://avatars.discourse-cdn.com/v4/letter/b/b9e5f3/32.png) [@Buckskin](https://discourse.nodered.org/u/Buckskin)\
**Post date:** [24 February 2023 23:27 UTC](https://discourse.nodered.org/t/sharing-files-between-two-rpi-devices-on-the-same-network/75684/2 "2023-02-24T23:27:42Z")

</div>

Hi Dave  
`nfs’ defines the type of filing syste, to be used` should be `nfs’ defines the type of filing system, to be used`

As to the technical aspects, I am going to give it a go.

---

<div class="post-metadata">

**Author:** ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)\
**Post date:** [25 February 2023 08:48 UTC](https://discourse.nodered.org/t/sharing-files-between-two-rpi-devices-on-the-same-network/75684/3 "2023-02-25T08:48:06Z")

</div>

Thanks Jeff for spotting the 'typo' (which has now been corrected on the website).

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [25 February 2023 09:18 UTC](https://discourse.nodered.org/t/sharing-files-between-two-rpi-devices-on-the-same-network/75684/4 "2023-02-25T09:18:42Z")

</div>

Dave, did you consider using MQTT or http for file transfer? Would make a good project for your students.

---

<div class="post-metadata">

**Author:** ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)\
**Post date:** [25 February 2023 09:33 UTC](https://discourse.nodered.org/t/sharing-files-between-two-rpi-devices-on-the-same-network/75684/5 "2023-02-25T09:33:27Z")

</div>

Hi Steve,  
A number of the students already use MQTT for their projects. The students I referred to above did initially use MQTT to transfer the PDF from one Pi to another. They then used one of my FTP Python scripts to perform the same task.

It will be interesting to see and hear their reaction to the file sharing method.

---

<div class="post-metadata">

**Author:** ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)\
**Post date:** [25 February 2023 09:55 UTC](https://discourse.nodered.org/t/sharing-files-between-two-rpi-devices-on-the-same-network/75684/6 "2023-02-25T09:55:13Z")

</div>

One thing I've noticed is... if I perform a... `cd /home/pi/my_mount` and then a` ls` command in a Terminal window on the client machine, I don't see any files - **which is expected.**

If I then mount the filing system and do another` ls` command, **I don't see any files - not expected.**

In order to see the files I have to` cd` to another place and come back again.  
e.g. `cd /home/pi/my_mount` and do` ls` again - **whereupon I do see the files**.  
I could have done... `cd ../my_mount` and then` ls` to achieve the same result.

Is this normal behaviour when doing a remote mount?  
Alternatively, it might be something peculiar on my home network/system.

---

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [25 February 2023 10:09 UTC](https://discourse.nodered.org/t/sharing-files-between-two-rpi-devices-on-the-same-network/75684/7 "2023-02-25T10:09:15Z")

</div>

David,  
Perhaps you should also tell them that file based transfer data between systems is not always the best solution in real life. In my daily job we are dealing with "lots" of data, some of which is transferred via files. But that gives a lot of headache issues, e.g. monitoring/querying/load distribution/... All kind of troubles that we have solved by communication via Kafka. But of course in other use cases file transfer will be better.

Just to make sure they learn to realize that they cannot use this for every application they come across later on in their jobs. By thinking about this in advance, they can avoid a lot of problems.

Of course fun is the most important factor in your classes I assume, so don't let me spoil that 😉

Bart

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [25 February 2023 10:22 UTC](https://discourse.nodered.org/t/sharing-files-between-two-rpi-devices-on-the-same-network/75684/8 "2023-02-25T10:22:23Z")

</div>

> [@dynamicdave](#):
>
> Is this normal behaviour when doing a remote mount?

It is normal behaviour when doing any mount, remote or local. Think of the directory entry `pi_mount` as being a road junction. In the unmounted case if you drive down the road from `home` through the junction into `my_mount` and look around (`ls`) you find nothing there. Then the mount operation is performed. This effectively closes the entry from the junction into the road where you are and instead opens a diversion off to the other machine. However, since you are still on the original road there is still nothing there. Drive back up the road past the junction (luckily it is only blocked off in one direction, you can still get out of it) and then drive down the road again and you are directed off to the remote folder.

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [25 February 2023 10:37 UTC](https://discourse.nodered.org/t/sharing-files-between-two-rpi-devices-on-the-same-network/75684/9 "2023-02-25T10:37:37Z")

</div>

Have you considered also showing them file sharing using sshfs ?  
It's a simpler process but it does rely on knowing a user password on the remote machine, so not ideal for accessing someone else's Pi, good for two pies that you own.

```auto
pi@MyPi:~ $ sudo apt install sshfs
...

pi@MyPi:~ $ mkdir myotherpi
pi@MyPi:~ $ sshfs pi@192.168.1.12:/home/pi myotherpi
pi@192.168.1.12's password:

pi@MyPi:~ $ cat myotherpi/hello
Hi there!
This file is on 192.168.1.12

pi@MyPi:~ $ sudo umount myotherpi

```

Sorry about the red highlighting, not sure where that comes from

---

<div class="post-metadata">

**Author:** ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)\
**Post date:** [25 February 2023 11:07 UTC](https://discourse.nodered.org/t/sharing-files-between-two-rpi-devices-on-the-same-network/75684/10 "2023-02-25T11:07:33Z")

</div>

Thanks Colin for the detailed explanation. It makes complete sense to me now.  
I think I'll put a paragraph in the Tutorial in case other people get tripped-up on this "effect" like I did.

---

<div class="post-metadata">

**Author:** ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)\
**Post date:** [25 February 2023 11:10 UTC](https://discourse.nodered.org/t/sharing-files-between-two-rpi-devices-on-the-same-network/75684/11 "2023-02-25T11:10:36Z")

</div>

Hi Bart,  
Thanks for your wise-words of wisdom/experience. I will certainly pass on the information to them.

---

<div class="post-metadata">

**Author:** ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)\
**Post date:** [25 February 2023 11:13 UTC](https://discourse.nodered.org/t/sharing-files-between-two-rpi-devices-on-the-same-network/75684/12 "2023-02-25T11:13:16Z")

</div>

Thanks for the information about 'sshfs' - my IoT students will be spolit for choice now.

---

<div class="post-metadata">

**Author:** ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)\
**Post date:** [25 February 2023 18:44 UTC](https://discourse.nodered.org/t/sharing-files-between-two-rpi-devices-on-the-same-network/75684/14 "2023-02-25T18:44:57Z")

</div>

I had problems with `fstab` being executed during the boot process before the network stack is up and operational, which resulted in not 'seeing' the files in the exported area.

After doing some Goggling I edited my 'fstab' file to include these extra options (and it now works fine)...

`192.168.1.152:/home/pi/pdf /home/pi/my_mount nfs defaults,noauto,x-systemd.automount 0 0`

---

<div class="post-metadata">

**Author:** ![Buckskin](https://avatars.discourse-cdn.com/v4/letter/b/b9e5f3/32.png) [@Buckskin](https://discourse.nodered.org/u/Buckskin)\
**Post date:** [25 February 2023 20:44 UTC](https://discourse.nodered.org/t/sharing-files-between-two-rpi-devices-on-the-same-network/75684/15 "2023-02-25T20:44:14Z")

</div>

> [@dynamicdave](#):
>
> 192.168.1.152:/home/pi/pdf /home/pi/my\_mount nfs defaults,noauto,x-systemd.automount 0 0

Not in the tutorial yet 😉

---

<div class="post-metadata">

**Author:** ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)\
**Post date:** [25 February 2023 21:48 UTC](https://discourse.nodered.org/t/sharing-files-between-two-rpi-devices-on-the-same-network/75684/16 "2023-02-25T21:48:47Z")

</div>

Well it is now. Sorry for the delay - it's my Saturday night (here in the UK) with the family.

Note: You might need to refresh your browser's cache to "see" the latest version.

---

<div class="post-metadata">

**Author:** ![manglemender](https://avatars.discourse-cdn.com/v4/letter/m/45deac/32.png) [@manglemender](https://discourse.nodered.org/u/manglemender)\
**Post date:** [28 February 2023 13:22 UTC](https://discourse.nodered.org/t/sharing-files-between-two-rpi-devices-on-the-same-network/75684/17 "2023-02-28T13:22:41Z")

</div>

Just a thought and maybe this is outside the scope of your lesson but have you considdered sending the file by MQTT? In that way, many devices could subscibe to the topic and recieve the updated file all over the world.

Nick

---

<div class="post-metadata">

**Author:** ![dynamicdave](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dynamicdave/32/96_2.png) [@dynamicdave](https://discourse.nodered.org/u/dynamicdave)\
**Post date:** [28 February 2023 13:55 UTC](https://discourse.nodered.org/t/sharing-files-between-two-rpi-devices-on-the-same-network/75684/18 "2023-02-28T13:55:13Z")

</div>

Yes they have - see post #4 above.

> [@Sharing files between two RPi devices on the same network](https://discourse.nodered.org/t/sharing-files-between-two-rpi-devices-on-the-same-network/75684/4):
>
> Dave, did you consider using MQTT or http for file transfer? Would make a good project for your students.

---

<div class="post-metadata">

**Author:** ![manglemender](https://avatars.discourse-cdn.com/v4/letter/m/45deac/32.png) [@manglemender](https://discourse.nodered.org/u/manglemender)\
**Post date:** [28 February 2023 14:17 UTC](https://discourse.nodered.org/t/sharing-files-between-two-rpi-devices-on-the-same-network/75684/19 "2023-02-28T14:17:47Z")

</div>

Ahh, sorry. I missed that.
