WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: headless wifi ssid / passphrase setup  (Read 3844 times)

Offline spot

  • Newbie
  • *
  • Posts: 6
headless wifi ssid / passphrase setup
« on: March 17, 2022, 07:54:00 PM »
I'm stuck. It's a long while since I used tiny core linux and I didn't use wifi. If I don't post I'll not get to bed and I need to get to bed.

Background: I put a public-facing very low-volume LAMP on a Pi Zero2 W last year and now it (probably fail2ban) has predictably fried the microSD storage. Putting everything in RAM with Tiny Core is my next step. I ground to a halt about 5 hours in trying to get the headless Pi wifi through a router WPA2 login.

I temporarily moved the microSD into an equally headless Pi 4+ and now I can ssh into it on the Ethernet. I still can't bring up the wifi though. It occurs to me the Pi 4+ might have different wifi hardware, of course - that insight might get me a step further. I'm also not sure what I should save between sessions with filetool if I eventually manage to login on the wifi IP address.

Here's what I can see so far: https://pastebin.com/wPVtXJam

Perhaps this counts as a belated intro thread. I'm learning a lot about linux today delving into Tiny Core again, so thank you for that.

Offline spot

  • Newbie
  • *
  • Posts: 6
Re: headless wifi ssid / passphrase setup
« Reply #1 on: March 30, 2022, 05:12:40 AM »
None of this is a complaint, I'm hugely impressed with the architecture of TinyCore. I'm exploring how to progress.

The WiFi is now up and running but I did have to borrow a monitor. And a keyboard. I still don't know how to achieve a headless install on a Pi. If I have an otherwise idle day I'll try that bit again and come back here with a recipe, or if anyone has ever done it they might have one already to hand, but so  far I've not found one.

Part of the learning curve is pulling in the dependencies while not having an Internet connection. I'm sure there's a way to tell the tce- utilities that the .tcz packages are mirrored to a local directory on partition 2 but I've not found how to do that either. Nor have I found the script on here which lets you install onto the SD card while it's inserted in an existing Linux environment. I practiced before I did the WiFi part by bringing up nano and mc for convenience, and that took ten additional packages to get them running (which is fine and proper, I didn't wince and it wasn't painful).

I need to make a choice now. Having studied the repo, I reckon a webserver will involve compiling. To make the most of the Pi Zero I think the right components are PHP8, lighttp and mariaDB, and they're heavyweight compiles.

TinyCore is the only way I've found to eliminate the long-term destructive load on an SD card, but I did have an alternative in mind if I couldn't manage this. I could strap an external M.2 NVMe SSD to the Pi Zero and run Raspbian like I did last year, with precompiled packages instead of compiling it all up, and not have an SD card at all.

I'm hesitant about the compiles because the only source will be the package maintainer version, there is no tailored source for the distribution. That's something I've never tried before. For a trivially small package I'd not feel intimidated but these three are all major beasts.

So, a question before I give it a try. Has anyone here any experience in bringing up a TinyCore webserver? I brief description would be very welcome. I've seen a lightweight static webserver package in the repo but I can't hang PHP or a database on it, and I need both.

Offline gadget42

  • Hero Member
  • *****
  • Posts: 818
Re: headless wifi ssid / passphrase setup
« Reply #2 on: March 30, 2022, 05:19:07 AM »
perhaps this setup might be interesting:
http://forum.tinycorelinux.net/index.php/topic,25675.0.html
The fluctuation theorem has long been known for a sudden switch of the Hamiltonian of a classical system Z54 . For a quantum system with a Hamiltonian changing from... https://forum.tinycorelinux.net/index.php/topic,25972.msg166580.html#msg166580

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14845
Re: headless wifi ssid / passphrase setup
« Reply #3 on: March 30, 2022, 06:38:06 AM »
Nor have I found the script on here which lets you install onto the SD card while it's inserted in an existing Linux environment.
I have an sd card slot in my laptop - this is all that is required after an sd card is inserted:
Code: [Select]
unzip piCore-13.1.zip
md5sum -c piCore-13.1.img.md5.txt
sudo dd if=piCore-13.1.img of=/dev/mmcblk0

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14845
Re: headless wifi ssid / passphrase setup
« Reply #4 on: March 30, 2022, 06:47:37 AM »
The WiFi is now up and running but I did have to borrow a monitor. And a keyboard. I still don't know how to achieve a headless install on a Pi.

Once you've burnt the image to sd card as per the previous post, insert the sd card into a RPi, connect it to a wired network and boot. Assuming your lan router assigns it an address of 192.168.1.101, then from another linux machine on your lan:
Code: [Select]
ssh tc@192.168.1.101 [password piCore]
filetool.sh -b [save the ssh keys]

..then expand the second partition as explained here: http://tinycorelinux.net/12.x/armv7/releases/RPi/README

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14845
Re: headless wifi ssid / passphrase setup
« Reply #5 on: March 30, 2022, 06:55:17 AM »
Has anyone here any experience in bringing up a TinyCore webserver? I brief description would be very welcome. I've seen a lightweight static webserver package in the repo but I can't hang PHP or a database on it, and I need both.

I believe user @andyj maintains an x86_64 tinycore webserver running in a vm. He maintains many x86/x86_64 extensions with build scripts like this: http://tinycorelinux.net/10.x/x86_64/tcz/src/php/build-php.sh

..note that php might well require too much cpu power for an RPi0/armv6.

Offline spot

  • Newbie
  • *
  • Posts: 6
Re: headless wifi ssid / passphrase setup
« Reply #6 on: March 30, 2022, 07:13:46 AM »
perhaps this setup might be interesting:
http://forum.tinycorelinux.net/index.php/topic,25675.0.html



That was enjoyable, I'm pleased to see the combination works. Pi PSUs always seem at the edge of their capacity, having to bump up to 5.25V for headroom and only running 2A at most. I've no idea why the designer can't just bite the bullet and over-engineer something which every add-on must hang off.

I've not tried Chromebook architecture so far (I browsed the blog a while). I might eventually. I agree many developers can get by with very little processing power, I settled years back on a lightweight Dell Latitude with no fan and that's done all I needed. I occasionally rent something more powerful and drive it remotely when it helps - like a recent online AI course.

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14845
Re: headless wifi ssid / passphrase setup
« Reply #7 on: March 30, 2022, 07:22:31 AM »
I'm sure there's a way to tell the tce- utilities that the .tcz packages are mirrored to a local directory on partition 2 but I've not found how to do that either.

If you are speaking of the second partition on the sd card, piCore will find extensions in /mnt/mmcblk0p2/tce/optional automatically.

In the case of an RPi0, you can use a separate linux machine with a sd card slot to copy firmware-rpi-wifi.tcz and wifi.tcz (and all of its recursive deps) to /mnt/mmcblk0p2/tce/optional along with the associated *.tcz.dep and *.tcz.md5.txt files and they will be found by piCore.

Offline spot

  • Newbie
  • *
  • Posts: 6
Re: headless wifi ssid / passphrase setup
« Reply #8 on: March 30, 2022, 07:56:09 AM »
Has anyone here any experience in bringing up a TinyCore webserver? I brief description would be very welcome. I've seen a lightweight static webserver package in the repo but I can't hang PHP or a database on it, and I need both.

I believe user @andyj maintains an x86_64 tinycore webserver running in a vm. He maintains many x86/x86_64 extensions with build scripts like this: http://tinycorelinux.net/10.x/x86_64/tcz/src/php/build-php.sh

..note that php might well require too much cpu power for an RPi0/armv6.



Thank you for the posts and suggestions Juanito. All my issues centred around having just a headless Zero 2 available and no immediate Internet before needing to edit the transferred image.

Once the image is on the SD card, the difficulty is giving a headless WiFi-only Zero 2 the extra packages, the router SSID and a PSK. Given a keyboard and monitor it's a doddle. With a script on a host computer, pushing all the .tcz and .conf files and onboot.lst would simple too (though I still haven't located the script on this site though I've seen reference to it). What one cannot do is just copy the image to the SD card, boot the Zero 2 and then log into it, I've found no way in and I don't know how to attach a wired connection. I believe there could be an Ethernet over USB avenue but I've not chased that down, it might have got me a headless install if I'd focused there.

I think PHP will be fine on the four-core armv7 Zero 2. Even on the earlier RPi0/armv6 I was running low-volume apache2, PHP and mysql for a year before my SD card collapsed through overuse. Avoiding excessive SD card I/O is what brought me here looking for a solution.

I'm grateful for your link to @andyj's extension scripts which is a big step forward for me, I'll explore those and especially the PHP script you focused on. Tailoring that for armv7 instead of x86 might be within my scope and I'll understand my problem better once I've tried.

Offline spot

  • Newbie
  • *
  • Posts: 6
Re: headless wifi ssid / passphrase setup
« Reply #9 on: March 30, 2022, 08:06:51 AM »
I'm sure there's a way to tell the tce- utilities that the .tcz packages are mirrored to a local directory on partition 2 but I've not found how to do that either.

If you are speaking of the second partition on the sd card, piCore will find extensions in /mnt/mmcblk0p2/tce/optional automatically.

In the case of an RPi0, you can use a separate linux machine with a sd card slot to copy firmware-rpi-wifi.tcz and wifi.tcz (and all of its recursive deps) to /mnt/mmcblk0p2/tce/optional along with the associated *.tcz.dep and *.tcz.md5.txt files and they will be found by piCore.



That hadn't occurred to me, putting a complete set of extensions into /mnt/mmcblk0p2/tce/optional instead of just the extensions named in onboot.lst - I had them in a side directory and copied them across when I added each onboot.lst line. I can see now that putting something in /optional doesn't add any overhead, I'd not realized. So yes, that's the answer to local storage I was stuck for.

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14845
Re: headless wifi ssid / passphrase setup
« Reply #10 on: March 30, 2022, 08:16:01 AM »
Once you have set firmware-rpi-wifi and wifi onboot:

copy /mnt/mmcblk0p2/tce/mydata.tgz somewhere and expand it:

a) add "wifi.sh -a" to the end of /opt/bootlocal.sh
b) create /home/tc/wifi.db containing "ssid->password->encryption" - for example "piNet->piUser->WPA"

..then recreate mydata.tgz and copy it to /mnt/mmcblk0p2/tce.

You can now put the sd card in an RPi0, boot it and it should connect to your wifi automatically.

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 14845
Re: headless wifi ssid / passphrase setup
« Reply #11 on: March 30, 2022, 08:32:00 AM »
(though I still haven't located the script on this site though I've seen reference to it).

The FetchExt.sh script is here: http://forum.tinycorelinux.net/index.php/topic,23034.0.html

Offline spot

  • Newbie
  • *
  • Posts: 6
Re: headless wifi ssid / passphrase setup
« Reply #12 on: March 30, 2022, 09:37:08 AM »
Once you have set firmware-rpi-wifi and wifi onboot:

copy /mnt/mmcblk0p2/tce/mydata.tgz somewhere and expand it:

a) add "wifi.sh -a" to the end of /opt/bootlocal.sh
b) create /home/tc/wifi.db containing "ssid->password->encryption" - for example "piNet->piUser->WPA"

..then recreate mydata.tgz and copy it to /mnt/mmcblk0p2/tce.

You can now put the sd card in an RPi0, boot it and it should connect to your wifi automatically.




That's the bit I'd not fathomed. As you say, that's everything needed to get the headless route sorted through to logging in over ssh. With the script you just referenced it automates the dependencies before the first boot too. I'll check later today with a fresh SD card but it looks right.


Offline Rich

  • Administrator
  • Hero Member
  • *****
  • Posts: 11694
Re: headless wifi ssid / passphrase setup
« Reply #13 on: April 04, 2022, 01:23:00 AM »
Hi spot
... With the script you just referenced it automates the dependencies before the first boot too. ...
I posted an updated version of that script. It can be found here:
http://forum.tinycorelinux.net/index.php/topic,23034.msg164705.html#msg164705

Offline zharr

  • Newbie
  • *
  • Posts: 29
Re: headless wifi ssid / passphrase setup
« Reply #14 on: May 18, 2022, 11:56:16 PM »
Made a script that automatically sets up a headless Pi and installs extensions and sets up whatever your project needs (e.g. program source code).
http://forum.tinycorelinux.net/index.php/topic,25760.0.html
With this you can set up a new SD card with everything you need and work on it over SSH within a minute, no matter where you are, without needing a keyboard and monitor.
Needs some initial setup (selecting architecture, additional dependencies you need, wifi credentials, custom config.txt / bootlocal entries, etc), but after that it's very nice to have.