GainDrive Server is a single statically linked executable with no runtime dependencies. Binaries are provided for arm64 and x86_64 Linux.
ffmpeg on PATH, only if you want on-the-fly transcoding.Download the release for your architecture, make it executable, and move it somewhere on your PATH.
$ curl -LO https://github.com/kpeeters/gaindrive/releases/latest/download/gaindrive-linux-x86_64 $ chmod +x gaindrive-linux-x86_64 $ sudo mv gaindrive-linux-x86_64 /usr/local/bin/gaindrive
You need a C++ compiler with C++20 support and CMake.
$ git clone https://github.com/kpeeters/gaindrive.git $ cd gaindrive $ cmake -B build -DCMAKE_BUILD_TYPE=Release $ cmake --build build -j
Point GainDrive at your music folder and start it. On the first start it creates both databases and begins an initial scan.
$ gaindrive --music ~/Music --port 4040 ♪ GainDrive · listening on :4040 ✓ scanned 1,284 albums · 18,902 tracks ✓ web player ready → http://localhost:4040
Open http://localhost:4040 in a browser and create the first account; it becomes the administrator. Further accounts are added from the admin panel in the web player.
GainDrive reads metadata from ID3 tags where they exist, and falls back to the folder structure where they do not. Either way it presents one unified library to every client.
A conventional layout gives the best results, and multi-disc sets are picked up automatically:
Music/
├── Artist Name/
│ ├── 1994 — Album Title/
│ │ ├── 01 First Track.flac
│ │ └── cover.jpg
│ └── 1998 — Box Set/
│ ├── Disc 1/
│ └── Disc 2/
Folders are watched with inotify, so added, moved and retagged files are reflected without a manual rescan. Artist and album metadata and artwork missing from your files are fetched from MusicBrainz and other sources.
To keep GainDrive running across reboots, install it as a systemd unit at /etc/systemd/system/gaindrive.service.
[Unit] Description=GainDrive music server After=network.target [Service] User=music ExecStart=/usr/local/bin/gaindrive --music /srv/music --port 4040 Restart=on-failure [Install] WantedBy=multi-user.target
$ sudo systemctl enable --now gaindrive $ systemctl status gaindrive
Put GainDrive behind nginx or Caddy if you want it reachable from outside your network with a certificate.
server {
server_name music.example.com;
location / {
proxy_pass http://127.0.0.1:4040;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
When a client asks for a format or bitrate your files are not already in, GainDrive transcodes on the fly using ffmpeg. Enable a cache so a given transcode is only produced once.
$ gaindrive --music /srv/music \ --transcode-cache /var/cache/gaindrive
Without ffmpeg on PATH, GainDrive streams original files only; everything else keeps working.
Install the APK from the releases page. You will need to allow installation from unknown sources the first time.
https://music.example.com) with your username and password.GainDrive speaks the OpenSubsonic API, so any compatible client on iOS, Android or desktop works. Point the client at your server URL and sign in with a GainDrive account. Each user gets their own playlists and listening history.
Check that the user running GainDrive can read the music directory, and that --music points at the folder containing your artist folders rather than a parent of it.
Filesystem watching relies on inotify, which does not work over most network mounts. On an NFS or SMB share, run a periodic rescan instead.
This is almost always inconsistent tagging — usually the album artist differing between tracks. Fix the tags and the watcher will regroup the album on its own.
That client is likely requesting a format your files are not in. Install ffmpeg so transcoding can take over.
Still stuck? Open an issue on GitHub.