There is a post, link will follow below, from the Raspberry Org site which is very informativ and handles how to connect your external hard disk, SSD, or USB stick to any of the USB ports on the Raspberry Pi(RPi), and "mount" the file system to access the data stored on it.
So there is no need for a rewrite and this post will therefore continue with how to connect to a Windows server, (Other SMB or Samba servers will also work), both temporary and automagically at boot.
Check this post RPi booting from an USB drive !
The link to the Raspberry site with connect information for external hard disk, SSD, or USB is found here!
Just some thoughts
- Before you connect the storage to the USB port on the RPi, check/format the storage with your PC/Mac
- Just after you connected the storage to the USB port on the RPi run the command "dmesg" which will show you information about the device
- If you want to share the USB storage in the network use Samba. Configuration example below.
Server connect
The protocol for connecting to Windows or Samba servers are SMB, CIFS.
In the same manner as you connect an USB storage to your RPi you "mount" a shared folder on a Windows server so it appears on your Raspberry Pi.
Mounting in Linux is the process of attaching a folder to a location, so we start with creating that location/directory on the RPi, logged on with user "pi"
mkdir windowshare
Manually "mount"
With remote server named "S01", in this case a RPi running Samba, with user "pi" and password "raspberry" issue the command
sudo mount.cifs //S01/pi /home/pi/windowshare -o user=pi,password=raspberry
Check the remote server content with
ls windowshare
Please note !! The command will by default use SMB version 1.0 and if your remote server is a Windows server you will probably get an error message.....
mount error(2): No such file or directory
or
mount error(22): Invalid argument
This is due to that the protocol, SMB1, is deprecated in "later" Windows server versions. (Not very informative error message !!) Instead test with SMB version 2.0 or higher. The command will then be
sudo mount.cifs //S01/pi /home/pi/windowshare -o vers=2.0,user=pi,password=raspberry
where you substitute "//S01/pi" with the path to the Windows server shared folder
"mount" at boot
If the manually "mount" went OK then we will go on with "umount"
sudo umount /home/pi/windowshare
which will disconnect the remote server.
To "mount" the remote server at boot you have to edit the file "fstab" with
sudo nano /etc/fstab
and add, at the end
//S01/pi /home/pi/windowshare cifs vers=2.0,user=pi,password=raspberry,x-systemd.automount 0 0
To test, without reboot, issue the command
sudo mount -a
and check with
ls windowshare
If OK do the reboot and check again. Please note that if the remote server goes down the RPi will automagically try to connect again.
Security
If you don't want to expose the credentials in "fstab" you can "hide" them in a file, with
nano .smbcredentials
and add
user=pi
password=raspberry
and then change the record in "fstab" to
//S01/pi /home/pi/windowshare cifs vers=2.0,credentials=/home/pi/.smbcredentials,x-systemd.automount 0 0
To make it even more "secret" you can change owner/group with
sudo chown root:root .smbcredentials
Remarks
This post on the Raspberry Org site can give additional info and these posts gave inspiration
to the solution
Samba config
Check the USB storage with "sudo blkid", mount with "sudo mount /dev/sda1 /media/extdisk" to the created directory "sudo mkdir /media/extdisk" and then add the following config to "smb.conf"
[Extdisk]
comment = External disk
read only = no
locking = no
path = /media/extdisk
guest ok = no
Automatic mounting are descibed here.
No comments:
Post a Comment
Feel free to leave a comment ! ... but due to a lot of spam comments I have to moderate them. Will reply ASAP !