10

I've been using my PC to access the files on RPi, using Samba Server on RPi.

But, Is there any way I could open Samba Connections on Pi? Like browsing Windows PC Samba Files on RPi?

  • 1
    ftp would be much faster – rav_kr Jan 12 '16 at 11:51
  • 1
    Yes I know, but It's tedious to install FTP server on all of my Windows PC's – Snazzy Sanoj Jan 12 '16 at 11:53
  • 2
    You want a samba client. I am sure you will find many explanations of such online if you search "linux samba client", although of course some of them will actually be about about using a client to access a share on a linux box rather than the other way around. I believe the CLI utility for this is smbclient. – goldilocks Jan 12 '16 at 11:57
  • @goldilocks Thanks, but Is there any workaround for the default File Manager to open Samba? :) – Snazzy Sanoj Jan 12 '16 at 12:08
  • 1
    The file manager in LXDE (the default desktop environment on Raspbian) is "pacmanfm", so if you search for "pacmanfm samba" you should find a bunch of stuff, e.g., askubuntu.com/q/249678/239729 I suggest for samba-on-linux stuff generally you start on U&L. – goldilocks Jan 13 '16 at 12:51
17

First install some packages:

apt-get install  samba-common smbclient samba-common-bin smbclient  cifs-utils

Then, create a local directory and mount the remote share:

mkdir /mnt/abc
mount -t cifs //server/share /mnt/abc

where server is your windows computer name (dns or netbios) and share is your windows shared directory.

Depending on the access you give to your windows share are the credentials required: if you give your share 'Everyone' read (and write) access nothing else is required, otherwise you must add credentials at mount time:

mount -t cifs //server/share /mnt/abc -o user=user,pass=password,dom=domain

replace with your own credentials.
When finished just dismount the share:

umount /mnt/abc
  • +1 This has worked for a shared USB drive connect to the USB port of a Modem/Router. If you need some more debugging add '--verbose' before the '-o' – Denja Sep 23 '16 at 3:39
  • I have this error with my credentials : Device or resource busy. Refer to the mount.cifs(8) manual page (e.g. man mount.cifs) – Axel Briche Oct 21 '17 at 11:10
3

if the samba share does not need any credentials to login and you want to mount the share when you start your raspberry pi then edit the fstab file as root

sudo nano /etc/fstab

and add the following line

//server/share  /mnt/abc  cifs  guest  0  0

close and save the changes to the fstab file

check that everything connects as it should with

sudo mount -a

if your samba share needs a password then you you can connect use the following in your fstab entry.

//server/share  /mnt/abc cifs username=username,password=password  0  0

its not the best idea to use this method if others have access to your RPi or network as fstab is readable by all and will be able to read your password.

A better solution is to use a credentials file.

nano ~/.smbcredentials

then enter your username and password into the file

username=username
password=password

save the file and change its permissions so it is not readable by others.

chmod 600 ~/.smbcredentials

then edit as root the fstab to add your samba share

//server/share  /mnt/abc cifs credentials=/home/pi/.smbcredentials  0  0

again, test with

sudo mount -a

and if there are no errors then it will mount the share automatically when you reboot.

just to add something I notice a lot on forums when someone asks a reasonable question. why is it people respond with something along the lines of "why do xxxxxx, yyyyy is a better." Thats not what they asked, and its not even helpful.

3

My issue was similar. My target was dd-wrt samba share.

My problem: unable to mount it in anyway (also fstab from RPi3).

I had errors from "not being able to pass the password to reference to mount.cifs" to "invalid argument error 22".

I came across this post, Cannot mount samba share: Mount error (22), and this answer suggests that the solution is to add vers=1.0 to the options on mount.

I hope that helps you.

  • vers=1.0 also solved the problem for me. sudo mount -t cifs //[remote ip address]/downloads /mnt/abc -o vers=1.0,user=[user] – tridy Oct 28 '18 at 15:01
0

If, after trying to auto-mount a share, you somehow run into the scenario where the Pi will no longer boot, drops you in "Emergency Mode" and/or tells you that the root account is locked, you can overcome it by following the instructions located here: Raspberry Pi Boot Issue - Root account locked!.

Summary of the linked steps for the future:

  1. Retrieve your SD card from the Pi and using a adapter mount the card to your PC, Mac or Linux.
  2. You should be able to see the /boot partition of your SD card.
  3. Locate the file cmdline.txt and add the following at the end of the line init=/bin/sh Note: Do not create a new line, just add the above to end of the current line.
  4. Load the SD card back to your Pi and boot up.
  5. You should now get the a root shell prompt. From here you can undo the changes to /etc/fstab or whatever else that initially broke your system.
  6. In some cases you will not be able save your changes and the system will complain of a read only file system. If you get that move to the next step.

A Raspberry Pi SD card will have two main partitions, since we cannot read the partition table directly you must manually locate the device for your root and boot partitions. You can do this by going to the /dev directory and you should see something similar to mmcblk0p1 & mmcblk0p2. The second device mmcblk0p2 will be your root partition. You need to remount this with read write permissions:

mount -o remount,rw /dev/mmcblk0p2 /

This will be most easily accomplished by mounting the SD card on another computer (Mac/Linux/Windows) and editing the cmdline.txt file there.

I had foobarred my environment with a bad fstab entry and following these instructions allowed me to unwind that error.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.