Introduction
In this post you will see how to modify a Raspberry unmounted to make the changes required by the user and save them on a uSD card.
This is very useful to create custom images and replicate them in several industrial PLC controllers.
Requirements
Any of our Raspberry PLCs can be used here:

Raspberry Image >>
You can use an official one or one from our repository, already modified for our products.

Linux based PC
It will be the operating system used in this tutorial so it is much easier to interact with compared to Windows or Macintosh.
Step-by-step process
In this example, we will work with the following image of our repository:
https://apps.industrialshields.com/main/rpi/images/2022-01-28-raspios-bullseye-armhf-lite-raspberry-plc-v4-20220428174519.zip
1. Mount Raspbian partition
- Create a new mountpoint
mkdir mountpoint
- Find the Raspbian partition in the disk image (you must find here the start sector of the second partition (532480). In order to calculate the offset of the partition you have to multiply this number by 512 bytes.
file 2022-01-28-raspios-bullseye-armhf-lite-raspberry-plc-v4-20220428174519.img
- Mount partition
sudo mount 2022-01-28-raspios-bullseye-armhf-lite-raspberry-plc-v4-20220428174519.img -o offset=$[512*532480] mountpoint
2. Make changes in the Raspbian image
Here you can make all the required modifications to the image by directly accessing to the mountpoint folder previously created, where the mounted image is located. A couple of examples of changes can be the WLAN configurating or the enabling of the SSH server.
3. Unmount the disk image
When all the modifications are finished, you can unmount the image again.
sudo unmount mountpoint
4. Write the image
You can write the image as commonly to the uSD card (you must take into account that all the data will be lost at the device /dev/sdb):
sudo dd bs=4M if=2022-01-28-raspios-bullseye-armhf-lite-raspberry-plc-v4-20220428174519.img of=/dev/sdb
5. Flush the write cache
Before removing the uSD card, you must execute the following command:
sync
And wait for the prompt. If your computer has detected the new partitions at the uSD card and mounted them automatically, please unmount them again. Now it is safe to remove the uSD card from the computer.

Done!
Now you know how to modify an unmounted Raspberry to make the changes and save them on a uSD card.
Modify a Raspberry PLC / Touchberry Image