layereight / raspberrypios-setup

Prepare a Raspberry Pi OS image for a headless installation

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

raspberrypios-setup

Prerequisites

  • installed software:
    • xz
    • fdisk
    • openssl

Usage

raspberrypios-setup.sh <ZIPPED_RASPBERRYPIOS_IMAGE> <HOSTNAME> <USER> <PASSWORD>
# typical run

$ ~/bin/raspberrypios-setup.sh /data/software/raspberrypios/2023-12-11-raspios-bookworm-arm64-lite.img.xz homecenter pi raspberry 
Zipped image: /data/software/raspberrypios/2023-12-11-raspios-bookworm-arm64-lite.img.xz
Working directory: /data/software/raspberrypios
Unzipping...
/data/software/raspberrypios/2023-12-11-raspios-bookworm-arm64-lite.img.xz (1/1)
  100 %     432.9 MiB / 2,612.0 MiB = 0.166    69 MiB/s       0:37             
Unzipped image file: /data/software/raspberrypios/2023-12-11-raspios-bookworm-arm64-lite.img
Image sector size: 512 bytes
Boot partition start at: 4194304 bytes
Root partition start at: 541065216 bytes
Temp image mounting directory: /tmp/tmp.QoRrJ002v1
[sudo] password for user: 
Create /ssh in boot partition
Create /userconf in boot partition
pi:$6$SgNXvXs7/GG82P0y$u3Ko.qBBDPvwjR2gsdI27TGqpDGk7G302G/OgeXAyDj3MpiuxvpKWorBFmYvU4rZM2MNUxj4crZ4KSmsw2NhT.

Contents of /etc/hostname in root partition:
homecenter

Contents of /etc/hosts in root partition:
127.0.0.1	localhost
::1		localhost ip6-localhost ip6-loopback
ff02::1		ip6-allnodes
ff02::2		ip6-allrouters

127.0.1.1		homecenter

DONE. Your prepared image file is in /data/software/raspberrypios/2023-12-11-raspios-bookworm-arm64-lite.img

Copy the resulting image

  • in a separate step
#
# typical target devices (use lsblk to find out)
# /dev/mmcblk0 for sdcard reader
# /dev/sdX for USB sticks
#
sudo dd if=/data/software/raspberrypios/2023-12-11-raspios-bookworm-arm64-lite.img of=/dev/mmcblk0 status=progress

About

Prepare a Raspberry Pi OS image for a headless installation


Languages

Language:Shell 100.0%