IT-LINUXMAKER, OpenSource, Tutorials

Preliminary installation of the Raspberry PI OS

Auch wenn wir uns hier für die Installation mit dem Projekt von Ronald Raike entscheiden, dann brauchen wir zunächst ein Raspberry Pi OS passend zu unser Raspberry Pi-Platine. 
Even if we decide to install with Ronald Raike's project, we first need a Raspberry Pi OS that matches our Raspberry Pi board. Until now, you could download images from the Raspberry Pi project and write them to an SD card as root using the Linux dd command. We need the Lite version for this.

fdisk -l

provides a list of disks and connected SD cards, which can be accessed immediately after connection via

dmesg

could see. We need this information in the next step.

~# unxz 2025-05-06-raspios-bookworm-armhf-lite.img.xz | dd bs=4M of=/dev/sdf status=progress

We unpack the image with unxz and pipe it directly to the detected SD card. We use the bs=4M option to increase the block size when writing – this significantly speeds up the copy process. Using dd, the unpacked image is written directly, without buffering, to the /dev/sdf device we previously identified. Additionally, we can display the status of the copy progress.

Alternative with the Raspberry PI Imager

Easier, and especially for Windows candidates, is the  Raspberry PI Imager, which is available as a Debian package, as an EXE file, and as an Apple Disk Image. This is significantly more performant and user-friendly if you only use the terminal under Linux if you only need to start in the terminal under Linux 

~$ rpi-imager

to launch an application window. Here, you select the Raspberry Pi OS, the board, and the SD card. You can also configure all the necessary settings (hostname, username, password, Wi-Fi, SSH, etc.) in advance. Starting the program will then create a fully functional SD card for the Raspberry Pi. In the first version, after the first login, typing "pi" with “raspberry”, you would need to run the

~$ sudo raspi-config

command to configure the Raspberry Pi for the first time. This way, you can even log in via SSH immediately after booting.

 

Adjusting the operating system and backup

Now you can log in to the Raspberry Pi via SSH or locally with your chosen username—or by default with 'pi' and the password 'raspberry'. Currently, I only have a standard installation, which is missing many tools like rsync, vim, postfix, ufw etc., as well as my .bashrc for root and user. Furthermore, the external USB drive we want to use for /var and /home is still missing. Furthermore, I personally find the sudo command annoying on servers that I administer myself. This is a security measure introduced by Ubuntu Linux to make Linux more user-friendly for end users.

Enabling root login

With this sequence you can easily login as user root

~$ sudo su -
~# passwd

After entering a secure password twice, you can now log in directly as root, which is much more convenient in a server environment.
You can then install all the programs you generally need to work on your servers.

Useful packages for administration, support and debugging

These tools are virtually indispensable for operating, supporting, and debugging Asterisk systems. They are not part of Asterisk itself, but in practice they are almost always used on production Asterisk servers.

~# apt -y install net-tools htop screen tshark sngrep mailutils

Preparing the directories /var and /home on USB disk

The disadvantage of SD cards when subjected to frequent write loads has already been mentioned, so we attach a USB disk that we have previously set up with two or more partitions using Gparted or fdisk and formatted with ext4.

On the Raspberry Pi we first search for the partitions

~# blkid
/dev/mmcblk0p1: LABEL_FATBOOT="bootfs" LABEL="bootfs" UUID="F615-3D6A" BLOCK_SIZE="512" TYPE="vfat" PARTUUID="b0477b82-01"
/dev/mmcblk0p2: LABEL="rootfs" UUID="8f6cdea4-22b2-47be-88eb-087a00e3ee2b" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="b0477b82-02"
/dev/sda2: LABEL="home" UUID="58efaf89-6eca-4b45-9001-f5697babfba0" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="6231394e-04"  
/dev/sda1: UUID="918d28c6-f68e-4a10-badb-10f317b68ebb" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="6231394e-01"

These UUID values ​​are inserted into /etc/fstab

~# echo "UUID=\"918d28c6-f68e-4a10-badb-10f317b68ebb\"     /var    ext4    defaults        0       2" >> /etc/fstab
~# echo "UUID=\"58efaf89-6eca-4b45-9001-f5697babfba0\"     /var    ext4    defaults        0       2" >> /etc/fstab
~# systemctl daemon-reload

With the following workaround we transfer all previously recorded data from /var on the SD card to the future /var on the USB disk

~# mount /dev/sda1 /mnt/
~# cd /mnt/
~# rsync -arv /var/* /mnt/
~# cd -
~# umount /mnt
~# mount -a

With the final mount command, the two partitions of the USB drive are now mounted as required and will now be used instead of the respective directories on the SD card. This contributes to a longer lifespan of the card and the operating system.

In principle, we've already taken a crucial step toward a backup. The database and spool directories for Asterisk are located below /var and thus on the external USB drive. And the SD card itself is removable.

Backup of the previous installation

To avoid having to repeat this preparatory installation step again and again, either because the SD card has failed or because we encounter errors and problems during the subsequent installation, my favorite approach is to create a backup of the current status quo in the form of an image. To do this, we'll run these commands.

~# dmesg
~# dd if=/dev/sdf of=RaspberryPI_clean.img bs=4M status=progress

The first is used to determine the device name of the SD card, and the second is used to create an image of the SD card. A backup SD card (same size as the original SD card) is created as follows:

~# dmesg
~# dd if=RaspberryPI_clean.img of=/dev/sdg bs=4M status=progress

This means we are prepared for any failures and can start with the actual installation of our Asterisk server on a Raspberry Pi.


IT-LINUXMAKER, OpenSource, IT-Support, IT-Consulting

© IT-LINUXMAKER 2025