omarchy-config/smb-setup.md
2026-07-17 20:02:49 +02:00

284 lines
3.6 KiB
Markdown

# SVR52 Samba Client Setup (Omarchy / Arch Linux)
## Purpose
This document describes the complete client-side configuration for automatically connecting to the Samba share hosted on **svr52** (a Raspberry Pi server) from another Linux machine running Omarchy/Arch.
The server is accessed primarily over **Tailscale**, meaning the machine may not be on the same LAN.
The goal is:
* Automatically access the Samba share after boot.
* Do **not** fail boot if the server is unavailable.
* Wait until the share is actually accessed before attempting to connect.
* Work reliably with Tailscale's startup delay.
---
# Server Information
Hostname:
```text
svr52
```
Samba user:
```text
ta52
```
Primary share:
```text
smb
```
Mount point on client:
```text
/home/milan/svr52
```
---
# Required packages
Arch:
```bash
sudo pacman -S cifs-utils smbclient
```
---
# Verify connectivity
List available shares:
```bash
smbclient -L //svr52 -U ta52
```
Expected shares:
```
smb
ta52
print$
IPC$
```
---
# Credentials file
Create:
```bash
mkdir -p ~/.smb
nano ~/.smb/svr52
```
Contents:
```text
username=ta52
password=costarica
```
Protect it:
```bash
chmod 600 ~/.smb/svr52
```
---
# Create mountpoint
```bash
mkdir -p ~/svr52
```
---
# /etc/fstab
Append:
```fstab
//svr52/smb /home/milan/svr52 cifs credentials=/home/milan/.smb/svr52,uid=1000,gid=1000,_netdev,nofail,x-systemd.automount,x-systemd.idle-timeout=10min 0 0
```
### Explanation
* `credentials=...`
Uses the credentials file.
* `uid=1000,gid=1000`
Files appear owned by the normal user.
* `_netdev`
Marks this as a network filesystem.
* `nofail`
Boot continues even if the server is unreachable.
* `x-systemd.automount`
Do **not** mount during boot.
Mount only when the directory is first accessed.
* `x-systemd.idle-timeout=10min`
Automatically unmount after 10 minutes of inactivity.
---
# Reload systemd
```bash
sudo systemctl daemon-reload
```
---
# Test
Unmount if currently mounted:
```bash
sudo umount ~/svr52
```
Start automount:
```bash
sudo systemctl start home-milan-svr52.automount
```
Status should show:
```
Active: active (waiting)
```
---
# Verify automount
Before accessing:
```bash
findmnt ~/svr52
```
Expected:
```
autofs
```
Access the folder:
```bash
ls ~/svr52
```
Then verify:
```bash
findmnt ~/svr52
```
Expected:
```
autofs
└── cifs //svr52/smb
```
This confirms the automount triggered successfully.
---
# Why automount is required
A normal fstab mount fails because:
1. systemd processes `/etc/fstab`
2. Tailscale has **not yet connected**
3. `svr52` cannot be reached
4. Samba mount fails
Automount fixes this because:
1. Boot finishes normally.
2. Tailscale connects.
3. User later opens:
```
~/svr52
```
4. systemd performs the mount only then.
This completely avoids boot-time race conditions.
---
# Useful commands
List shares:
```bash
smbclient -L //svr52 -U ta52
```
Manual mount:
```bash
sudo mount -a
```
Unmount:
```bash
sudo umount ~/svr52
```
Status:
```bash
systemctl status home-milan-svr52.automount
```
Verify mount:
```bash
findmnt ~/svr52
```
Reload systemd after editing fstab:
```bash
sudo systemctl daemon-reload
```
---
# Current Working Configuration
* Client OS: Omarchy (Arch Linux)
* Transport: Tailscale
* Hostname: `svr52`
* Share: `smb`
* Credentials file: `~/.smb/svr52`
* Mount point: `/home/milan/svr52`
* Mount type: CIFS
* Mount strategy: `systemd` automount
* Idle timeout: 10 minutes
This configuration has been tested and confirmed working. The Samba share mounts automatically on first access after Tailscale is connected, eliminating boot-time failures caused by network startup timing.