修改树莓派系统镜像

Raspberry Pi Documentation - Configuration
The official documentation for Raspberry Pi computers and microcontrollers

boot partition

  • /boot/ssh
  • /boot/wpa_supplicant.conf

root partition

  • /home/pi/.ssh/authorized_keys
$ wget https://downloads.raspberrypi.org/raspios_lite_arm64/images/raspios_lite_arm64-2022-01-28/2022-01-28-raspios-bullseye-arm64-lite.zip

$ unzip 2022-01-28-raspios-bullseye-arm64-lite.zip
Archive:  2022-01-28-raspios-bullseye-arm64-lite.zip
  inflating: 2022-01-28-raspios-bullseye-arm64-lite.img

$ fdisk -l 2022-01-28-raspios-bullseye-arm64-lite.img
Units: sectors of 1 * 512 = 512 bytes
Device                                      Boot  Start     End Sectors  Size Id Type
2022-01-28-raspios-bullseye-arm64-lite.img1        8192  532479  524288  256M  c W95 FAT32 (LBA)
2022-01-28-raspios-bullseye-arm64-lite.img2      532480 3899391 3366912  1.6G 83 Linux

$ sudo touch /mnt/{boot,root}

$ sudo mount -o offset=$((8192*512)) 2022-01-28-raspios-bullseye-arm64-lite.img /mnt/boot

$ sudo mount -o offset=$((532480*512)) 2022-01-28-raspios-bullseye-arm64-lite.img /mnt/root

$ sudo touch /mnt/boot/ssh.txt

$ sudo vi /mnt/boot/wpa_supplicant.conf

$ sudo mkdir -m 700 /mnt/root/home/pi/.ssh

$ sudo vi /mnt/root/home/pi/.ssh/authorized_keys

$ sudo chown -R 1000:1000 /mnt/root/home/pi/.ssh

$ sudo umount /mnt/{boot,root}

$ gzip 2022-01-28-raspios-bullseye-arm64-lite.img