archlinux-orange-pi-zero icon indicating copy to clipboard operation
archlinux-orange-pi-zero copied to clipboard

Create custom img

Open beyazsis opened this issue 2 years ago • 1 comments
trafficstars

I use your img on may pi zero. It's works fine. Then I customized system and now I need to use this system in another orange pi zero with another SD card. How can I create my arch linux arm img file like your img?

beyazsis avatar May 09 '23 09:05 beyazsis

Hi beyaszsis! What you can do if you're fine with having an exact copy of your current system and if your new SD card is at least the same size as your current one, is :

  • shutdown Pi Zero with desired image state
  • take out SD card
  • plug SD card into a linux PC
  • locate the card root block device path, using something like sudo fdisk -l
  • extract the image from the SD card using dd. Say for example you located your SD card block device at /dev/sdX. Also, you might want on-the-fly fast compression to avoid getting a huge file. For example with Zstandard compression : sudo dd if=/dev/sdX bs=1M | zstd --fast -o custom-arch-pi-zero.img.zst
  • now you've got your custom image as a file :)
  • you can do the "reverse" process to write it to another SD card. Say you located that SD card at /dev/sdY: zstd -c -d custom-arch-pi-zero.img.zst | sudo dd of=/dev/sdY bs=1M

Drawbacks of this: the new system is a clone. That means everything will be the same on first startup (partitions, partition sizes, hostname, users, secrets...). If your new SD card is smaller, it won't work. If your new SD card is bigger, it will work but will not see the new available space until you manually resize the partition.

Another approach would be to build the system yourself (more involved - see https://github.com/ubitux/archlinuxarm-orangepi_zero, this is basically what I did to create this image). Or you could also try to start from mounting my image file (unpacked) to a loop device, and try to reapply your changes on there without ever actually booting the image.

Anyway, good luck :)

nguiard avatar May 09 '23 11:05 nguiard