Use a Raspberry Pi as an iPhone photo backup target (Samba)

By Isaac Griffiths, developer of SMBDrop ·

You don't need a NAS to have somewhere at home for your iPhone photos. A Raspberry Pi with a USB drive running Samba is a perfectly usable SMB server, and the iPhone's Files app can connect to it the same way it connects to a Synology. The official Raspberry Pi NAS tutorial even walks through connecting from iOS.

This guide puts the pieces together from the Raspberry Pi docs and Samba's own documentation, with a couple of updates where the official tutorial has aged.

What you need: a Raspberry Pi 4 or 5, a proper power supply, a microSD card, a USB SSD or hard drive, and an Ethernet cable. A Pi 4 needs a 5V/3A supply. A Pi 5 wants 5V/5A: on a lesser supply it limits USB peripherals to 600 mA, which a forum explanation says is unlikely to be enough for an SSD. If in doubt, use a powered USB hub, as the official tutorial does.

Step 1: Install Raspberry Pi OS Lite (64-bit)

Use Raspberry Pi Imager to flash Raspberry Pi OS Lite (64-bit). In Imager's settings, set a hostname, a username and password, and turn on SSH. The official NAS tutorial still says 32-bit, which is dated advice. Plug the Pi into your router with Ethernet; the tutorial recommends it for the best performance.

SSH in and update:

sudo apt update
sudo apt full-upgrade

Step 2: Install Samba

Raspberry Pi OS doesn't include Samba by default.

sudo apt install samba samba-common-bin

Step 3: Mount the USB drive by UUID

Pi OS Lite doesn't automount drives, so you'll add it to /etc/fstab. Find the drive:

sudo lsblk -o UUID,NAME,FSTYPE,SIZE,MOUNTPOINT,LABEL,MODEL

If it's a new drive and you're happy to erase it, format the partition as ext4 (this wipes it; check the device name first):

sudo mkfs.ext4 /dev/sda1

Make a mount point and get the UUID:

sudo mkdir /mnt/photos
sudo blkid

Add a line like this to /etc/fstab, with your own UUID:

UUID=your-uuid-here /mnt/photos ext4 defaults,noatime,nofail 0 2

Using the UUID rather than /dev/sda1 (which is what the official tutorial does) means the right drive mounts even if device names shuffle. nofail lets the Pi still boot if the drive isn't plugged in. Then:

sudo mount -a
mountpoint /mnt/photos

It should print /mnt/photos is a mountpoint. If it says /mnt/photos is not a mountpoint, stop and fix the fstab line before you go any further. Because of nofail, the Pi carries on without the drive, and the iphone folder and every photo you send would land on the SD card instead. Run mountpoint /mnt/photos again after your first reboot to check the drive comes back on its own.

If you'd rather keep the drive as exFAT, install exfat-fuse. NTFS is read only unless you install ntfs-3g. For a drive that lives on the Pi, ext4 is simplest.

Step 4: Make a folder and a Samba user

sudo mkdir /mnt/photos/iphone
sudo chown youruser:youruser /mnt/photos/iphone
sudo smbpasswd -a youruser

Replace youruser with the user you created in Imager. smbpasswd sets a separate Samba password for that user, which is what the iPhone will sign in with. Some tutorials use chmod 0777 on the folder; owning it with your user is tidier.

Step 5: Configure the share

Edit /etc/samba/smb.conf. In the [global] section, add the Apple compatibility lines. The Samba wiki's recommended config for Macs is:

[global]
   vfs objects = fruit streams_xattr
   fruit:metadata = stream
   fruit:model = MacSamba
   fruit:veto_appledouble = no
   fruit:nfs_aces = no
   fruit:wipe_intentionally_left_blank_rfork = yes
   fruit:delete_empty_adfiles = yes

To be clear about what's known: these settings are written for Macs, and I haven't seen a test of whether iPhones strictly need all of them. They're commonly advised for Apple clients, and streams_xattr in particular is the line that has fixed the iOS 18 "read only" problem for a lot of people (see the read-only share guide). Samba warns that setting vfs objects inside a share overrides the global one, so keep it in [global].

Then add the share at the bottom of the file:

[iphone]
   path = /mnt/photos/iphone
   valid users = youruser
   read only = no
   browseable = yes

The Raspberry Pi docs' example share uses public = yes, which allows guest access. For your photos, valid users limits it to your account. Check the config and restart Samba:

testparm
sudo systemctl restart smbd

Step 6: Give the Pi a fixed address

In your router, set a DHCP reservation for the Pi so its IP address never changes. The iPhone connects by address, so a moving address means a broken connection.

Step 7: Connect from the iPhone

  1. Open Files → Browse → ⋯ → Connect to Server.
  2. Enter smb:// and the Pi's IP address, or smb://yourhostname.local.
  3. Choose Registered User and sign in with the Samba username and password.
  4. Open the iphone share and save a test file.

If it won't connect, the can't connect to server guide and "Socket is not connected" cover the usual causes. On the Raspberry Pi forum, one user with a Pi 3B+ found the Files app couldn't create folders while other SMB apps could, which is the same read-only pattern.

Be honest about what this is

Where SMBDrop fits

Disclosure: I make SMBDrop. It sends original photos and videos from your iPhone to an SMB share like this one, with both halves of each Live Photo, in the background with a retry queue. It doesn't find the Pi on your network by itself, which is why the DHCP reservation matters: you enter the Pi's address and your Samba sign-in, tap Find Shares, and pick iphone. It needs Settings → Privacy & Security → Local Network turned on, like any third-party app reaching your network, and it works over a VPN such as Tailscale when you're away (see sending to your NAS over Tailscale). It's £9.99 once, no subscription, no account. The best SMB apps for iPhone covers the alternatives, and the NAS backup comparison covers the bigger picture.

FAQ

Can a Raspberry Pi be an iPhone photo backup target?

Yes. Install Samba on Raspberry Pi OS, share a folder on a USB drive, and the iPhone can connect to it over SMB from the Files app or an SMB app, the same way it connects to a NAS.

Do I need vfs_fruit for an iPhone to use a Pi Samba share?

It isn't proven to be required for iPhones, but it's commonly advised for Apple clients. The streams_xattr part has fixed the iOS 18 read-only problem for many people, so it's worth including.

Why won't my Pi 5 power my USB SSD?

On a supply below 5V/5A, the Pi 5 limits USB peripherals to 600 mA, which is unlikely to be enough for an SSD. Use the official 5V/5A supply or a powered USB hub.

Should I use public = yes on the share?

Not for photos. public = yes allows guest access. Use valid users with your own account so only you can sign in.

More guides

Try SMBDrop

Send original photos, videos and files from your iPhone straight to your own SMB share. One purchase, no account, no subscription.

Download SMBDrop on the App Store £9.99 once · no subscription · iOS 17+