Pi Cloud

Pi Cloud : Samba

The final step is setting up your storage and sharing it.

Setting up your drive

First, let’s make sure we have the widest filesystem support possible. We’ll be installing support for NTFS, exFAT, and HFS+:

You’ll need to locate your drive. Plug it in, open your Pi console, then run:

Under there, you should see mmcblk0 (your Pi’s microSD card), and sda (your USB drive). You might see several partitions; remember the one with the largest entry in the SIZE column (in my case, sda2).

Note: if you’ve plugged in multipl hard drives, you’ll have multiple sd# entries. If you’re planning on sharing them all, you’ll need to repeat this for each one. Alternately, you could go crazy and set up software RAID with mdadm, but that’s way outside the scope of this document.

Anywhere I write sda2, substitute in your drive’s name:

Next, you may need to format your drive. If your disk is already formatted, skip this. So you can use your drive elsewhere, we’re going to go with exFAT.

Next, we’ll need some parameters:

Make a note of PARTUUID and TYPE, then create a directory in the root filesystem for the drive. We’ll use the drive’s label, but you can name it whatever you want. This will be the mount path

Finally, make an entry in /etc/fstab for the drive, so that it’s always mounted on-boot and by root. The entry is of this format:

PARTUUID={PARTUUID from above} {mount path} {TYPE} [options] [dump] [passno]

For options, we’ll use: defaults,nofail,noatime,rw,users,user_id=0,group_id=0,default_permissions,allow_other,umask=000. These will mount the drive as root, and allow any user to make changes to the drive (important for Samba to work with little fuss; it’s not great for a multi-user or public system, but you’re configuring your Pi as a private server with one user, pi).

We never want to dump, so that’s 0, and we want the drive scanned on the last boot-time pass, or 2.

Note: if TYPE is ntfs, you’ll want to use ntfs-3g instead.

So, the line we’re adding to /etc/fstab should look something like:

Samba

Install Samba

Edit Samba’s config

Each time you tweak /etc/samba/smb.conf, you’ll need to restart Samba:

If you’ve messed with netbios name or workgroup, you’ll also need to restart NMB:

Adding new Samba users / groups

If you need to provide password-protected access for multiple users on your shares, you can create new users and groups.

To create a user:

To create a group (which can be referenced in smb.conf with a leading @):

To add a user to a group:

To delete a user

Finally, to change a user’s SMB password,

See the headings above for how to set up a user- or group-resticted share.

WSDD

You’ll find that Windows 10 computers can’t see your Raspberry Pi, either locally or through the VPN. This is because Windows 10 no longer supports the NMB protocol for security reasons. To fix it, we have to install and configure wsdd:

Now configure it to match your Samba config. The following lines create an /etc/wsdd.conf that exactly matches your SMB config.

Validate

Local access

Go to another machine on your local network, and look in its network places. For Windows, this is near the bottom on Explorer’s left sidebar; for OS-X, it will be in the left sidebar under “Locations”. It varies on Linux, but I’m already kinda talking down to Linux users; you know where it is.

You should see a computer in your network places corresponding to the hostname you chose. If you double-click it, you should see the shares you configured. Drill down deeper, and you’ll get the files on those shares.

Remote access

With a phone or tablet, turn off WiFi and activate your VPN. Install VLC Media Player (it has good SMB browsing support), and tap “Browse” on the bottom tab bar (looks like a folder). In the “Local Network” section, you should see your Pi appear. Make sure you can browse in, and, for funsies, put a movie file on your Pi so you can try playing it through your VPN.

Conclusion

If you’re here, and everything’s good, that’s about the last of it. You should now have a working Cloud server you can access from anywhere!

If you’re here and everything’s not working, please file an issue, and I’ll be happy to help you debug the problem.