PART2: Cloning AMD64 UEFI Image Disk From Windows

# we assume you have a PC with Windows system and 7zip (or Winrar) installed
# and GParted Live USB stick bootable


# more info on GParted website to create your a bootable Live system)
# and another USB drive for the image disk

WINDOWS PC

# download the distribution from our website/github and extract it with 7zip (or Winrar)
# insert your USB drive and format it using NTFS with for example ‘imgdisk’ name
# then copy the extracted image disk (.img) from Windows to your USB drive
# optional: rename image disk to musiclounge.img or medialounge.img

BAREBONE PC (HTPC)

# insert the the GParted Live USB, the imgdisk usb stick, plug a keyboard (and optionally a mouse)
# and turn the HTPC ON
# quickly hit F10 (NUC) or F12 to show up the boot menu
# boot UEFI:disk corresponding to GParted live USB
# GParted app should be opened so you can identify easily
# your internal hard drive (/dev/sda) and your USB stick ‘imgdisk’ (/dev/sdX)
# in our example:

internal hard drive (ssd): /dev/sda
imgdisk partition 1: /dev/sdb1

# QUIT GParted app

# open terminal with root permissions
# mount your usb imgdisk

  1. $ mount /dev/sdX /media
  2. $ cd /media
  3. $ ls

# IMPORTANT: check the integrity of the image disk

  1. $ sha1sum medialounge....img

# compare the result with the SHA1 line on website
# if this doesn’t match then your image disk is corrupted, you can’t go further until your img disk is clean
# clone from image disk to your internal disk (/dev/sda)
# ALL DATA IN INTERNAL HARD DRIVE/SSD WILL BE ERASED

  1. $ sudo dd if=musiclounge.img of=/dev/sda bs=2048 status=progress

# then fix gpt backup header/table on the target disk

  1. $ sudo sgdisk -e /dev/sda

# unmount /media

  1. $ cd /
  2. $ umount /media

# now launch GParted app to resize the root partition (3) of your internal disk (/dev/sda3)

# double-check and APPLY all changes

# expand partition 3 (minimum 16GB)


# shutdown your HTPC
# remove both GParted live usb and imgdisk usb drive

# congrats! You are now ready to enjoy your distribution

PART1: Cloning AMD64 UEFI Image Disk From Windows (Rufus)

# we assume you have a PC with Windows system with 7zip (or Winrar) and Rufus installed
# an USB Drive with GParted Live USB bootable


# more info on GParted website to create your a bootable Live system)


# and an USB3 To SATA adapter cable

# if you do not have the cable, follow the instructions of SOLUTION 2

WINDOWS PC

# download the distribution from our website/github and extract it with 7zip or Winrar

# IMPORTANT: check the integrity of the image disk
# and compare the result with the corresponding SHA256 line on website

# run powershell (i.e. Windows Terminal) and type:

Get-FileHash C:\path\to\imagedisk.img

# if this doesn’t match then your image disk is corrupted, you can’t go further until your img disk is clean
# connect your SSD (or 2.5″ Hard drive) to your PC with the Startech USB3 To SATA adapter


# then run Rufus and select the image disk, tick the “List USB Hard Drives” and select your SSD
# clone from image disk to your internal disk
#ALL DATA IN INTERNAL HARD DRIVE/SSD WILL BE ERASED


# After the cloning, close Rufus, disconnect the adapter cable from the PC and mount the SSD inside your Barebone PC/NUC

BAREBONE PC (HTPC)

# insert the the GParted Live USB, plug a keyboard (and optionally a mouse)
# and turn the HTPC ON
# quickly hit F10 (NUC) or F12 to show up the boot menu
# boot UEFI:disk corresponding to GParted live USB
# GParted app should be opened so you can identify easily
# your internal hard drive (/dev/sda)
# Fix the GPT backup header/table if GParted prompts to do so

# resize the root partition of your internal disk (/dev/sda3)

# double-check and APPLY all changes

# expand partition 3 (minimum 16GB)


# shutdown your HTPC
# remove both GParted live usb

# congrats! You are now ready to enjoy your distribution

expand partition with gparted

Expand Your Main Partition With GParted

# Armbian and Raspi OS come with a nice utility to expand your partition (read the Musiclounge installation for more info) but what about Debian/Ubuntu?
# for this distro you need to do it manually but don’t worry


# with the great GParted it’s very easy

# grab the gparted live iso, make a bootable sd card or usb stick to expand your hard drive
https://gparted.org/livecd.php


# so you already created your image disk of MusicLounge audiophile server for amd64 on hard drive, usb stick or SD card


# boot with GParted Live USB key and run GParted (the software should startup automatically)


# select on top-right menu your musiclounge device disk (here it’s /dev/sdc)

# in edition 2023 the root partition is the last.
# so it is very easy, unmount root partition and expand it

# may need to fix the GPT table backup due to the different size of the hard drive.

# if GPT partions table is corrupted, open terminal and fix gpt with

# assuming it is on /dev/sda disk

  1. $ sudo sgdisk -e /dev/sda

# that’s it!
# your MusicLounge Audiophile Server distro is now ready

# however if your root partition is before the swap do the following


# right-click the main partition to unmount musiclounge device


# click the swap partition and right-click to select Resize/Move


# select Align To Cylinder and
# move the partition to the end (or put zero in free space following)
# then click Resize/Move button


# click the main partition and right-click to select Resize/Move

# resize the partition to the end
# then click Resize/Move button


# apply changes

# that’s it!
# your MusicLounge Audiophile Server distro is now ready

Continue Reading The Musiclounge Installation

Cloning AMD64 UEFI Image Disk From Windows

# cloning large UEFI image disk (5GB+) from Windows to internal hard drive (or SSD) may cause of corrupt installation
# also due to GPT structure, cloning to another disk is not enough, you need to rewrite the GPT backup header/table on the last 33 sectors of your target disk
# finally you really need to resize the root partition to get enough space for using the distribution

# here are the instructions to make this from Windows and with GParted Live on Linux side.

SOLUTION 1 Requirements

This way is very easy but requires to remove the hard drive/SSD from the Barebone PC/NUC and a special USB3.0 to SATA adapter cable (ref. USB3S2SAT3CB from StartTech).

Windows PC with Rufus and 7-Zip (or Winrar) Installed
1 USB Drive with Bootable GParted Live

1 USB3 To SATA adapter cable

SOLUTION 2 Requirements

Windows PC with Rufus and 7-Zip (or Winrar) Installed
1 USB drive for the image disk
1 USB Drive with Bootable GParted Live

MusicLounge: Upgrade Server To Editon 2023

Upgrade MusicLounge Server Editon 2021 To Editon 2023

# Important Notice: The image disk of the 2023 edition for Raspberry PI 4, Odroid C4 and amd64 platform are available for download HERE.
#
# follow the instructions below to upgrade your edition 2021 of MusicLounge. The audiophile server must be already installed and operational.
#
# be sure your data partition is resized
# Odroid C4 with Armbian

  1. $ sudo systemctl enable armbian-resize-filesystem
  2. $ sudo reboot

# Raspberry PI 4 with RaspPI OS, simply run raspi-config and select Advanced Options > Expand Filesystem and reboot

  1. $ sudo raspi-config

# expanding your partition during the boot can take a while (depending the size of your SD Card) so be patient,

# at first boot you should see

Usage of /: 71% of 3.7G

# after expansion on 16GB SD Card

Usage of /: 19% of 14G

# for debian amd64 expand your hard drive if needed using gparted on live distro or from desktop PC is easy
# first move the swap sda2 to end and then resize sda1
# click this link to read the tutorial to expand your disk with GParted


# First, ensure your system is up-to-date in it’s current release.
# update unpncli signature
# go to https://www.lesbonscomptes.com/pages/signatures.html
# download lesbonscomptes.gpg and copy to /usr/share/keyrings/

  1. $ cd ~/Downloads/
  2. $ sudo cp lesbonscomptes.gpg /usr/share/keyrings/

# update buster (ed. 2021) pkgs, the distro must be up to date

  1. $ sudo apt update

# now upgrade pkgs, during installation
# keep local smb.conf
# choose the internal hard drive /dev/sda to install grub if needed (and NOT /dev/sda1)
# otherwise select [default=N] reply

  1. $ sudo apt upgrade

# make a full upgrade to be sure

  1. $ sudo apt full-upgrade

# run update again and you should read
# All packages are up to date.

  1. $ sudo apt update

# now update sources list

  1. $ sudo sed -i 's/buster/bullseye/g' /etc/apt/sources.list
  2. $ sudo sed -i 's/buster/bullseye/g' /etc/apt/sources.list.d/*.list

# update to bullseye sources.list with the entries below

  1. $ sudo nano /etc/apt/sources.list
deb http://deb.debian.org/debian bullseye main contrib non-free
deb-src http://deb.debian.org/debian bullseye main contrib non-free
deb http://deb.debian.org/debian bullseye-updates main contrib non-free
deb-src http://deb.debian.org/debian bullseye-updates main contrib non-free
deb http://deb.debian.org/debian bullseye-backports main contrib non-free
deb-src http://deb.debian.org/debian bullseye-backports main contrib non-free
deb http://security.debian.org/debian-security/ bullseye-security main contrib non-free
deb-src http://security.debian.org/debian-security/ bullseye-security main contrib non-free

# check and update upnpcli source list

  1. $ sudo nano /etc/apt/sources.list.d/*
deb [signed-by=/usr/share/keyrings/lesbonscomptes.gpg] http://www.lesbonscomptes.com/upmpdcli/downloads/debian/ bullseye main
deb-src [signed-by=/usr/share/keyrings/lesbonscomptes.gpg] http://www.lesbonscomptes.com/upmpdcli/downloads/debian/ bullseye main
  1. $ sudo apt clean
  2. $ sudo apt update

# IMPORTANT: on any error fix your sources list before going further

# say YES for restarting services automatically
# for all request (i.e. update conf files) during the upgrade say no
[default=N]

  1. $ sudo apt upgrade

# may require to remove gcc 8 base if the command failed during upgrade because of libc6-dev

  1. $ sudo apt-get remove libgcc-8-dev

# for all request during the upgrade say ‘n’
[default=N]
# and obviously keep smb.conf
# make a full upgrade

  1. $ sudo apt full-upgrade

# run update again and you should read
# All packages are up to date.
# otherwise run $ sudo apt full-upgrade AGAIN

  1. $ sudo apt update

# cleanup pkgs

  1. $ sudo apt autoremove -y

# reboot

  1. $ sudo shutdown -r now

# MPD Upgrade
# check the latest release version available on offical website musicpd.org
# for example to download and extract release 0.23.12 in mpd-0.23.12/

  1. $ cd ~/Downloads/
  2. $ sudo wget https://www.musicpd.org/download/mpd/0.23/mpd-0.23.12.tar.xz
  3. $ sudo tar xf mpd-0.23.12.tar.xz

# or get the very latest (unstable dev release) by cloning the MPD git to MPD/

  1. $ sudo git clone https://github.com/MusicPlayerDaemon/MPD.git

# notice: libboost-dev dependency is no longer needed
# read the mpd tutorial to compile and install the latest version of MPD (version 0.23.12 or greater)

# after compilation and installation enable and start the service

  1. $ sudo systemctl enable mpd
  2. $ sudo systemctl start mpd
  3. $ sudo reboot

# check mpd

  1. $ sudo systemctl status mpd

#
# TROUBLESHOUTING
# in case of error (generally occurs within 5s just after playing) :

alsa_output: Decoder is too slow; playing silence to avoid xrun

# adding the following lines to all your audio output in mpd configuration (/etc/mpd.conf) may help
#

buffer_time "200000"
period_time "5084"

#
# edit mpd.conf and scroll to audio output area to add the 2 lines

  1. $ sudo nano /etc/mpd.conf
.
.
.
audio_output {
type "alsa"
name "Default"
device "hw:1,0"
mixer_type "none"
dop "no"
buffer_time "200000"
period_time "5084"
}

audio_output {
type "alsa"
name "ALSA DAC DOP"
device "hw:1,0"
mixer_type "none"
dop "yes"
buffer_time "200000"
period_time "5084"
}
.
.
.

#
# in case of non fatal binding error

server_socket: bind to '0.0.0.0:8000' failed (continuing anyway, because binding to '[::]:8000' succeeded): Failed to bind socket: Address already in use

# a binding already exists due to ipv6, however mpd is running correctly. if you do not need ipv6 support follow these instructions to disable it by using sysctl command and by adding the kernel option ipv6.disable=1 https://www.wikihow.com/Disable-Ipv6-on-Linux
# edit your nginx.conf to remove ipv6 listening by
# commenting listen [::]:80 default_server; on server block

  1. $ sudo nano /etc/nginx/sites-available/default
server {
        listen 80 default_server;
#       listen [::]:80 default_server;

# myMPD Upgrade

  1. $ cd Downloads/

# rename current directory if exists

  1. $ mv myMPD/ myMPD-10.1.7/

# read the myMPD tutorial on website
# to compile and install the latest version of myMPD (version 10.2.0 or greater)
# after compilation and installation generate the config files

  1. $ sudo systemd-run -t -p DynamicUser=yes -p StateDirectory=mympd -p CacheDirectory=mympd /usr/bin/mympd -c

# change port to 8080

  1. $ sudo nano /var/lib/mympd/config/http_port

# deactivate SSL (false)

  1. $ sudo nano /var/lib/mympd/config/ssl

# enable and start service

  1. $ sudo systemctl enable mympd
  2. $ sudo systemctl start mympd
  3. $ sudo reboot

# check

  1. $ sudo systemctl status mympd

# Raspotify Upgrade
# Install latest version of Raspotify on armhf
# before installing purge old version of raspotify

  1. $ sudo apt purge raspotify

# attention on amd64 you need to remove the Raspotify docker image

  1. $ sudo docker stop spot
  2. $ sudo docker rm spot

# list images

  1. $ sudo docker images

# get IMAGE ID and remove it

  1. $ sudo docker rmi IMAGE_ID

# if docker is no longer used you can remove it as well
# for more info see the tutorial on page:
# MusicLounge: Spotify Connect (On amd64 Distro Using Docker)
# docker image is now removed
# to install Raspotify type the following command:

$ sudo apt-get -y install curl && curl -sL https://dtcooper.github.io/raspotify/install.sh | sh

# Edit Raspotify configuration:

  1. $ sudo nano /etc/raspotify/conf

# and change these options only

LIBRESPOT_DEVICE_NAME="MusicLounge"
LIBRESPOT_BITRATE="160"
LIBRESPOT_DEVICE="plughw:1,0"

# CTRL+O to save
# CTRL+X to exit
# now enable and start the service

  1. $ sudo systemctl daemon-reload
  2. $ sudo systemctl enable raspotify
  3. $ sudo systemctl start raspotify
  4. $ sudo reboot

# check the status

  1. $ sudo systemctl status raspotify

#
# TROUBLESHOOTING
#
# in case of warning related to libmdns

WARN  libmdns::fsm] dropping truncated packet from 192.168.x.x:5353

# this error is probably due to a bad implementation of mDNS in your router,
# you may update your router firmware or disable zeroconf (librespot discovery) and
# add your credentials to the Raspotify config
# edit conf and enable credential cache, disable discovery
# add your Spotify username and password

  1. $ sudo nano /etc/raspotify/conf
#LIBRESPOT_DISABLE_CREDENTIAL_CACHE=
...
# Disable zeroconf discovery mode.
LIBRESPOT_DISABLE_DISCOVERY=
...
LIBRESPOT_USERNAME="...."
LIBRESPOT_PASSWORD="...."

# NGINX
# check nginx service

  1. $ sudo systemctl status nginx

# in case of error

nginx.service: Failed to parse PID from file /run/nginx.pid: Invalid argument

# make the following changes:

  1. $ sudo mkdir /etc/systemd/system/nginx.service.d
  2. $ sudo nano /etc/systemd/system/nginx.service.d/override.conf

# enter these lines

[Service]
ExecStartPost=/bin/sleep 0.1

# CTRL + X and Y to SAVE

  1. $ sudo systemctl daemon-reload
  2. $ sudo reboot

# open the ssh session and check the status

  1. $ sudo systemctl status nginx

# check the status of minidlna service

  1. $ sudo systemctl status minidlna

# in case of error related to autofs

/lib/systemd/system/minidlna.service:4: Failed to add dependency on autofs, ignoring: Invalid argument

# edit service to apply this fix

  1. $ sudo nano /lib/systemd/system/minidlna.service

# and replace autofs by autofs.service
# CTRL + X and Y to SAVE

  1. $ sudo systemctl daemon-reload
  2. $ sudo reboot

# check your fstab entry and journalctl (sudo journalctl -f )
# in case of error type:

CIFS VFS: Server 192.168.x.x has not responded in xxx seconds. Reconnecting...

# read carefully the SAMBA tutorial chapter “CIFS Mounts Disconnecting Issue – Read More…” (end of the page)
# otherwise disable the cron job (comment line)

  1. $ sudo nano /etc/cron.d/smb_v1_fix
#*/10 *   *   *   *   root    /home/pi/scripts/smb_v1_fix.sh >/dev/null 2>&1

# in case of dhcpcd error type

dhcpcd.service: Failed to locate executable /usr/lib/dhcpcd5/dhcpcd: No such file or directory

# check if you have an error in the status of the service

  1. $ sudo systemctl status dhcpcd
Failed to start DHCP Client Daemon.

# edit the service
# to change ExecStart command to /usr/sbin/dhcpcd -q -w

  1. $ sudo nano /etc/systemd/system/dhcpcd.service.d/wait.conf
[Service]
ExecStart=
ExecStart=/usr/sbin/dhcpcd -q -w

# restart service and check again the status

  1. $ sudo systemctl daemon-reload
  2. $ sudo systemctl restart dhcpcd
  3. $ sudo systemctl status dhcpcd

# check the status of all other services ( airplay, roon, etc.) should be okay

# Congrats!
# Your MusicLounge audiophile server is fully updated to edition 2023
# now update the music library (database)
# use DroidMyMPD or MALP Android client
# or open your browser with http://musiclounge:8080 (or IP address)
# Enjoy!

I2S DAC Support

MusicLounge do not support I2S audio dac by default but it’s really easy to add the support of such cards.

Example 1 with Hifiberry DAC Plus RCA and Hiffiberry DAC+ PRO on Raspberry PI 4

Example 2 with Hifi Shield 2 (RCA) on Odriod C4

1- HIFIBERRY DAC And Raspberry PI 4

Make sure the board is correctly connected to the PI 4 and to the power supply (5V 3A)

# edit config.txt

pi@musiclounge:~ $ sudo nano /boot/config.txt

# add at end

dtoverlay=hifiberry-dacplus

CTRL+X to SAVE

List of Hifiberry device tree overlay:

DAC+ Standard/Pro/Amp2

dtoverlay=hifiberry-dacplus

DAC2 HD

dtoverlay=hifiberry-dacplushd

DAC+ ADC

dtoverlay=hifiberry-dacplusadc

DAC+ ADC Pro

dtoverlay=hifiberry-dacplusadcpro

Digi+

dtoverlay=hifiberry-digi

Digi+ Pro

dtoverlay=hifiberry-digi-pro

Reboot and That’s It!

Now check if card number is 1 using aplay -l

pi@musiclounge:~ $ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: Headphones [bcm2835 Headphones], device 0: bcm2835 Headphones [bcm2835 Headphones]
Subdevices: 8/8
Subdevice #0: subdevice #0
Subdevice #1: subdevice #1
Subdevice #2: subdevice #2
Subdevice #3: subdevice #3
Subdevice #4: subdevice #4
Subdevice #5: subdevice #5
Subdevice #6: subdevice #6
Subdevice #7: subdevice #7
card 1: sndrpihifiberry [snd_rpi_hifiberry_dacplus], device 0: HiFiBerry DAC+ Pro HiFi pcm512x-hifi-0 [HiFiBerry DAC+ Pro HiFi pcm512x-hifi-0]
Subdevices: 1/1
Subdevice #0: subdevice #0

The trick here is to keep dtparam=audio=on (native headphone) to shift Hifiberry DAC to card number 1 to be dirrectly compatible with MusicLounge audio server settings.

if card number is different go HERE to reconfigure MPD and other audio services

and if you use the alsa equalizer plugin do not forget to change the plughw id in .asoundrc, see the tutorial here

here is a basic setup of the mpd output audio for hifiberry dac

audio_output {
type "alsa"
name "Hifiberry"
device "hw:1,0"
mixer_type "hardware"
mixer_control "Digital"
mixer_device "hw:1"
mixer_index "0"
dop "yes"
}

2- HIFI SHIELD 2 AND ODROID C4

Make sure the board is correctly connected to the C4 and to the power supply ( more info available HERE ).

# Edit /media/boot/config.ini to edit the DTBO settings. Open that file and find the part shown below. The below settings different from the default, it adds a new section named overlay_hifishield (C2) or overlay_hifishield2 (C4) and uses that section by the overlay_profile variable.

@musiclounge:~ $ sudo nano /media/boot/config.ini

For C4 Only:

; Device Tree Overlay
overlay_resize=16384
overlay_profile=hifishield2
overlays="spi0 i2c0 i2c1 uart0"
 
[overlay_custom]
overlays="i2c0 i2c1"
 
[overlay_hktft32]
overlays="hktft32"
 
[overlay_hktft35]
overlays="hktft35"
 
[overlay_hifishield2]
overlays="hifishield2"

For C2 only:

; Device Tree Overlay
overlay_resize=16384
overlay_profile=hifishield
overlays="spi0 i2c0 i2c1 uart0"
 
[overlay_custom]
overlays="i2c0 i2c1"
 
[overlay_hktft32]
overlays="hktft32"
 
[overlay_hktft35]
overlays="hktft35"
 
[overlay_hifishield]
overlays="hifishield"

Reboot and That’s It!

Now check if card number is 1 using aplay -l

pi@musiclounge:~ $ aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: ODROIDHDMI [ODROID-HDMI], device 0: SPDIF-dit-hifi dit-hifi-0 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: ODROIDHIFI [ODROID-HIFI], device 0: TDM-B-pcm5102a-hifi multicodec-0 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0

if card number is different go HERE to reconfigure MPD and other audio services


List of other Raspberry PI device tree overlay (untested):

502-dac
dtoverlay= hifiberry-dacplus
502-dac-pro
dtoverlay= hifiberry-dacplus
503hta-hybrid
dtoverlay= hifiberry-dac
adafruit-max98357
dtoverlay= hifiberry-dac
adafruit-uda1334a
dtoverlay= hifiberry-dac,i2s-mmap
allo-boss-dac
dtoverlay= allo-boss-dac-pcm512x-audio
allo-digione
dtoverlay= allo-digione
allo-katana-dac
dtoverlay= allo-katana-dac-audio
applepi-dac
dtoverlay= applepi-dac
audio-injector-isolated
dtoverlay= audioinjector-isolated-soundcard
audio-injector-ultra
dtoverlay= audioinjector-ultra
audiophonics-es9028q2m-dac
dtoverlay= i-sabre-q2m
bassfly
dtoverlay= hifiberry-dac
bassfly-mic
dtoverlay= googlevoicehat-soundcard
bassowl
dtoverlay= bassowl
es90x8q2m-dac
dtoverlay= es90x8q2m-dac
fe-pi-audio
dtoverlay= fe-pi-audio
generic-dac
dtoverlay= hifiberry-dac
hifibox-dac
dtoverlay= hifiberry-dacplus
iqaudio-amp
dtoverlay= iqaudio-dacplus,unmute_amp
iqaudio-dacplus
dtoverlay= iqaudio-dacplus,unmute_amp
iqaudio-digiplus
dtoverlay= iqaudio-digi-wm8804-audio
justboom-amp
dtoverlay= justboom-dac
justboom-dac
dtoverlay= justboom-dac
justboom-digi
dtoverlay= justboom-digi
mamboberry-dac
dtoverlay= hifiberry-dac
merus-amp
dtoverlay= merus-amp
nanosound-dac
dtoverlay= hifiberry-dacplus
osa-dacberry-one-plus
dtoverlay= hifiberry-dacplus
osa-dacberry-pro
dtoverlay= iqaudio-dacplus
phat-beat
dtoverlay= hifiberry-dac
phat-dac
dtoverlay= hifiberry-dac
piano-dac
dtoverlay= allo-piano-dac-pcm512x-audio
piano-dac-plus
dtoverlay= allo-piano-dac-plus-pcm512x-audio
picade-hat
dtoverlay= hifiberry-dac
pisound
dtoverlay= pisound
raspiaudio
dtoverlay= googlevoicehat-soundcard
raspidacv3
dtoverlay= raspidac3
rpi-dac
dtoverlay= rpi-dac
soekris-dac
dtoverlay= hifiberry-dac
speaker-phat
dtoverlay= hifiberry-dac
st400-dac-amp
dtoverlay= iqaudio-dacplus
taudac
dtoverlay= taudac
terraberry-dac2
dtoverlay= i-sabre-q2m

MISC.: Preparing A Minimal Linux Distro (Odriod C4 Example)


# preparing your linux distro
# before following our tutorials and build your audiophile server

# our ready to use audiophile server distribution image disk (MusicLounge) is available here

# all info below are applicable to Odroid and others boards like raspberry PI or barebone PC
# beware official Odroid Linux Kernel version (v3.16.85) is outdated and do not contains the Native DSD patch
# you need version 4.19.64 or greater to play native DSD,
# however selecting DOP MPD audio output will works with limitation

# To build the MusicLounge Audiophile Server we recommended:
# Armbian Focal or Jammy Linux Distro on Odroid C4,
# RaspiOS lite (Debian) buster or Bulleyes for Raspberry PI 4,
# latest stable Debian Standard or Ubuntu server for amd64 (buster or bullseye)

# MPD version 0.23.12 and 0.22.8 for old distribution
# myMPD version 10.2.0 and 10.7.1 for old distribution

# before building you audiophile server the software requirements are simple:
# pi user must be set
# ssh must be set
# alsa must be installed and should recognize your usb dac (command: aplay -l )

# get the img from repository (armbian, raspberry, debian)
# burn it on SDCARD (8GB is enough) with any tool like Win32DiskImager app on Windows
# connect your usb DAC
# boot
# and start the ssh session
# default login/pass:
# on odroid: root/odroid or root/1234
# on raspberry PI: pi/raspberry
# on amd64 Debian: root password is created during the installation
# on our MusicLounge distro: pi/musiclounge

# the root password needed to be changed immediately
# and a new user (non root) must be created (see below)

New root password: ************************
Repeat password: ************************

Choose default system command shell:

1) bash
2) zsh

Shell: BASH

Creating a new user account. Press  to abort

Please provide a username (eg. your forename): pi
Create password: ************************
Repeat password: ************************

Please provide your real name: Pi

Dear Pi, your account pi has been created and is sudo enabled.
Please use this account for your daily work from now on.

# sanity check

  1. $ sudo apt update -y
  2. $ sudo apt upgrade -y

# on armbian ssh is available by default

# on RaspiOS you need to add an empty file named ssh inside the sdcard before booting the OS

# on Ubuntu server amd64 SSH is activated during installation

# on Debian Standard amd64 you need to install openssh-server pkg

# on Debian netinstall you need to install sudo and pi to sudo group

  1. ~# su - root
  2. ~# apt install sudo
  3. ~# usermod -aG sudo pi

# after the first boot add user pi to sudoers on Debian

  1. $ su - root
  2. $ nano /etc/sudoers

# find line root ALL=(ALL:ALL) ALL and add this line

pi ALL=(ALL:ALL) ALL

# save
# CTRL+X then type y and enter
# go back to user

  1. exit

# install ssh server
# not needed on debian netinstall distro as you normally install SSH server during the installation process

  1. $ sudo apt install openssh-server -y

# active service

  1. $ sudo systemctl start ssh
  2. $ sudo systemctl enable ssh

# HEADLESS PC Server (boot without monitor on)
# BEWARE: if you install a distro supposed to work with GUI like Ubuntu/Debian
# and EVEN IF YOU DID NOT INSTALL A USER INTERFACE you may not be able to boot without a monitor!
# fortunately we can fix it by changed a few lines in grub bootloader to get our headless audio server

# edit grub conf

  1. $ sudo nano /etc/default/grub

# and modify the parameters of GRUB_CMDLINE_LINUX_DEFAULT and GRUB_CMDLINE_LINUX to

GRUB_CMDLINE_LINUX_DEFAULT=""
GRUB_CMDLINE_LINUX="text"

# and obviously uncomment this line

GRUB_TERMINAL=console

# SAVE
# CTRL+X then type y and ENTER key

# now update grub

  1. $ sudo update-grub

that’s it!


# optional: if bash auto-completion (automatically completing of file names, commands and more) is not installed by default

  1. $ sudo apt-get install bash-completion

# audio check
# plug your usb DAC and type the cmd below to list soundcard, your dac must be in the list:

  1. $ aplay -l

# alsa should be already installed (not in ubuntu server no soundcard driver by default)
# if your dac is not visible, install ALSA:

  1. $ sudo apt-get install alsa-utils alsa-tools libasound2

# list devices to see if your DAC is recognized

  1. $ aplay -l
root@odroid:~# aplay -l
**** List of PLAYBACK Hardware Devices ****
card 0: ODROIDHDMI [ODROID-HDMI], device 0: I2S dit-hifi-0 []
  Subdevices: 1/1
  Subdevice #0: subdevice #0
card 1: D90 [D90], device 0: USB Audio [USB Audio]
  Subdevices: 1/1
  Subdevice #0: subdevice #0

# your usb DAC should be visible in the list

# if still it’s not visible (no soundcard error)
# list installed alsa pkgs, remove them and reinstall alsa
#
# alsa-base pkg could be omited if not present in repository

  1. $ sudo dpkg -l alsa*
  2. $ sudo apt --purge remove alsa-base alsa-firmware-loaders alsa-oss alsa-source alsa-tools alsa-tools-gui alsa-topology-conf alsa-ucm-conf alsamixergui alsa-utils
  3. $ sudo apt-get install alsa-base alsa-utils alsa-tools libasound2
  4. $ sudo reboot

# check alsa status

  1. $ sudo systemctl status alsa-utils.service

# if alsa service is masked unmask it

  1. $ sudo rm /lib/systemd/system/alsa-utils.service
  1. $ sudo systemctl daemon-reload
  1. $ sudo systemctl enable alsa-utils
  2. $ sudo systemctl start alsa-utils

# check the status again everything should be okay

  1. $ sudo systemctl status alsa-utils.service

# on a minimal linux distro with only root you need to create a new user ‘pi’ (or other name) which going to be used to build your MusicLounge audiophile server
# if you’re already login as pi user skip the creation below and go to adding groups directly


# create a user pi:

  1. $ adduser pi
root@odroid:~# adduser pi
Adding user `pi' ...
Adding new group `pi' (1000) ...
Adding new user `pi' (1000) with group `pi' ...
Creating home directory `/home/pi' ...
Copying files from `/etc/skel' ...
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully
Changing the user information for pi
Enter the new value, or press ENTER for the default
        Full Name []: PI
        Room Number []:
        Work Phone []:
        Home Phone []:
        Other []:
Is the information correct? [Y/n] y

# add new user to all default groups

  1. $ sudo usermod -aG adm,dialout,cdrom,sudo,audio,www-data,video,plugdev,games,users,input,netdev pi

# for Raspberry PI add gpio i2c spi

  1. $  sudo usermod -aG  adm,dialout,cdrom,sudo,audio,www-data,video,plugdev,games,users,input,render,netdev,gpio,i2c,spi pi
  1. $ groups pi

# reboot, login pi (skip this step if you are already logged in as pi user)

  1. $ sudo reboot
login as: pi
pi@192.168.1.11's password:
  ___      _           _     _    ____ _  _
 / _ \  __| |_ __ ___ (_) __| |  / ___| || |
| | | |/ _` | '__/ _ \| |/ _` | | |   | || |_
| |_| | (_| | | | (_) | | (_| | | |___|__   _|
 \___/ \__,_|_|  \___/|_|\__,_|  \____|  |_|

Welcome to Armbian 21.05.2 Focal with Linux 5.10.34-meson64

System load:   45%              Up time:       0 min
Memory usage:  4% of 3.73G      IP:            192.168.1.11
CPU temp:      42°C             Usage of /:    10% of 14G
RX today:      31.0 MiB

[ 0 security updates available, 4 updates total: apt upgrade ]

To run a command as administrator (user "root"), use "sudo ".
See "man sudo_root" for details.

pi@odroidc4:~$

# your linux distro is now ready

# click the link below to follow our tutorials and build the MusicLounge Audiophile Server

BUILD THE MUSICLOUNGE AUDIOPHILE DISTRO

MISC: Tips & Tricks


# RANDOM LINUX TIPS & TRICKS


# Get INFO/VERSION

# Raspberry PI model / revision / serial

  1. $ cat /proc/device-tree/model
  1. $ cat /proc/cpuinfo

# SN#:

  1. $ cat /proc/cpuinfo | grep Serial | cut -d ' ' -f 2

# 10000000XXXXXXXX


  1. $ cat /proc/asound/version
  1. $ dpkg -l alsa*

# Kernel version

  1. $ uname -a

# fedora update kernel/system

  1. $ dnf -y update && dnf -y upgrade

# For example, to add the user linuxize to the sudo group you would run the following command:

  1. $ sudo usermod -a -G sudo linuxize

# Configure to boot into Raspbian Desktop

  1. $ sudo raspi-config

# use your arrow keys to navigate to Enable Boot to Desktop and press enter. Select the Desktop login option and press enter.

# Configure to boot into Raspbian Desktop (without raspi-config)

  1. $ sudo update-rc.d lightdm disable

# Raspberry testing repository

# replace buster by testing in /etc/apt/sources.list

  1. $ sudo nano /etc/apt/sources.list

# # from
# deb http://raspbian.raspberrypi.org/raspbian/ buster main contrib non-free rpi
# # to
# deb http://raspbian.raspberrypi.org/raspbian/ bullseye main contrib non-free rpi

  1. $ sudo apt update

# check if process is locked

  1. $ ps aux | grep -i apt

# kill process (replace pid_id by the process ID number)

  1. $ sudo kill pid_id

# check if killed

  1. $ sudo kill -9 pid_id

# Disable DEBIAN 10 GUI:

  1. $ sudo systemctl set-default multi-user.target
  1. $ sudo reboot

To re-enable the GUI:

  1. $ sudo systemctl set-default graphical.target
  1. $ sudo reboot

# activate raspberry pi WIFI

  1. $ sudo raspi-config

# Select “Localisation Options” then select “change WLAN country”

# then enter root

  1. $ sudo su

# generate wpa_passphrase using your SSID and followed by typing the wifi password
# replace YOUR-SSID by the exact name of your wifi network name

  1. $ wpa_passphrase "YOUR-SSID" >> /etc/wpa_supplicant/wpa_supplicant.conf

# check if the configuration is okay

  1. $ sudo nano /etc/wpa_supplicant/wpa_supplicant.conf

# should contain something like this:
# the country= must contains a 2 letters ISO 3166-1 of your country code

  1. ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
  2. update_config=1
  3. country=GB
  4. # reading passphrase from stdin
  5. network={
  6. ssid="YOUR-SSID"
  7. psk=47abc8153891372573fc831a0bab0346b07cb900ada28dc52686359cc60ab9e7
  8. }

# network IP info

  1. $ ifconfig

# scan wifi network

  1. $ sudo iwlist wlan0 scan

# power OFF / ON HDMI raspberry pi

# hdmi OFF

  1. $ sudo /opt/vc/bin/tvservice -o

# hdmi ON

  1. $ sudo /opt/vc/bin/tvservice -p

# AMD64 Useful Cmds

# get hostname

  1. $ hostnamectl

# set hostname

  1. $ sudo hostnamectl set-hostname musiclounge
  1. $ sudo nano /etc/hosts

127.0.0.1 localhost
127.0.1.1 musiclounge

# The following lines are desirable for IPv6 capable hosts
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

  1. $ sudo reboot

# Check your current Ethernet connection speed

# install ethtool utility

  1. $ sudo apt-get install ethtool

# determine the name of your ethernet interface usually eth0 or enp3s0

  1. $ ip a

# get the speed

  1. $ sudo ethtool eth0 | grep -i speed

# get current playback info useful to check if current playback is DSD native (DSD_U32_BE)

  1. $ cat /proc/asound/card*/pcm*p/sub*/hw_params

# in case you have to entry commands from the server console and not from remote PC/SSH session
# you may want to change the keyboard layout
# use the followinf cmd on debian

  1. sudo dpkg-reconfigure keyboard-configuration

Multi Room Audio Configuration

Multi Room Audio Configuration

# if you intend to create a multi-room audiophile configuration sharing the same music library on your LAN network
# Use the script below to configure your audio server very easily.
# change the hostname manually

  1. $ sudo nano /etc/hosts
  2. $ sudo nano /etc/hostname
  3. $ sudo nano /etc/minidlna.conf
  4. $ sudo nano /etc/upmpdcli.conf
  5. $ sudo nano /etc/shairport-sync.conf
  6. $ sudo nano /etc/raspotify/conf

# in Edition 2021 raspotify config (/etc/default/raspotify)
# and docker spot image must be changed as well, see the script 2021 below


# change hostname by script
# create the script in scripts directory

  1. $ sudo nano ~/scripts/musicloungerenamer2023.sh

# SCRIPT EDITION 2023
# insert these lines (copy then right-click on ssh session)

#!/bin/bash

# File: musicloungerenamer.sh
# Author: Linux Audio Foundation
# Requirements: MusicLounge Audiophile Distro
# Link: https://linuxaudiofoundation.org/musiclounge-multi-room-audio-configuration/
#
# get current arch
arch=$(dpkg --print-architecture)

# check if run as root
if [ "$(id -u)" -ne 0 ]; then
echo "This script must be run by root" >&2
exit 1
fi

CURR_HNAME=$(cat /etc/hostname)

NEW_HOSTNAME=$1
NEW_HOSTNAMELOW=${NEW_HOSTNAME,,}
echo "current hostname: ${CURR_HNAME}" >&2
echo "new hostname: ${NEW_HOSTNAME}" >&2

# empty new hostname
if [ -z "${NEW_HOSTNAME}" ]; then
echo "error: hostname (first parameter) is empty!" >&2
exit 1
fi

# no change
if [ "${CURR_HNAME}" == "${NEW_HOSTNAME}" ]; then
echo "Same host name exit with no change." >&2
exit 1
fi


# mini dlna cfg
sudo sed -i "s/$CURR_HNAME/$NEW_HOSTNAME/I" /etc/minidlna.conf
echo "minidlna service changed to: ${NEW_HOSTNAME}" >&2

# upmpdcli (upnp)cfg
sudo sed -i "s/$CURR_HNAME/$NEW_HOSTNAME/I" /etc/upmpdcli.conf
echo "upnp service changed to: ${NEW_HOSTNAME}" >&2

# air play cfg
# nothing to do as general section contains name = "%H" which is current hostname
sudo sed -i "s/$CURR_HNAME/$NEW_HOSTNAME/I" /etc/shairport-sync.conf
echo "AirPlay service changed to: ${NEW_HOSTNAME}" >&2

# spotify connect amd64 cfg
sudo sed -i "s/$CURR_HNAME/$NEW_HOSTNAME/I" /etc/raspotify/conf
echo "Spotify Connect (armhf/arm64) service changed to: ${NEW_HOSTNAME}" >&2

# hostname cfg
sudo sed -i "s/$CURR_HNAME/$NEW_HOSTNAMELOW/g" /etc/hostname

# hosts
sudo sed -i "s/$CURR_HNAME/$NEW_HOSTNAMELOW/g" /etc/hosts

echo "hostname and hosts changed to: ${NEW_HOSTNAMELOW}" >&2

# ask before rebooting
while true; do
read -p "Hostname and services have been changed for ${NEW_HOSTNAME}, reboot for the change to take effect (y / n)? " yx
case $yx in
[Yy]* ) sudo reboot; break;;
* ) exit;;
esac
done

# CTRL+O to save
# CTRL+X to exit
# change permision

  1. $ sudo chmod +x ~/scripts/musicloungerenamer2023.sh

# SCRIPT EDITION 2021
# change hostname by script
# create the script in scripts directory

  1. $ sudo nano ~/scripts/musicloungerenamer2021.sh

# insert these lines (copy then right-click on ssh session)

#!/bin/bash

# File: musicloungerenamer.sh
# Author: Linux Audio Foundation
# Requirements: MusicLounge Audiophile Distro
# Link: https://linuxaudiofoundation.org/musiclounge-multi-room-audio-configuration/
#
# get current arch
arch=$(dpkg --print-architecture)

# check if run as root
if [ "$(id -u)" -ne 0 ]; then
echo "This script must be run by root" >&2
exit 1
fi

CURR_HNAME=$(cat /etc/hostname)

NEW_HOSTNAME=$1
NEW_HOSTNAMELOW=${NEW_HOSTNAME,,}
echo "current hostname: ${CURR_HNAME}" >&2
echo "new hostname: ${NEW_HOSTNAME}" >&2

# empty new hostname
if [ -z "${NEW_HOSTNAME}" ]; then
echo "error: hostname (first parameter) is empty!" >&2
exit 1
fi

# no change
if [ "${CURR_HNAME}" == "${NEW_HOSTNAME}" ]; then
echo "Same host name exit with no change." >&2
exit 1
fi

# hostname cfg
sudo sed -i "s/$CURR_HNAME/$NEW_HOSTNAMELOW/g" /etc/hostname

# hosts
sudo sed -i "s/$CURR_HNAME/$NEW_HOSTNAMELOW/g" /etc/hosts

echo "hostname and hosts changed to: ${NEW_HOSTNAMELOW}" >&2

# mini dlna cfg
sudo sed -i "s/$CURR_HNAME/$NEW_HOSTNAME/I" /etc/minidlna.conf
echo "minidlna service changed to: ${NEW_HOSTNAME}" >&2

# upmpdcli (upnp)cfg
sudo sed -i "s/$CURR_HNAME/$NEW_HOSTNAME/I" /etc/upmpdcli.conf
echo "upnp service changed to: ${NEW_HOSTNAME}" >&2

# air play cfg
# nothing to do as general section contains name = "%H" which is current hostname
sudo sed -i "s/$CURR_HNAME/$NEW_HOSTNAME/I" /etc/shairport-sync.conf
echo "AirPlay service changed to: ${NEW_HOSTNAME}" >&2

# spotify connect armhf & arm64 cfg
if [ "amd64" != "$arch" ]; then
# armhf and arm64
sudo sed -i "s/$CURR_HNAME/$NEW_HOSTNAME/I" /etc/default/raspotify
echo "Spotify Connect (armhf/arm64) service changed to: ${NEW_HOSTNAME}" >&2
fi

# docker spot container on amd64 cfg
if [ "amd64" == "$arch" ]; then
# read -p "Press any key to stop Spotify Connect service"
sudo docker ps -q --filter "name=spot" | grep -q . && docker stop spot && docker rm -fv spot
# read -p "Press any key to change the new of Spotify Connect to ${NEW_HOSTNAME}"
export SPOTNAME=$(echo "NAME=${NEW_HOSTNAME}")
sudo docker run -d --restart unless-stopped \
--name "spot" \
--env $SPOTNAME \
--volume /tmp \
--group-add audio \
--device /dev/snd \
--net host \
--cap-drop ALL \
--read-only \
dubodubonduponey/librespot \
--backend alsa \
--device plughw:1,0 \
--disable-audio-cache \
--initial-volume=100
echo "Spotify Connect (Docker amd64) service changed to: ${NEW_HOSTNAME}" >&2
fi

# ask before rebooting
while true; do
read -p "Hostname and services have been changed for ${NEW_HOSTNAME}, reboot for the change to take effect (y / n)? " yx
case $yx in
[Yy]* ) sudo reboot; break;;
* ) exit;;
esac
done

# CTRL+O to save
# CTRL+X to exit

# change permision

  1. $ sudo chmod +x ~/scripts/musicloungerenamer2021.sh

# we suggest a name which identify the room easily like a Music or Audio prefix + the room name (e.g MusicBedroom, MusicLivingroom, MusicKitchen,…)
# run the script with the audio server name in parameter, example:

  1. $ cd scripts/
  2. $ sudo ./musicloungerenamer.sh MusicKitchen

# type y to reboot the server
# that’s it!

TROUBLESHOOTING: Boot Fall Into BusyBox (initramfs)

# after downloading and install (clone) the image disk onto your hard drive (/dev/sda),
# falling into BusyBox (initramfs) during boot is easy to fix
# boot using gparted live and open terminal with sudo permission

# create mount directory

  1. root@debian:~# mkdir /mnt/temp

# sudo fdsik -l /dev/sda may help your to identify root and boot partition
# mount root partition

  1. root@debian:~# mount /dev/sda3 /mnt/temp

# mount boot partition

  1. root@debian:~# mount /dev/sda4 /mnt/temp/boot

# bind all others

  1. root@debian:~# mount --bind /dev /mnt/temp/dev
  1. root@debian:~# mount --bind /dev/pts /mnt/temp/dev/pts
  1. root@debian:~# mount --bind /proc /mnt/temp/proc
  1. root@debian:~# mount --bind /sys /mnt/temp/sys

# chroot mounted partition

  1. root@debian:~# chroot /mnt/temp

# update initramfs

  1. root@debian:/# update-initramfs -u
update-initramfs: Generating /boot/initrd.img-6.1.0-7-amd64
W: No zstd in /usr/bin:/sbin:/bin, using gzip

# update grub

  1. root@debian:/# update-grub
Generating grub configuration file ...
Found background image: mdl_splash.png
Found linux image: /boot/vmlinuz-6.1.0-7-amd64
Found initrd image: /boot/initrd.img-6.1.0-7-amd64
Found linux image: /boot/vmlinuz-6.1.0-3-amd64
Found initrd image: /boot/initrd.img-6.1.0-3-amd64
Warning: os-prober will not be executed to detect other bootable partitions.
Systems on them will not be added to the GRUB boot configuration.
Check GRUB_DISABLE_OS_PROBER documentation entry.
done
  1. root@debian:/# exit
  1. root@debian:/# sudo reboot

# optional: as soon as you boot normally repeat the last 2 commands to update initramfs and grub

# also, if cannot boot, use the gparted live option to boot local system and reinstall grub

  1. root@debian:/# sudo grub-install /dev/sda

# that’s it!