RAM disk on boot

I will come back and provide some context about why i need this later, for now, if you want your PC to take away some ram and make a RAM disk, you have two ways, I would go with the first

The easy way (tmpfs)

Start by creating a directory to mount the ram disk onto

sudo mkdir -p /hds/ram

Then just add a line like the following to the /etc/fstab file

tmpfs /hds/ram tmpfs defaults,size=80G 0 0
Or, the more elaborate
tmpfs /hds/ram tmpfs rw,noatime,nosuid,nodev,noexec,size=80G,mode=0755 0 0

Now mount it
sudo mount -a (To avoid having to restart)

If you have a dual CPU setup, I recommend you check out NUMA tuning before playing with this

The other way (ramfs)

You will not see real world gains in speed, they are super marginal, and you lose a lot of features like swapping ! Also, it eats up all the ram in advance, ram that could have been used for caching
If you must, it is the same as above, but the line in fstab is the following instead

ramfs /hds/ram ramfs rw,noatime,nodev,nosuid,noexec 0 0

Notes:

1- “df -h” will report an 80 GB disk, even though they are not missing from ram, it is an upper limit, not a pre-alocated space

2- noatime doesnโ€™t matter much, on a ram disk, it is a neglegible load, I add it anyways because none of my applications can make use of ti

3- noswap : swapping a ram disk is probably the worst idea ever ! so you may want to consider

tmpfs /hds/ram tmpfs rw,noatime,nosuid,nodev,noexec,noswap,size=80G,mode=0755 0 0

4- NUMA tuning

Now, to keep all the ram on one CPU, while still allowing it to spill over to the ram from th other CPU when needed, you can pin the process to a CPU and make the ram of that CPU preferred !

Here is an example, if you intend to use the disk with MySQL, you would do as follows

1- Make sure the daemon is called mysql

systemctl status mysqld

2- Create an override file
sudo systemctl edit mysql

3- Add NUMA binding (Empt line means “Clear the existing startup command first”)
[Service]
ExecStart=
ExecStart=/usr/bin/numactl –cpunodebind=1 –preferred=1 /usr/sbin/mysqld

sudo systemctl daemon-reload

sudo systemctl restart mysql

ps aux | grep mysqld

An alternative to all the above would be to pin it to CPUs !

[Service]
CPUAffinity=16-31

The rest is just like the other method

Fix Debian hum/buzz in speaker after a few seconds

On my system, whenever no sound comes out of the speakers for a bit, the speaker starts humming, the same sound that comes out of it when my PC is switched off

In my case, I am using Debian 13 with gnome

What is that sound

That sound is basically the speaker picking up the power line frequencies, and because it is an amplified speaker, it amplifies it, and makes it audible !

Why does it come out from my PC after some time

There are two audio drivers for linux, PulseAudio/ALSA and PipeWire, both supporting power saving mode, when no audio comes out of the speaker for some time, power saving mode kicks in, the sound chip (FKA the sound card) is disabled, so you get that sound exactly as if your computer was switched off !

How do i fix it ?

Disable power saving mode is the simplest method !

To disable it for this session, which works instantly, run the command

echo "0" | sudo tee /sys/module/snd_hda_intel/parameters/power_save

To make that change permanent (Later reboots)

sudo tee /etc/modprobe.d/snd-hda-intel.conf <<< "options snd_hda_intel power_save=0"

Sanity check for BZ2 files before decompression

To check if a file integrity is intact without expanding it, you can try the obvious send to /dev/null or use a built in equivilent

bzip2 -dc file.bz2 > /dev/null
bzip2 -tv file.bz2

Now, the problem can be that the split files were not complete ! so when i executed

cat file.bz2.001 file.bz2.002 file.bz2.003 file.bz2.004 > file.bz2

I thought that 004 was the last part, but it was not, how can i know without wasting CPU cycles ! let me show you

NOTE: If you have not yet concatenated the files, you can do the header checks on the first file, and the footer checks on the last ๐Ÿ˜‰ in my case, I already have them concatenated (Not a problem, i can add more files to it later) so i am doing both checks on the same file

Check the header, Every bzip2 file starts with: 42 5a 68 xx

head -c4 file.bz2 | hexdump -C

Should result in

00000000  42 5a 68 39                                       |BZh9|

And it does

But when i check the footer with the command

tail -c64 file.tar.bz2 | hexdump -C

The first line of that output should be

00000000  17 72 45 38 50 90 00 00  00 00 00 00 00 00 00 00  |.rE8P...........|

But it is not, in my case it was

00000000  e4 fc 2e 36 2f e7 d5 bf  74 d5 3b 0f ef 4a 61 15  |...6/...t.;..Ja.|

Which looks like random compressed data

In conclusion, I should find all the other parts to be concatinated to this before wasting time decompressing it

Gnome calculator freezes instantly

Well, the calculator that ships with Gnome would launch instantly, then freeze instantly, I would then have to keep clicking the (x) in the corner and wait for the OS to suggest killing the app

No matter how long I wait on the app, it won’t budge, you can’t even move it around the screen

Turns out the calculator works if I am not connected to the internet (Pull the Ethernet cable out)

The solution was simple, it seems the calculator freezes waiting for data from the internet, when there is no internet, it skips the step

The solution was simple, it goes online for currency conversion rates, something i never use, so the solution is to execute the following command to stop it from doing that

dconf write /org/gnome/calculator/refresh-interval 0

Yup, that is it, the calculator works perfectly now

Audio breaking and noisy on debian 12

I am not sure that this problem is specific to my setup, where my audio comes from an nvidia 1650 passed through to a KVM virtual machine, but it seems that many people on bare metal are having this problem too

The problem occures randomly, and when it does, pipewire would be consuming a lot of CPU even though no audio is running

pipewire for those of you who don’t know is the new pulse audio, it comes with most modern distributions !

The solution when this happens for now sems to be to restart pipewire !

systemctl --user restart pipewire.service

SSH tunnel for VNC

If you were on a linux machine, it would be as simple as

ssh -L 5901:localhost:5901 root@192.168.7.119

Just kidding, don’t login as root, it is all just for tunneling, replace root and the IP of my super top secret server with something suitable

On windows, the most popular SSH client is putty, and to do that in putty, follow the following steps

Open putty, then enter the IP address or hostname of the remote machine

Editing Music ID3 tags

id3 tags were meant to be a simple way to store metadata in MP3 files, slowly but steadily, things became a bit more complicated

Originally, ID3 tags were meta data near the end of a file, then ID3V2 came along, and meta tags were moved to the beginning (With an ID3V1 copy at the end added by most ID3 editors)

Album artwork is another complication, As it may be embedded in the file, An older method used to depend on keeping an image called “cover.jpg” in the folder where the file is stored.

You can also have “user-defined fields”, which can be helpful if you are developing a music player that has some novel ideas

ID3 tag information can be obtained from gnudb.org, MusicBrainz, Discogs, Amazon

Gnome

  • EasyTAG: GIT = tag editor for MP3, Ogg Vorbis files and more
    Written in C,
    Dep: libid3-3.8.3v5 libid3tag0 libopusfile0 – Suggested: libid3-tools

KDE

  • KID3

LINUX Command Line

  • id3:
  • id3edit: GIT = id3edit is a command line ID3v2 tag editor and debugger

Windows

  • MP3TAG: Freeware (Not free as in freedom), But great software nonetheless ๐Ÿ˜‰

Copy KVM virtual machine

This is much simpler than you’d expect (provided there are no hardware passthoughs, and there usually isn’t), All you need to do is copy both the Disk and the XML file (Typically in /etc/libvirt/qemu) then

1- edit the following in the XML file

Create a new virtual machine ID

uuidgen

Create new MAC addresses for every network adapter

https://olavmrk.github.io/html-macgen/

Change the path to the disks to point to where you put the new copy of the disks

Thats it, now you need to tell KVM about it so….

2- Tell KVM about the new definition with the define function

virsh define /etc/libvirt/qemu/newxmlfile.xml

Mounting various image files in Linux

Hyper-v disk files, with extensions such as vhdx and vhd can be mounted under linux directly with the libguestfs-tools tool, mind you, many packages will be installed… mostly libraries relating to the formats it is capable of mounting

sudo apt-get install libguestfs-tools

Now, the following command should mount the disk inside the virtual machine

guestmount --add diskname.vhdx --inspector /mount/dir/name

If the system does not detect a system, you will need to tell guestmount what partition to mount, to explore the partitions, you will need ….

 virt-filesystems -a disk.vhdx

Once you know your partitions

guestmount --add disk_d.vhdx -m /dev/sda1  /hds/loop

If you would rather mount the disk as read only, you can add the –ro switch

guestmount --add yourVirtualDisk.vhdx --inspector --ro /mnt/anydirectory

To unmount, you will need to use the following command

guestunmount /mnt/anydirectory

Sunshine and moonlight

VNC and RDP are great and all, and for so many purposes, they are the goto solution for remoting into a machine.

Now, another solution which is great (And much better if you have the bandwidth) is to broadcast your screen video and do all the work on the server rather than the client

The solution used to be nvidia’s game stream, which was abandoned by nvidia, the new solution based on nvidia would be the sunshine (Server) and moonlight client

The sunshine+moonlight duo work on almost every platform I need, Windows, Mac, Android, iOS, Even LG TVs running web OS… in short, it is a more universal solution. You can even create a virtual non existent monitor under linux and stream that to a different device !

So, let us start with the server (Sunshine)

Sunshine on debian

Installing sunshine on debian is very easy as a .deb installation file is provided, sunshine is not yet in the debian repositories, but if i understand the license correctly, it can be some time in the future

Now, go to the sunshine website, and download the deb file., in my case, I visit this webpage, and download the sunshine-debian-bookworm-amd64.deb file

Now, from the command prompt, su (to run as root), then cd to the directory where your deb file resides, then “sudo apt install ./sunshine-debian-bookworm-amd64.deb”, We should now have the server running and waiting to be opened in the web browser, Now, on the command line , type “sunshine”

Point a web browser to https://localhost:47990/, ignore the problem with self signed certificates, and set your username and password

Now, your debian computer is running a sunshine server, go to any other machine where you want to install the client (moonlight) from here , and connect to your server by its IP address.

You are done !

Sunshine on Windows

Download sunshine on windows from the latest release (As of today, you will fine it here)

Install it like you would any other application, once done, the official help page will show up (this)

once you click finish, a page at https://localhost:47990/welcome will open, asking you to create a password, create one, the default username is sunshine, but you can use whatever you want (In my case, it is my default RDP password)

you are done, you can now access the windows PC from any device with moonlight

Moonlight on Windows

you can download moonlight ether from github (Here) or from the official website (https://moonlight-stream.org/),