Skip to content

Instantly share code, notes, and snippets.

@rikvermeer
Last active November 28, 2019 16:04
Show Gist options
  • Save rikvermeer/805905b5fae087c4c024ebd5ffafa465 to your computer and use it in GitHub Desktop.
Save rikvermeer/805905b5fae087c4c024ebd5ffafa465 to your computer and use it in GitHub Desktop.
Run docker and (chroot)mount a (raspberry) pi image. It allows you to preconfigure apt (arm), wi-fi and SSH keys on a mac/linux using docker.
####
# Start docker
docker run --rm --privileged -it -v /dev:/dev -v `pwd`/nanopi-duo2_sd_friendlycore-xenial_4.14_armhf_20191018.img:/nanopi.img ubuntu:xenial
####
# Bind loopback devices
losetup -f /nanopi.img -P --show
mkdir /mnt/d1 /mnt/d2 /mnt/d3
mount /dev/loop2p1 /mnt/d1 && \
mount /dev/loop2p2 /mnt/d2 && \
mount /dev/loop2p3 /mnt/d3
####
# Bindmount folder
mount --bind /mnt/d1 /mnt/d2/boot
mount --bind /mnt/d3 /mnt/d2/lost+found
chroot /mnt/d2 bash
####
# Make sure wifi drivers are loaded
apt-get update && apt install -y apt-utils linux-firmware
####
# Put this in /etc/wpa_supplicant/wpa_supplicant.conf
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=wheel
network={
ssid="hotpocket"
scan_ssid=1
key_mgmt=WPA-PSK
#psk="password" generate by wpa_passphrase hotpocket password
psk=5bd365a2ebb5bdb04bbf1e9f0c2018a46568b7c5d80b0c024359864850eac8ad
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment