Jump to content
IGNORED

Linux OS booted to RAM


bodiebill

Recommended Posts

I have been experimenting with light Linux distros and ended up some time ago to using the minimal (even GUI-less) version of Ubuntu 17.04 with MPD and upmpdcli. I am using Audirvana+ on another PC (Windows) to send DSD to the Linux box and SQ is great.

 

Lately I was looking to improve this further by trying to get the Linux OS fully run in RAM.

 

I tried this with Puppy Linux booted from a usb stick and by default loaded into RAM. This has an elegant way of making changes persistent by saving them after each session to a file that is used for the next boot. While playing music the usb stick can be removed. However, I have not been succesful so far to install MPD or upmpdcli with Puppy.

 

I did succeed to make it work with Lubuntu 18.04 using this method:

https://calvin.me/create-persistent-ubuntu-16-04-live-usb-even-boots-ram/

The sound is really good (better?).

I did not dare removing the usb stick during play in this case, and I don't know whether this would make a difference SQ wise... 

 

Any recommendations? 

 

audio system

 

Link to comment

Thanks Miska, I will look into both scenarios.

 

Regarding the microSD card: by 'tiny adapter' do you mean one that can be inserted in a usb port?

 

Running the OS in RAM and using MPD so far only succeeded with (l)ubuntu desktop which obviously has a GUI.

Alas, 'Minimal CD' ubuntu cannot be used for the Calvin recipe above.

Again, Puppy Linux looks great as it even has an option in the boot menu to boot without GUI, but no success with MPD so far.

 

So I will continue to look for a distro that can be run in RAM without GUI and enables MPD and upmpdcli...

Maybe I can try some Debian-derived OS from:

https://en.wikipedia.org/wiki/List_of_Linux_distributions_that_run_from_RAM

 

 

audio system

 

Link to comment
28 minutes ago, bodiebill said:

Regarding the microSD card: by 'tiny adapter' do you mean one that can be inserted in a usb port?

 

Yes, exactly, sometimes those adapters come with microSD card.

 

29 minutes ago, bodiebill said:

Running the OS in RAM and using MPD so far only succeeded with (l)ubuntu desktop which obviously has a GUI.

 

But if you boot the minimal GUI-less OS from something like microSD you don't need to worry about the "OS in RAM" part.

 

33 minutes ago, bodiebill said:

 

Of those I only know Knoppix and Tails. Knoppix has existed for quite long time already. Tails is RAM-based for security reasons and became more well known thanks to Snowden.

 

Signalyst - Developer of HQPlayer

Pulse & Fidelity - Software Defined Amplifiers

Link to comment

After some hit and miss trials, I finally managed to get a Linux pc working with mpd and upmpdcli, with the full OS booting into RAM. I first followed Miska’s advise and installed Arch Linux on a 16GB microSD card. I used pacman to install mpd and then yay to install upmpdcli and ramroot. All works well and booting into RAM is a clear step up in SQ! Booting takes time, but the system is much faster and when booted the stick can be removed if you like.

 

The recipe below is somewhat sketchy. Just let me know if anything is unclear, or whether it (wording or content) can be improved.

 

Arch Linux audio pc with mpd, upmpdcli and ramroot

 

Requirements: pc with minimum 4 GB RAM + 16GB usb stick or (micro)SD card. No hd or ssd needed!

 

OS
- note that installing Arch Linux is not a breeze; however these instructions worked well for me: http://valleycat.org/linux/arch-usb.html?i=1 

- install Arch Linux on a (micro)SD card or usb stick from a LiveCD using the above link
- name the machine <computername> and add user <username>
- set static ip address <ipaddress> using dhcpcd: https://willhaley.com/blog/static-ip-in-arch-linux/
- install openssh: https://linuxhint.com/arch_linux_ssh_server/
- ssh in from terminal with ssh <username>@<ipadress>

 

alsa
- install alsa-utils
- edit /etc/security/limits.conf by adding the following lines:
@audio - rtprio 99
@audio - memlock unlimited
@audio - nice -10 

 

mpd
- install mpd: pacman -S mpd
- assign mpd to the group audio: usermod -aG audio mpd
- systemctl start mpd
- systemctl enable mpd
- check with: systemctl status mpd

- make the directory for the music- and playlist files:
- mkdir /home/<username>/share/music /home/<username>/share/playlists
- set write permission: chmod 777 /home/<username>/share/music /home/<username>/share/playlists

 

samba (optional)
- install and configure samba: https://lampjs.wordpress.com/2018/08/10/setting-up-samba-sharing-server-on-arch-linux/ 

 

package helper
- install yay as user (not root): https://www.ostechnix.com/yay-found-yet-another-reliable-aur-helper/ 

 

upmpdcli
- install libupnp: pacman -S libupnp
- install upmpdcli and libupnpp from AUR: yay -S upmpdcli
- systemctl start upmpdcli
- systemctl enable upmpdcli
- check with: systemctl status systemctl

 

configure mpd for bit-accurate reproduction

- connect DAC & restart
- using the output of cat /proc/asound/cards (shows DAC ID), create /etc/mpd.conf for <computername> / <username> with the following content:

music_directory    "/home/<username>/share/music"
playlist_directory    "/home/<username>/share/playlists"
db_file    "/var/lib/mpd/tag_cache"
log_file    "/var/log/mpd/mpd.log"
pid_file    "/run/mpd/pid"
state_file    "/var/lib/mpd/state"
sticker_file    "/var/lib/mpd/sticker.sql"
group    "audio"
port    "6600"
follow_outside_symlinks    "yes"
follow_inside_symlinks     "yes"
zeroconf_enabled    "yes"
zeroconf_name    "<computername>"
audio_output {
        type    "alsa"
        name    "USB Audio"
        period_time    "8192"
        device    "hw:0,0"
        buffer_time    "131072"
        mixer_type    "disabled"
        auto_resample    "no"
        auto_format    "no"
        dop    "no"
}
filesystem_charset    "UTF-8"

- note: replace "hw:0,0" with the actual device ID; could be "hw:1,0".

 

- systemctl restart mpd
- if needed, debug / improve mpd.conf by running mpd
- test for bit-accurate reproduction via USB while playing a song: 
cat /proc/asound/<card1>/pcm0p/sub0/hw_params
(replace <card1> with your actual hw according to cat /proc/asound/cards) 
This should look like the following with a 24 bit / 176 kHz file:
access: RW_INTERLEAVED
format: S24_3LE
subformat: STD
channels: 2
rate: 176400 (176400/1)
period_size: 22050
buffer_size: 88200

 

ramroot
- install ramroot: https://www.ostechnix.com/ramroot-run-arch-linux-entirely-ram/ 
- note that nothing will be saved after reboot; when changes are needed, boot normally first

 

backups
- make system backup using rsync:
rsync -aAXv --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found"} / /media/backup
- clone disk: dd if=/dev/sda of=/dev/sdb bs=64K conv=noerror,sync status=progress

 

todo

consider replacing kernel with a real-time or lowlatency kernel? 

 

 

audio system

 

Link to comment
  • 2 weeks later...

Hi bodiebill.

 

Quite a guide you have made. It took me quite some time to manage to boot into ramroot.

I just have finished a small setup based on slax (debian) squeezelite and it works fantastic.

This might even be better regards no I/O's when running in ramroot mode.

 

Have you had time for further improvements. I'm logging quite some statistics (io,irq,kernel,user,idle) time

from /proc/stat , then it's easier to see if applied optimisations works.

 

I have added threadirqs to the GRUB_CMDLINE which lowered my IRQ time used.

 

Over the next couple of days, I'll make a RT-Kernel which I used to have on my debian setup.

 

Thanks for a great guide.

 

   

Link to comment

I am still happy with the Arch Linux setup which I now boot from a Mach Extreme MX-ES 3.0 usb stick which is much faster.

 

However I am now also experimenting with GentooPlayer which is less work and very promising. It has the advantages of built-in menu items, ability to choose between many real-time kernels, different alsa versions (1.0.29 is known for its great sound), built-in ramsystem (ramdisk) option and produces great SQ.

The next version will be out soon to include upmpdcli (which I installed manually on the current version). 

 

audio system

 

Link to comment

Could see you were posting on the GentooPlayer thread.

 

Before I try this out, always good trying different things out, do you know which linux kernel it uses ??

I need a fairly new one as I'll will get a Intel NUC8 which require a newer kernel, think it need to be as new

as the one ubuntu18.10 comes with.

 

I'm from Denmark and a lot of funny stuff isn't available, it's a small marked.

 

 

Link to comment

hi boriebill

I have it installed as I could see it was a fairly new kernel. I had been playing on it for a couple

of hours, will try to do the ramboot, when my backup of it is finished.

Took a little while to install, never tried gentoo before. I have some software which logs things from

/proc/stat to see what changes it makes when switching around with differents setups.

I'll post on the gentoo thread with my impressions.

I'm having a fairly new CPU Intel I5-7600T with 8GB DDR4 memory.

 

Thanks for your reply

 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...