AI helped me build the music lib setup of my dreams.

Published on Nov 30, 2026

Vinyl came back into my life about two years ago, and since then I've been digitizing my records as I go. I love the ritual of the turntable, but some evenings I just want to hear that one album I half remember, without the setup. So the digital copies, along with everything else I have collected, live on a single external SSD.

There's a second reason it's an external drive and not a folder on some computer. Now and then I play a set with Serato and my Numark gear (a Mixtrack Go and a Scratch mixer). Serato keeps its crates in a _Serato_ folder on the drive itself, so I plug the SSD into the laptop and my whole library, crates and all, is right there for the set.

So the idea was simple. One drive I can carry around: plug it into the PC or the Mac to add music or play a set, and when it goes back to the Raspberry Pi at home, the music just appears on every Sonos speaker in the house. No settings, no "is it mounted?", no opening the Sonos app to hunt for "Update Music Library".

That last bit was the hard one. I built it in an afternoon with Claude Code, and the way we got there was messier than I expected.

The setup

  • An Intenso TX500 1 TB SSD, formatted exFAT. That was Claude's suggestion when I first set the drive up, and I didn't realize at the time how much it mattered: exFAT is the one format that Windows, macOS and Linux all read and write natively, with no file-size limit to trip over on big FLAC rips. Without it the drive couldn't move around at all.
  • A Raspberry Pi 4 on the home network, sharing the drive over Samba (SMB).
  • Sonos speakers in the living room, office and bedroom, pointed at that share as their music library.

On paper that already works. In practice it kept falling over.

What kept breaking

I plugged the drive in, ran my old connect script, and got:

❌ Drive not found (UUID 69ED-157A). Is the SSD plugged in and powered?

Claude Code connected to the Pi and read the kernel log. The drive was showing up, failing with USB protocol errors, disappearing and retrying, until the kernel gave up with Cannot enable. Maybe the USB cable is bad?. Power was fine. Moving it to the other blue USB 3.0 port fixed the connection immediately.

Underneath that there was a second problem. The drive uses a JMicron USB bridge that is known to misbehave on the Pi 4 with the fast uas driver: it randomly drops off the bus and comes back as a new device, while the old mount stays pointed at the dead one. Sonos then reports perfectly good tracks as "not encoded correctly", which sends you looking in completely the wrong place.

The fix is one line in the Pi's boot config that tells it to use the plain usb-storage driver for this one device. My first question was whether that would change the drive and stop it working on the Mac. It doesn't: the setting lives on the Pi, the drive stays exFAT, and the Mac never knows.

Making it automatic

The part I am happiest with is that I no longer do anything. When the drive is plugged in, a udev rule on the Pi notices it by its UUID and starts a small service that:

  1. clears any stale mount left over from a disconnect,
  2. mounts the drive and checks it can really read a file,
  3. makes sure the Samba share is running,
  4. asks Sonos how many tracks its library has, and if the answer is zero, tells Sonos to rescan.

Sonos has no official API for this, but every speaker exposes a local UPnP interface on port 1400. The same "Update Music Library Now" action the app sends can be sent from a script. The speakers change IP addresses over DHCP, so the script finds them on the network by multicast instead of relying on fixed IPs.

At first it rescanned on every plug-in. A full scan of about 22,700 files takes around ten minutes, and most of the time nothing has changed. So now it only rescans on its own when the library is empty. When I have added music, I run one command and it asks me first.

The commands

Everything starts with music-, so typing music- and Tab shows them all:

Command What it does
music-status Is the drive mounted, is Samba up, is Sonos scanning?
music-scan Asks, then tells Sonos to rescan
music-connect Mounts by hand (rarely needed now)
music-disconnect Unmounts so the drive is safe to unplug
music-help Lists them

Sonos never tells you how far along a scan is, and the library stays empty until it finishes. So music-status estimates it, by checking which file Sonos is reading right now and how fast it is moving:

⏳ Sonos is still scanning the library. Music appears in the app when it finishes.
   Progress: about 96% (22041 of 22742 files, rough estimate)
   Speed: about 1776 files/min. Time left: less than a minute

The mistakes were the fun part

It didn't all work first time, and honestly I enjoyed those moments.

The first version mounted the drive and then, ten seconds later, the mount quietly vanished. Sonos happened to scan in exactly that window, found nothing, and my whole library disappeared from the app. Not fun. The cause: on this older Pi OS, exFAT runs as a user-space (FUSE) process, and systemd cleans up every process a service started when that service finishes, including the one holding the mount open. The fix was to let systemd do the mount through its own mount unit. We only caught it because Claude Code asked me to physically unplug and replug the drive instead of trusting the code.

Then the status command told me the scan was done when it wasn't. Only one speaker in the house (the living room Beam) does the indexing, and the others always say "not scanning". So now it asks all of them.

What it's like now

The drive moves between computers like any USB drive. For a set it goes to the laptop with Serato; at home it goes into the Pi and that's it. Sonos doesn't even notice the Serato folders, because there's no audio in them. My wife opens the Sonos app and the whole collection is there, vinyl rips included, on any speaker or all of them at once, whether I'm home or not.

SD cards die, so the whole thing lives in a GitHub repo with an install script. Fresh card, one git clone, one sudo ./install.sh, a reboot, and it's back.

It's open source, so if you have a Pi, a drive full of music and a few Sonos speakers, it's yours too: github.com/drakakisgeo/pi-music.

I still put the record on some nights. When I just want to remember how that B-side goes, I tap the app.