dr_xemacs
Posts: 15
Joined: Mon Jan 25, 2016 8:46 am

Lan file/HD server

Mon May 20, 2019 11:50 am

Hi everybody.

So I have a little quandry. As shown below is the layout I thought would be suitable for a "home cloud" - and particularly to be able to backup and synchronize iPhone and Macbook. I installed Samba on my Raspberry, and so far it's fine. It shows up in every computer connected to the network, but I can't see any hard drives connected to it. It is configurated to show the /share folder I know, and I have tried to symlink the hard drives into the /share folder, but nothing appears. Am I doing this wrong or am I missing something?

All best! Lasse

Image

Andyroo
Posts: 4140
Joined: Sat Jun 16, 2018 12:49 am
Location: Lincs U.K.

Re: Lan file/HD server

Mon May 20, 2019 12:40 pm

You have to mount the hard drives onto the Pi using systemd or fstab
Once that has been done you have to set the share up in SAMBA by manually editing the config file
Then you have to set up a user (assuming that you are using the default security in Samba)
Finally you have to restart the Samba services to reread the configuration

If you are stuck on any bit, just add a note here.

Out of interest what are you syncing between iOS and the Mac as iCloud or iTunes do it all...

Backups of the iOS devices will be picked up by Time Machine but if you are using a Samba share as destination then you will need to follow https://kirb.me/2018/03/24/using-samba- ... erver.html unless the modules are now merged in Samba (do not know as my Synology does TM backups).
Need Pi spray - these things are breeding in my house...

LTolledo
Posts: 1761
Joined: Sat Mar 17, 2018 7:29 am
Location: Anime Heartland

Re: Lan file/HD server

Mon May 20, 2019 1:00 pm

to add....

If the HDDs are bus powered the USB hub has to be self powered

or

If the USB hub is bus powered, all the HDDs have to be self powered.

to check if the HDDs are detected (even if you have not mounted yet)
enter

Code: Select all

 lsblk
if all 4 showed up (as sdb, sdc, sdd,.... etc) then you can successfully mount those in /etc/fstab

once mounted, you can share those via samba
"Don't come to me with 'issues' for I don't know how to deal with those
Come to me with 'problems' and I'll help you find solutions"

Some people be like:
"Help me! Am drowning! But dont you dare touch me nor come near me!"

User avatar
thagrol
Posts: 1777
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: Lan file/HD server

Tue May 21, 2019 12:48 pm

Your diagram shows four HDD with indications of wanting/having more.

A couple of things to be aware of:
  • Eveything (all HDD, ethernet, keyboard, mosue, etc) on the Pi hangs off one USB port. The more you add and the more you have going on at the same time the less bandwidth each device will have.
  • There's an upper limit to the number of HDD you can have connected that's way lower than the theoretical limit of USB. I think it's in the region of 5 but I'm not sure, nor am l I sure whether it has recently been fixed. Thing break if you go over that limit.
This space unintentionally left blank.

dr_xemacs
Posts: 15
Joined: Mon Jan 25, 2016 8:46 am

Re: Lan file/HD server

Thu May 23, 2019 2:29 pm

Andyroo wrote:
Mon May 20, 2019 12:40 pm
You have to mount the hard drives onto the Pi using systemd or fstab
How do I mount a disk already mounted in readonly mode in another place ( = /media/pi/diskinquestion)?
fstab issues are rocket science for me.
Andyroo wrote:
Mon May 20, 2019 12:40 pm
Once that has been done you have to set the share up in SAMBA by manually editing the config file
I was told to add one section beginning with [share] which I did. It now reflects that folder (i.e. /share) - but can I add another section like it with another name (eg. [bkupdisk1]) as well, or is [share] reserved in any way?
Andyroo wrote:
Mon May 20, 2019 12:40 pm
Out of interest what are you syncing between iOS and the Mac as iCloud or iTunes do it all...
I dont want to pay for icloud storage - I want it locally at home.
Andyroo wrote:
Mon May 20, 2019 12:40 pm
Backups of the iOS devices will be picked up by Time Machine but if you are using a Samba share as destination then you will need to follow https://kirb.me/2018/03/24/using-samba- ... erver.html unless the modules are now merged in Samba (do not know as my Synology does TM backups).
Following the link above this didn't work at all! I ran into a lot of thoubles beginning with the line "sudo apt build-dep samba". The configure script then required some miscellaneous software which I installed, but in vain since the script keep asking for it.

This seems to be my fate whenever I try to install or build something on a Linux machine - there are always loads of dependency errors that keep dragging me down. In the end I give up because it is impossible to overcome and so I give up.

Please help!

All best. Lasse

PhatFil
Posts: 1341
Joined: Thu Apr 13, 2017 3:55 pm
Location: Oxford UK

Re: Lan file/HD server

Thu May 23, 2019 3:50 pm

You could look at OMV Open media Vault for the pi if its dedicated to NAS duties?
https://sourceforge.net/projects/openme ... %20images/
https://thepi.io/how-to-use-your-raspbe ... a-nas-box/
Its got a web interface thats intuitive if a bit clunky..

re hdd limits with the pi 3B I managed to connect 6x hdds with independent psu's via a 10 port usb hub (+5v cut on the pi-usb connection to avoid back powering from hub and disks) attempts to add more failed with a random 6x disks being accessible.

LTolledo
Posts: 1761
Joined: Sat Mar 17, 2018 7:29 am
Location: Anime Heartland

Re: Lan file/HD server

Thu May 23, 2019 9:39 pm

PhatFil wrote:
Thu May 23, 2019 3:50 pm

re hdd limits with the pi 3B I managed to connect 6x hdds with independent psu's via a 10 port usb hub (+5v cut on the pi-usb connection to avoid back powering from hub and disks) attempts to add more failed with a random 6x disks being accessible.
I can confirm this when I test connect my RPi3B+ to my self powered HDD clusters....only max 6 random HDDs out of 10 can be accessed.
this is a hardware limitation as pointed before by jamesh
"Don't come to me with 'issues' for I don't know how to deal with those
Come to me with 'problems' and I'll help you find solutions"

Some people be like:
"Help me! Am drowning! But dont you dare touch me nor come near me!"

dr_xemacs
Posts: 15
Joined: Mon Jan 25, 2016 8:46 am

Re: Lan file/HD server

Fri May 24, 2019 4:00 pm

PhatFil wrote:
Thu May 23, 2019 3:50 pm
You could look at OMV Open media Vault for the pi if its dedicated to NAS duties?
Thanx a lot for this contribution! This looks a little more like what I want. Alas it seems I´ll be having to buy some new Raspberries. I have some hard disks that I really want to have running on my network. Luckily they aren´t that expensive.
PhatFil wrote:
Thu May 23, 2019 3:50 pm
re hdd limits with the pi 3B I managed to connect 6x hdds with independent psu's via a 10 port usb hub (+5v cut on the pi-usb connection to avoid back powering from hub and disks) attempts to add more failed with a random 6x disks being accessible.
This seems to be the bottleneck that anyway forces me to acquire some more Raspberries.

Thanx again!

PhatFil
Posts: 1341
Joined: Thu Apr 13, 2017 3:55 pm
Location: Oxford UK

Re: Lan file/HD server

Fri May 24, 2019 6:38 pm

You may not need to if you have older (cheaper) usb hdd enclosures designed for 3.5" drives these will generally require
a dc power supply to power the disk and controller..

Using these style hdd enclosurs, mounting via uuids, and 'smart switches' to control their power you can turn on/off and mount disks as needed using node red and mqtt hosted on your pi very easily.

so you can select to mount disks on demand, how often would you need concurrent access to more than 6x hdds ??

dr_xemacs
Posts: 15
Joined: Mon Jan 25, 2016 8:46 am

Re: Lan file/HD server

Fri Jun 07, 2019 9:32 pm

Hi again!

A little update! ...or upgrade rather... I purchased a raspi III - which automatically connected two of my drives to /media/pi/

Now i just need help to properly make changes to the config file. So back to one of my original questions: do I add one section per new disk I want to add to my network named after the disk, or is the header name [share] reserved - thus restricting my number of network resources to one, namely ”share”?

Best, Lasse

User avatar
thagrol
Posts: 1777
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: Lan file/HD server

Sat Jun 08, 2019 6:36 am

The header name doesn't have to be [share] it can be [anything]. Well baring any existing share definitions and those used internally by samba.

I'd add one section per drive though you could have just one section sharing the directory above the mount points but you'll see incorrect free/used space reported by the clients.

If your drives are mounted at /foo/bar and /foo/baz, I'd add something like this:

Code: Select all

[bar]
path = /foo/bar
...

[baz]
path = /foo/baz
...
This space unintentionally left blank.

LTolledo
Posts: 1761
Joined: Sat Mar 17, 2018 7:29 am
Location: Anime Heartland

Re: Lan file/HD server

Sat Jun 08, 2019 7:54 am

On one of my RPi NAS setups I have 2 HDDs connected

a 2TB HDD mounted in fstab but sharing 2 (of the 4 ) directories via samba
and another 1 TB HDD mounted and fstab, but sharing 1 directory (inside another directory) in samba

I've posted the image of that build, somewhere in the forum.....
(if you like I can post the image here....)
"Don't come to me with 'issues' for I don't know how to deal with those
Come to me with 'problems' and I'll help you find solutions"

Some people be like:
"Help me! Am drowning! But dont you dare touch me nor come near me!"

dr_xemacs
Posts: 15
Joined: Mon Jan 25, 2016 8:46 am

Re: Lan file/HD server

Mon Jun 17, 2019 9:52 am

Andyroo wrote:
Mon May 20, 2019 12:40 pm
You have to mount the hard drives onto the Pi using systemd or fstab
Done automatically by the raspi
Andyroo wrote:
Mon May 20, 2019 12:40 pm
Once that has been done you have to set the share up in SAMBA by manually editing the config file
Done
Andyroo wrote:
Mon May 20, 2019 12:40 pm
Then you have to set up a user (assuming that you are using the default security in Samba)
Done
Andyroo wrote:
Mon May 20, 2019 12:40 pm
Finally you have to restart the Samba services to reread the configuration

If you are stuck on any bit, just add a note here.
Yeah! so now I've added two hard disks automatically mounted by my raspi on /media/pi/disk1 and disk2
But only one seems to appear when I search for it - and under the wrong name.

I have tried to start my mac over, the sambaserver over, the raspi over, reconnecting, but nothing results in showing the correct map of my units. One of them appear under an old name (after my fiddling around) How can I get the samba server to report the correct items under correct names when "/etc/init.d/samba restart" doesn't do the trick?

/Lasse.

hortimech
Posts: 310
Joined: Wed Apr 08, 2015 5:52 pm

Re: Lan file/HD server

Mon Jun 17, 2019 10:48 am

Can you post your smb.conf file, but before you do, remove all lines that have a '#' or ';' as the first character

User avatar
thagrol
Posts: 1777
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: Lan file/HD server

Mon Jun 17, 2019 11:43 am

Drives appearing under the wrong names could be a mount related issue. Post you fstab too please.
This space unintentionally left blank.

dr_xemacs
Posts: 15
Joined: Mon Jan 25, 2016 8:46 am

Re: Lan file/HD server

Mon Jun 17, 2019 2:35 pm

hortimech wrote:
Mon Jun 17, 2019 10:48 am
Can you post your smb.conf file, but before you do, remove all lines that have a '#' or ';' as the first character
...
Drives appearing under the wrong names could be a mount related issue. Post you fstab too please.
Hi. Sure will. Following below. One note first! Strange errors occur when omitting one single bracket, as shown below in the line "Bilddisk_2]" where the "[" misses. Adding that solved the whole problem.

May I ask a question even if its out of scope here... the resources I now have made available in my network I'd like to make them connected to my computer the very instant my computer signs into my LAN. Is that achievable somehow? (Have a Macbok Pro) These resources serve as image disks to my Lightroom app, and I really like to omit the connecting procedure I otherwise have to go through each time I sign on at home.

smb.conf:

Code: Select all

[global]
   workgroup = WORKGROUP
   dns proxy = no
   log file = /var/log/samba/log.%m
   max log size = 1000

   syslog = 0
   panic action = /usr/share/samba/panic-action %d
   server role = standalone server
   passdb backend = tdbsam
   obey pam restrictions = yes
   unix password sync = yes
   passwd program = /usr/bin/passwd %u
   passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .
   pam password change = yes
   map to guest = bad user
  usershare allow guests = yes

[homes]
   comment = Home Directories
   browseable = no
   read only = yes
   create mask = 0700
   directory mask = 0700
   valid users = %S

[printers]
   comment = All Printers
   browseable = no
   path = /var/spool/samba
   printable = yes
   guest ok = no
   read only = yes
   create mask = 0700

[print$]
   comment = Printer Drivers
   path = /var/lib/samba/printers
   browseable = yes
   read only = yes
   guest ok = no

[Bilddisk_1]
Comment = Image Disk 1
Path = /media/pi/DISK1
Browseable = yes
Writeable = Yes
only guest = no
create mask = 0777
directory mask = 0777
Public = yes
Guest ok = yes

Bilddisk_2]
Comment = Image Disk 2
Path = /media/pi/DISK2
Browseable = yes
Writeable = Yes
only guest = no
create mask = 0777
directory mask = 0777
Public = yes
Guest ok = yes
fstab:

Code: Select all

PARTUUID=5b901c2d-01  /boot           vfat    defaults          0       2
PARTUUID=5b901c2d-02  /               ext4    defaults,noatime  0       1
# a swapfile is not a swap partition, no line here
#   use  dphys-swapfile swap[on|off]  for that
//192.168.1.151/backup /mnt/bildbackup cifs _netdev,auto,user=pi,guest,rw,vers=1.0,file_mode=0777,dir_mode=0777,uid=pi,gid=pi,forceuid,forcegid 0 3
//192.168.1.152/media /mnt/nas cifs _netdev,auto,user=pi,guest,rw,vers=1.0,file_mode=0777,dir_mode=0777,uid=pi,gid=pi,forceuid,forcegid 0 3
Note that Raspberry automatically mounts new devices like hard disks, so I haven´t mounted them in the fstab.

/Lasse

hortimech
Posts: 310
Joined: Wed Apr 08, 2015 5:52 pm

Re: Lan file/HD server

Mon Jun 17, 2019 3:56 pm

Yes, that would do it, Samba requires both the opening and closing square brackets.

If you are connecting from Mac, try reading this:
https://wiki.samba.org/index.php/Config ... h_Mac_OS_X

You should be able to get your Mac to automount your rpi Samba shares.

User avatar
thagrol
Posts: 1777
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: Lan file/HD server

Mon Jun 17, 2019 6:15 pm

dr_xemacs wrote:
Mon Jun 17, 2019 2:35 pm
Note that Raspberry automatically mounts new devices like hard disks, so I haven´t mounted them in the fstab.
For a server, that's not ideal.

Are you, as I suspect, running the desktop rather than booting your Pi into the command line? If so, consider the following:
  • Using the desktop's auto mounter you have little to no control over where the disc gets mounted, with what options, and with what permissions.
  • The samba server is started before the desktop so your clients may initially see empty shares. These may be writeable but anthing written to them will be hidden once the disc is mounted.
  • Discs will only be mounted once the desktoip is running and the pi user has logged in.
  • If a different use logs in to the desktop discs will be mounted somewhere else.
  • Discs may be unmounted when the pi user logs out of the desktop
  • I'm not sure about how the desktop's automounter works (I don't use it, all my Pi are headless) but you may see drives on the wrong mount point if they come online in a different order. Device nodes (/dev/sd*) depened on the order in which USB drives are detected. Equally, I've no idea how it handles partitions with the same labels.
I strongly advise switching to fstab to mount your shared drives. And mounting by UUID or PARTUUID rather than device node.

Do something like this:
gksudo

Code: Select all

UUID=<UUID of partition>	/media/pi/DISK1	auto	defaults,nofail	0	0
UUID=<UUID of partition>	/media/pi/DISK2	auto	defaults,nofail	0	0
You'll need to adjust the mount options to get the ownership and permission you want (for local and remote users). I can't give more direct help withouit knowing what filesystems are in use on your discs and what ownership and permissions you want. The default ownership and permissions probably aren't what you want.

You can get the UUID by running

Code: Select all

blkid
Do not omit "nofail" from the mount options. Doing so will cause problems if you ever try to boot the pi without the disc connected.
This space unintentionally left blank.

LTolledo
Posts: 1761
Joined: Sat Mar 17, 2018 7:29 am
Location: Anime Heartland

Re: Lan file/HD server

Tue Jun 18, 2019 9:49 am

I've just rebuilt my RPiNAS to use (currently) a 4TB Seagate HDD (before it was 2TB and 1TB)
also before it was using the desktop version of Raspbian, now its sporting Lite.
thagrol wrote: Are you, as I suspect, running the desktop rather than booting your Pi into the command line?

I noticed this when I changed to Lite, cant find my 4TB HDD. I thought it was damaged. Even after initializing and formatting it was no show.
Then I remembered that I need to mount it via fstab. And sure enough it mounted properly upon reboot.

Also, with the Lite version, the shares are available much faster than when it was shared using the desktop version. Boot and Reboot are faster as well.
thagrol wrote: I strongly advise switching to fstab to mount your shared drives. And mounting by UUID or PARTUUID rather than device node.

I second this!
thagrol wrote: Do not omit "nofail" from the mount options. Doing so will cause problems if you ever try to boot the pi without the disc connected.

To fix this you will need to edit the fstab on another PC or Raspberry Pi (or other SBC) running Linux, as those are the ones capable of accessing the fstab in the rootfs in your boot drive


Also I've been doing some "timed mirroring" (using rsync and cron) of 2 drives mounted and shared by 2 different SBCs, before porting it to my RPiNAS that needs to mirror my main RAID1 NAS.

So far the testing is going well....

UPDATE:
just ported the commands to the RPiNAS and its working perfectly.
now my RPiNAS is timed to mirror my RAID1 NAS every midnight....
"Don't come to me with 'issues' for I don't know how to deal with those
Come to me with 'problems' and I'll help you find solutions"

Some people be like:
"Help me! Am drowning! But dont you dare touch me nor come near me!"

Return to “Advanced users”