I have a laptop, a power cable, an sd card, and a Pi3 (wifi built in).
I'm trying to ssh in but first I need to setup the wifi. Where on the boot partition can I setup wifi (cmdline.txt?) with a hostname and a password?
Since you have not mentioned some details I think are relevant to the answer such as
I will assume the following
PI: raspbian/jessie which the latest as of this writing
Remote: some flavor of linux
This is how I'd go about setting up the customized image from the remote machine
download the official raspbian OS image file which should come bundled with the required drivers, firmware compatible with the included kernel.
unzip the archive to extract img file. lets call this image file jessie.img for this post
the jessie.img file should contain 2 partitions - one for boot (FAT32) and for the rest (EXT4)
use fdisk to find out the file offsets of the partitions.
fdisk -l ./jessie.img
Disk ./jessie.img: 4.1 GiB, 4348444672 bytes, 8493056 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0xd94ffdb3
Device Boot Start End Sectors Size Id Type
./jessie.img1 8192 137215 129024 63M c W95 FAT32 (LBA)
./jessie.img2 137216 8493055 8355840 4G 83 Linux
here jessie.img2 starts at block 137216
with each block 512
bytes long.
so the total offset is the product of the two = 70254592
bytes
next step is mount the jessie.img2 as read/write so that we can edit the /etc/network/interfaces
make a temporary mount point
mkdir ~/mntpt
sudo mount -o loop,rw,offset=70254592 jessie.img ./mntpt
cd ./mntpt
ls
bin boot dev etc home lib lost+found media mnt opt proc root run sbin srv sys tmp usr var
etc
cd ./etc
less ./network/interfaces
# interfaces(5) file used by ifup(8) and ifdown(8)
# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'
# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d
auto lo
iface lo inet loopback
iface eth0 inet manual
allow-hotplug wlan0
iface wlan0 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
allow-hotplug wlan1
iface wlan1 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
/etc/wpa_supplicant/wpa_supplicant.conf
file and add the new lines, customize to match your setup, save and exitsudo nano /etc/wpa_supplicant/wpa_supplicant.conf
network={
ssid="YOUR_NETWORK_NAME"
psk="YOUR_NETWORK_PASSWORD"
proto=RSN
key_mgmt=WPA-PSK
pairwise=CCMP
auth_alg=OPEN
}
etc
cd ..
cd ..
sudo unmount ./mntpt
References
Notes
kpartx makes it bit easier to mount the individual partitions
Since this technique requires some unix/linux tools, it might be harder to do the same from a windows machine. a mingw / cgywin setup might work but i have not tried them
if you spot any mistakes or encounter any error messages along the way, please leave a comment and I will try to address them the best I can
cmdline.txt
. I suggest firing up a Linux virtual machine and editing the/etc/wpa_supplicant/wpa_supplicant.conf
file on the Pi's SD card from there. Let me know if you need thecmdline.txt
approach or if this will suffice.