Lxd/Lxc the containers in the wild [2024 version]

The other container solution Normaly we only think about docker containers if we want to containerize something in linux. But there are more options lxd/lxc is one of those other solutions. Where docker containers are mostly used to start one process, lxd containers are more like containerized vm’s How to install it sudo pacman -S lxd or sudo apt install lxd-installer or sudo snap install lxd –channel=latest/stable Add your user to the lxd group in /etc/group and restart lxd
3 minutes to read

loop device mount partitions

If you have a disk image with multiple partitions, this type of image is used a lot for the raspberry pi, you can easily mount them using kpartx, you can install kpartx as follows

arch linux / manjaro sudo pacman -S multipath-tools # ubuntu 24.04 sudo apt install kpartx # centos 8 / oracle sudo yum install kpartx Maybe you need to insert the loop module, if so you can do that like this

One minute to read

Selinux Short

I few shorts remarks about selinux, more like a reminder for myself Restore directory permissions, exmple authorized keys files that doesn’t work restorecon -R -v ~/.ssh How to temporarily disable selinux, i use this for debugging to see if the problem is selinux echo 0 >/selinux/enforce # or setenforce 0 And to enable them again use echo 1 >/selinux/enforce # or setenforce 1
One minute to read

Split a mysql dump in databases

Hello, I once needed to split a mysql dump in to multiple files, one per database so i used this awk one liner. awk -F'`' '{if ($0 ~ /^– Current Database:/) db=$2; print >> db"-split.sql"}' mysql_dump.sql If you need to split one table from one database you can try the following bash scripts !/bin/bash export DATABASE="$1" export TABLE="$2" echo $DATABASE echo $TABLE awk '/Table structure for table .'$TABLE'.$/,/UNLOCK TABLES/{print}' $DATABASE-split.sql
One minute to read

Control cec_client as daemon on pi4

I wanted to control the my television and blu ray player/receiver from my pi, so i installed the client on my raspbian pi installation. Everytime cec_client start it’s does some initializing, so i wanted to run is as some kind of daemon, i thought about a fire options, like maybe some expect kind of script without daemoniziing or a python with python expect to run it and control it, with mayne a socket.
2 minutes to read

reattach ssh or script to new tty

Once in a will you need you have a lang running script that you started into a shell but you want to transfer it to a screen. For this i am using the reptyr program which i installed with sudo pacman -S reptyr or sudo apt-get install reptyr find pid ps ax | grep ssh # find pid 34177 (for example) # start a screen screen -S my_screen_name # in de screen start reptyr reptyr 34177 if you get a issue with ptrace scope just change this value echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope
One minute to read

Screen or Daemontools

If you want to start some daemon in the background you can install daemontools and user supervise, but i like to use screen to start daemons in the background, so that i can easily see the output.

check screen if ! /usr/bin/screen -ls | awk '{print $1}' | grep ".${SCREEN_NAME}$" >/dev/null; then echo "starting $SCREEN_NAME" screen -S "${SCREEN_NAME}" -d -m "$COMMAND_SCRIPT" fi I use this snippet, to check of a screen with a given name exists and if not start it up, i run a script i call screen-ls.

4 minutes to read

Boot Raspberry Pi over NFS

The Raspberry Pi is typically booted from an SD card which contains the bootloader and the root partition. This can be limiting from a space and speed perspective,and writes to the card will slowly cause it’s death. SD media doesn’t typically use the same wear leveling technology that goes into a solid state drive. Today I’ll take a quick look at how you can boot your Pi from an NFS server.
One minute to read

On-demand activation of Docker containers with systemd

On-demand activation of Docker containers with systemd One of the features of systemd is its ability to defer the start-up of networked applications until their services are actually requested, a process referred to as socket activation. This isn’t really a new an idea; systemd borrowed the idea from launchd which has been in OS X since Tiger’s release in 2005, and the venerable Unix inetd has implemented a simpler version of it since the 1980s.
One minute to read