-
-
Save telenieko/d17544fc7e4b347beffa87252393384c to your computer and use it in GitHub Desktop.
#!/bin/sh | |
# this goes into /etc/initramfs-tools/scripts/init-premount/a_enable_wireless | |
PREREQ="" | |
prereqs() | |
{ | |
echo "$PREREQ" | |
} | |
case $1 in | |
prereqs) | |
prereqs | |
exit 0 | |
;; | |
esac | |
. /scripts/functions | |
AUTH_LIMIT=30 | |
INTERFACE="wlp5s0" | |
alias WPACLI="/sbin/wpa_cli -p/tmp/wpa_supplicant -i$INTERFACE " | |
log_begin_msg "Starting WLAN connection" | |
/sbin/wpa_supplicant -i$INTERFACE -c/etc/wpa_supplicant.conf -P/run/initram-wpa_supplicant.pid -B -f /tmp/wpa_supplicant.log | |
# Wait for AUTH_LIMIT seconds, then check the status | |
limit=${AUTH_LIMIT} | |
echo -n "Waiting for connection (max ${AUTH_LIMIT} seconds)" | |
while [ $limit -ge 0 -a `WPACLI status | grep wpa_state` != "wpa_state=COMPLETED" ] | |
do | |
sleep 1 | |
echo -n "." | |
limit=`expr $limit - 1` | |
done | |
echo "" | |
if [ `WPACLI status | grep wpa_state` != "wpa_state=COMPLETED" ]; then | |
ONLINE=0 | |
log_failure_msg "WLAN offline after timeout" | |
panic | |
else | |
ONLINE=1 | |
log_success_msg "WLAN online" | |
fi | |
configure_networking |
# !/bin/sh | |
# This goes into /etc/initramfs-tools/hooks/enable-wireless | |
set -e | |
PREREQ="" | |
prereqs() | |
{ | |
echo "${PREREQ}" | |
} | |
case "${1}" in | |
prereqs) | |
prereqs | |
exit 0 | |
;; | |
esac | |
. /usr/share/initramfs-tools/hook-functions | |
# CHANGE HERE for your correct modules. | |
manual_add_modules iwlwifi iwlmvm | |
copy_exec /sbin/wpa_supplicant | |
copy_exec /sbin/wpa_cli | |
copy_file config /etc/initramfs-tools/wpa_supplicant.conf /etc/wpa_supplicant.conf |
# This is run on the shell | |
chmod +x /etc/initramfs-tools/scripts/local-bottom/kill_wireless | |
chmod +x /etc/initramfs-tools/scripts/init-premount/a_enable_wireless | |
chmod +x /etc/initramfs-tools/hooks/enable-wireless | |
update-initramfs -k all -u | |
update-grub |
#!/bin/sh | |
# this goes into /etc/initramfs-tools/scripts/local-bottom/kill_wireless | |
PREREQ="" | |
prereqs() | |
{ | |
echo "$PREREQ" | |
} | |
case $1 in | |
prereqs) | |
prereqs | |
exit 0 | |
;; | |
esac | |
echo "Killing wpa_supplicant so the system takes over later." | |
kill `cat /run/initram-wpa_supplicant.pid` |
# sample /etc/initramfs-tools/wpa_supplicant.conf | |
# note that this is independent of the system /etc/wpa_supplicant.conf (if any) | |
# only add the network you need at boot time. **And keep the ctrl_interface** !! | |
ctrl_interface=/tmp/wpa_supplicant | |
network={ | |
ssid="MyNetwork" | |
scan_ssid=1 | |
psk="network passphrase" | |
key_mgmt=WPA-PSK | |
} |
- The resized root partition won't work in another raspberry pi or resized SD card unless you get to boot there from a second USB stick, chroot into the installation with LUKS and rebuild the initramfs. "Cross-initramfs-building" is NOT an option. I learned this the very hard way, that is, time.
It worked well for me, I just had to use QEMU.
It worked well for me, I just had to use QEMU.
I tried to fit a 64gb installation into a 16 gb card (both rsync and resize/dd way). I made sure to use the same UUIDs for the partitions. SSH works on boot, but after entering the passphrase this follows:
Cannot initialize device-mapper. Is dm_mod kernel module loaded?
The same applied to the Pi400. Since I have another installation running on the Pi400, after chrooting and rebuilding it worked there, but rebuilding for the Pi Zero W failed.
Thanks for this scripts.
To add autodetection of wlan interface name in a_enable_wireless.sh
change
INTERFACE="wlp5s0"
to
INTERFACE=`ip link | awk '{if(substr($2,1,1) =="w") {gsub(":","",$2); print($2); exit;}}'`
it finds first interface by mask "w*",
and then add check if INTERFACE is zero string and skip wpa_supplicant.
if ! [ -z "$INTERFACE" ]; then
# wpa supllicant stuff
fi
configure_networking
Hello, I'm having a little issue. I've tried the above (thanks for the scripts!) but I'm now stuck and not able to boot my server.
I think the connection is failing for some reason except that I never end up again in a command line to unlock my disk manually from the laptop (without using wifi).
Any idea how I can solve this?
Hello, I'm having a little issue. I've tried the above (thanks for the scripts!) but I'm now stuck and not able to boot my server.
You are welcome.
I am not using Debian on this scenarios anymore so I cannot be of much help but:
a) I think there have been some considerable changes to initramfs/dracut that could make all this not very usefull
b) The dropbear packages (dropbear-initramfs
), if memory serves well, had some scripts on line with what is proposed here which may be useful.
c) The mandos-client package also had some sample scripts that could help you
Oh, and check the comments posted here by some users giving updates! like @morfikov & @leksmut (Thank you all for those comments!)
Ok, so I found your blog entry and followed all of the steps. It works!
There are two extra things to note:
I think it is better to first build the initramfs and figure out the exact files needed on boot for the wi-fi interface, then proceed with the rest of the steps (I also have a pi zero w and no mini HDMI converter, so for anyone in the same situation, this is strongly advised)
The resized root partition won't work in another raspberry pi or resized SD card unless you get to boot there from a second USB stick, chroot into the installation with LUKS and rebuild the initramfs. "Cross-initramfs-building" is NOT an option. I learned this the very hard way, that is, time.