[root tip] [How To] SAMBA fileserver over WiFi using Raspberry Pi

Difficulty: ★★★★☆

Wireless Raspberry Pi file server

Source: ARM wireless Samba file service based on Arch | root.nix.dk

Goal

The exercise is to share different content for different audiences.

The bar is set high as the installation and configuration is done from scratch using a SSH terminal session to the target system.

It will also require understanding of the Access Control List in a GNU/Linux system as well as networking concepts.

The final setup will provide the following features

Users and groups

  • user:admin group:admin home:admin
  • user:hans group:users,office (no-shell, no-home)
  • user:grete group:users,admin (no-shell, no-home)

Shares

  • public share
    • authenticated users can edit files
    • guests can read files
  • document share
    • stored on local root partition accessible to authenticated users
    • files may be edited by users belonging to the admin group
    • office users can only read the documents
  • music library (administrated by the dedicated admin)
    • stored on external partition - in this case an USB stick

Prerequisite

  • Reference Arch Wiki on Samba
  • Manjaro workstation
  • The following packages micro, rpi-imager, smb-client, gvfs and gvfs-smb
  • A cardreader to be able to write the image to a micro sd-card
  • Raspberry Pi 4
  • Micro sd-card

Do a full system sync adding the packages to your workstation (remember to reboot if your kernel is updated)

sudo pacman -Syu rpi-imager micro smb-client gvfs gvfs-smb --needed

Plug your sd-card in the card reader attached to your Manjaro workstation

The RPI imager is simple to use. Upon selection of source and storage the app downloads the image, writes to sd-card and verifies the image - ready to use.

Just launch the app - navigate to locate the Manjaro ARM minimal and write it to your sd-card.

Create the wifi-hack.sh script and use it to configure your PI’s WiFi.

The script takes 6 arguments <blockdev> <ssid> <passphrase> <cidr> <gateway> <dns>.

The following is an example - amend the arguments for your use case

sudo hack-wifi.sh /dev/mmcblk0 my-ssid 192.168.1.90/24 192.168.1.1 192.168.1.1

Move the sdcard to your pi and power up. Wait for the device to settle - the green activity led becomes quiet - more important - allow the device to connect to your wifi.

We will switch back and forth and forth between ssh and workstation - and we will be referencing the pi’s smb service quite a lot.

So to avoid having to type the IP address repeatedly we will create an alias for the configured IP and append to your workstation’s hosts file.

For this writeup I have chosen rpi

echo "192.168.1.90 rpi" | sudo tee -a /etc/hosts

Connect to the pi using the either the address or the alias

ssh root@rpi

The oem installer script will prompt you for a hostname - be smart and use the alias you just created.

After completion of the script the device reboot.

Continue your quest to conquer Samba mysteries with [root tip] [How To] Samba Server From Scratch

1 Like

:no_entry_sign: This is not a support thread - so don’t ask questions.

:ok: If you spot an error - please do comment so the error can be fixed.