How to pre-configure rasberry image for swedish wifi and enable ssh

Star InactiveStar InactiveStar InactiveStar InactiveStar Inactive
 

This will setup a raspian image to be used with a swedish wifi and ssh enabled. Done in linux.

Prologue:

  • Map the partitions from the image with:
        kpartx -a <name-of-unpacked-raspian-image>.img
  • Run losetup to see which loop device was used. Lets say it was loop4 in this case
  • Mount the root partition of the image (second partition) under /mnt:
       sudo mount /dev/mapper/loop4p2 /mnt

Wifi:

  • Create the file /mnt/etc/wpa_supplicant/wpa_supplicant.conf  with following content:
    ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
    update_config=1
    country=SE
    network={
    ssid="<your-wifi-ssid>"
    psk="<your-wifi-password>"
    }
  • Replace the '1' to a '0' i all files /mnt/var/lib/systemd/rfkill/platform-*

Enable ssh daemon:

Either do:

  • ln -s /lib/systemd/system/ssh.service /mnt/etc/systemd/system/
  • ln -s /lib/systemd/system/ssh.service /mnt/etc/systemd/system/multi-user.target.wants/

Or mount the boot partition and touch a file named "ssh" in that directory.

Epilogue:

  • Run: umount /mnt
  • Drop the devicemapper mappings:
        kpartx -d <name-of-unpacked-raspian-image>.img

Now your image file should be ready to write to a MicroSD card and the raspberry should boot up directly to the wifi network with ssh enabled.

Extra stuff

Enable camera:

  • Run the kpartx and mount /dev/mapper/loop4p1 instead as /mnt
  • Add following files to the "[all]" section of /mnt/config.txt:
    start_x=1
    gpu_mem=128