Issue at Hand
You wish to know how to set up debian-installer
to pre-configure your WiFi settings. You mention using this build to create an image of Debian for a Raspberry Pi 3.
They are using debootstrap
and not the standard debian-installer
to install Debian on the Raspberry Pi. I will provide information on how to pre-configure your WiFi using both processes.
Using debian-installer
If you wish to know how individual components of debian-installer
works please read over this manual. Section 6.3.1.5 covers configuring the network. Section 3.3.4 helps provide information about what you will need to provide to debian-installer
to set up networking.
However, all of this is a manual process that can be automated via "preseeding" or providing debian-installer
with a pre-configuration file.
Here is the Debian Wiki page on how to edit a preseed file. I am also include another manual page to help provide additional information on preseeding.
Here is an example preseed.cfg for you to look over. Edit it to include the steps to add wireless firmware ( d-i hw-detect/load_firmware boolean true
is the key line here ).
Add these lines to preseed a wireless WPA2 network to your preseed.cfg
after you have added the lines to load your firmware. Check here for information on how to load firmware during debian-installer
d-i netcfg/wireless_essid [string] // Name of wireless network
d-i netcfg/wireless_security_type [select] // Options are wep/open or wpa
d-i netcfg/wireless_wpa [string] // Password
Here is a fairly comprehensive list to show you possible netcfg
options. Add more as needed to your preseed.cfg
if the ones I listed do not cut it. Once you have created your preseed.cfg
add it in using the following steps.
To add a preseed file you will need to mount your debian.iso
and extract the the contents to copy in your preseed.cfg
. The [arch] refers to the architecture of your .iso
. In your case it is most likely armhf
or arm64
.
udevil mount debian.iso
cp -rT /media/debian.iso/ isofiles/
chmod +w -R isofiles/install.[arch]/
gunzip isofiles/install.[arch]/initrd.gz
echo preseed.cfg | cpio -H newc -o -A -F isofiles/install.[arch]/initrd
gzip isofiles/install.386/initrd
chmod -w -R isofiles/install.[arch]/
Here is how you fix md5sum.txt:
# cd isofiles
# md5sum `find -follow -type f` > md5sum.txt
# cd ..
Here is how you create a new bootable ISO image:
genisoimage -r -J -b isolinux/isolinux.bin -c isolinux/boot.cat \
-no-emul-boot -boot-load-size 4 -boot-info-table \
-o preseed-debian.iso isofiles
Now you have created a bootable ISO image to be written to your installer USB or disk that contains your pre-configurations. Make sure to read over the Wiki page and the manual carefully to help troubleshoot any issues.
Using debootstrap
Another method of installing Debian is to use debootstrap
. Here is a link to the Debian Wiki and another link to the manpage. Debootstrap
can be used to create an installation of Debian from an existing Unix or Linux machine.
Using debootstrap
only requires a chroot
or other disk/partitions and a network connection to download the packages from the repository. You can then chroot
into the new Debian rootfs
and configure it as needed then propagate it out to any device you wish the install to be on. This is very similar to the Arch Linux install process.
However, if you are using this script from GitHub, and you wish to pre-stage your wireless configuration then you will need to edit raspi3.yaml
and use vmdb2
.
Install vmdb2
: ( This assumes you are using Debian Stretch! )
apt install kpartx parted qemu-utils qemu-user-static python3-cliapp \
python3-jinja2 python3-yaml
Note that python3-cliapp
is not available in Stretch, but as it does not carry any dependencies, can be manually installed by fetching its .deb package and installing it manually.
Next download a copy of the image:
git clone --recursive https://github.com/Debian/raspi3-image-spec
cd raspi3-image-spec
Now edit the raspi3.yaml
to include the following:
After - apt: install
on line 68 add these lines:
- iw
Now after line 90 ( - shell: |
) you can add this code on its own line:
wpa_passphrase [WiFi SSID] [WiFI Password] > /etc/wpa_supplicant.conf
As long as wpa_supplicant
installs correctly during your image process this line should add your WiFi configuration to allow you to connect automatically. You will still need to probably run these commands after boot, but they could potentially be added to the script too.
ip link set wlan0 down
ip link set wlan0 up
wpa_supplicant -B -iwlan0 -c /etc/wpa_supplicant.conf -Dwext
dhclient wlan0
Once you have edited raspi3.yaml
, you can generate the image by issuing the following. If you are using the systemwide vmdb2
:
umask 022
sudo env -i LC_CTYPE=C.UTF-8 PATH="/usr/sbin:/sbin:$PATH" \
vmdb2 --output raspi3.img raspi3.yaml --log raspi3.log
Or, if you are using it from the submodule in this repository
umask 022
sudo env -i LC_CTYPE=C.UTF-8 PATH="/usr/sbin:/sbin:$PATH" \
./vmdb2/vmdb2 --output raspi3.img raspi3.yaml --log raspi3.log
After that you should be able to install the new image onto an SD card and it will follow the extra steps you added in the script. You can add any additional steps you wish to the file.
The OP of this stack exchange post noted that the second method user GAD3R advises works as well to add wireless configurations via command line.
Conclusion
If you are using debian-installer
you will need to preseed your debian.iso
with the configuration you desire.
If you are using debootstrap
you will have to include any additional steps you wish to take in the installation process or chroot
in afterwards.
I will be including the Debian Wiki Page on WiFi as well as the How To page and the information on adding missing firmware. The wireless firmware can be found here for Raspberry Pi
Please comment if you have any questions or issues with this answer. I highly suggest you read through each link I have provided thoroughly before attempting the commands. I appreciate feedback to correct any misconceptions and to improve my posts. I can update my answer as needed.
Best of Luck!
raspberry-pi
tag because neitherd-i
nor the WiFi configuration has anything to do with the device itself. I only mentioned as context of the question. – Oxwivi Sep 16 '18 at 19:57