Adding simple music server to my network
One of my goals for 2022 is to not pay for music subscriptions anymore. Nowadays, it’s really easy and cheap to actually own my music.
Internet is full of cheap, used CDs and new music is ready for purchase on sites like Bandcamp. Since I mostly listen to dead people, CDs are my primary source.
The first problem is having something to put a disc in. I’ve gotten myself a cheap USB-CD/DVD drive. It’s very loud, but since I use it only for getting the data to my computer, it’s not a problem.
I rip (a word that I have not seen in a long time) on MacBook using XLD app. I plan to move this step to Linux soon.
I rip the music to FLAC, which seems to be standard. It’s lossless and most file-based players have no problems with it. Of course, not everywhere. iOS is always problematic, but I don’t listen to music on the go very often, so it’s a problem for future me.
A single album in FLAC takes about 200-300 MB. I still remember MP3 days, where it would go down to 60 MB or less, but back then storage and transfer were actually expensive. I don’t hear any noticeable difference between FLAC and good compressed file, but again - storage and transfer is cheap, Furthermore I have a single high-res album where half an hour takes 750 MBMB and there is zero difference. Well, now I know, and I won’t buy-high res ever again :)
Storing and serving music
The music will be accessed by multiple devices on local network, so putting it on the Home Server makes perfect sense. I now have a dedicated share “music” which is shared via Samba and NFS.
Samba seems better than NFS, but then NFS on Linux is simpler to set up.
For Samba, I need to add read+write access to Music share for each user from Synology web UI.
NFS on the other hand doesn’t support users, but devices instead. The first step is to set static IP for my devices (which is always a good idea). How exactly this should be approached depends on the setup, but I use UniFi Dream Machine and forcing IP for a device is very straight forward. After I have static IPs, I can add read/write access for those addresses, also via Synology web UI.
Served music is so small, that this does not add any noticeable overhead for the server.
Accessing the music on Linux
First, I needed to install NFS support. I use Arch, so:
# pacman -S nfs-utils
Then I checked if the share actually exists. My server’s address is 10.0.1.200.
$ showmount -e 10.0.1.200 ------------------ Export list for 10.0.1.200: /volume2/music 10.0.1.10
Voilà! Next step: check if it works
# mkdir /mnt/music # mount 10.0.1.200:/volume2/music /mnt/music/ # cd /mnt/music # ls
And listing worked. Noice. To automate it for future, and to allow non-root users to actually mount the drive I added a new mount to /etc/fstab:
10.0.1.200:/volume2/music /mnt/music nfs _netdev,noauto,x-systemd.automount,x-systemd.mount-timeout=10,timeo=14,users,x-systemd.idle-timeout=1min 0 0
After the first user accesses /mnt/music, the drive will be mounted.
Playing the music using CMUS
We have access to the files, let’s play it. Every modern music player for Linux should work with Flac, but I’ve chosen CMUS. It’s fast, it’s terminal based, and it supports VIM keybindings.
# pacman -S cmus
After we open cmus, we need to add music. It’s done similarly to VIM, via an ex command.
And a few seconds later, the music is visible in the player. Using CMUS requires reading the manual
$ man cmus-tutorial
but the basics I needed to play something from Artist/Album view were:
j go up k go down tab change active window (artists/tracks) space expand artist to album list c play track / pause track e add track to queue q exit
Extra bonus: after first configuring system I had some problems with audio not working from time to time. Moving from Pulse to Pipewire solved them all.
Listening on Mac via CMUS
I have no idea how to auto mount a server on MacOS, so after every reboot or network change, I need access the Samba share via Finder. After it’s mounted, I can access it under /Volumes/music.
On Mac I also use CMUS, so all of the above apply as well. One difference is adding the files due to different location
This doesn’t solve all my needs. In the future I need to find out how to:
- access the music outside my home network
- how to marry this setup with my multiroom system (Sonos + Homepods)