alpine-linux-headless-boots.../README.md

48 lines
3.8 KiB
Markdown
Raw Permalink Normal View History

2022-07-29 10:30:38 +00:00
# Deploy Alpine Linux on a headless system
2022-07-09 12:34:58 +00:00
2023-03-20 10:51:54 +00:00
[Alpine Linux documentation](https://docs.alpinelinux.org/user-handbook/0.1a/Installing/setup_alpine.html) assumes **initial setup** is carried-out on a system with a keyboard & display to interract with.\
However, in many cases one might want to deploy a headless system that is only available through a network connection (ethernet, wifi or as USB ethernet gadget).
2022-07-09 12:34:58 +00:00
2023-05-12 13:57:37 +00:00
This repo provides an **overlay file** to initially boot such headless system (leveraging Alpine distro's `initramfs` feature): it starts a basic ssh server to log-into from another Computer, in order to then perform actual system setup.
2022-07-09 12:34:58 +00:00
## Install procedure:
2023-03-20 10:51:54 +00:00
Please follow [Alpine Linux Wiki](https://wiki.alpinelinux.org/wiki/Installation#Installation_Overview) to download & create installation media for the target platform.\
2022-07-09 12:34:58 +00:00
Tools provided here can be used on any plaform for any install modes (diskless, data disk, system disk).
2023-05-12 13:57:37 +00:00
Just add [**headless.apkovl.tar.gz**](https://github.com/macmpi/alpine-linux-headless-bootstrap/raw/main/headless.apkovl.tar.gz)[^1] overlay file at the root of Alpine Linux boot media (or onto any custom side-media) and boot-up the system.\
With default network interface definitions (and SSID/pass file if using wifi), system can then be remotely accessed with: `ssh root@<IP>`\
2023-02-24 15:03:04 +00:00
(system IP address may be determined with any IP scanning tools such as `nmap`).
2022-07-09 12:34:58 +00:00
2023-05-12 13:57:37 +00:00
As with Alpine Linux initial bring-up, `root` account has no password initially (change that during setup!).\
From there, actual system install can be performed as usual with `setup-alpine` for instance (check [wiki](https://wiki.alpinelinux.org/wiki/Alpine_setup_scripts#setup-alpine) for details).
2022-07-09 12:34:58 +00:00
Extra files may be added next to `headless.apkovl.tar.gz` to customise boostrapping configuration (check sample files):
2023-05-12 13:57:37 +00:00
- `wpa_supplicant.conf`[^2] (*mandatory for wifi usecase*): define wifi SSID & password.
- `interfaces`[^2] (*optional*): define network interfaces at will, if defaults DCHP-based are not suitable.
- `ssh_host_*_key*` (*optional*): provide custom ssh keys to be injected (may be stored), instead of using bundled ones[^1] (not stored). Providing an empty key file will trigger new keys generation (ssh server may take longer to start).
2023-05-12 13:57:37 +00:00
- `unattended.sh`[^2] (*optional*): create custom automated deployment script to further tune & extend actual setup (backgrounded).
2022-07-09 12:34:58 +00:00
2023-05-12 13:57:37 +00:00
**Goody:** seamless USB bootstrapping for PiZero devices (or similar supporting USB ethernet gadget networking):\
Just add `dtoverlay=dwc2` in `usercfg.txt` (or `config.txt`), and plug USB cable into Computer port.\
With Computer set-up to share networking with USB interface as 10.42.0.1 gateway, one can log into device from Computer with: `ssh root@10.42.0.2`
2022-12-05 09:54:35 +00:00
2022-07-29 10:30:38 +00:00
Main execution steps are logged in `/var/log/messages`.
2022-07-09 12:34:58 +00:00
2023-05-11 15:53:42 +00:00
[^1]: About bundled ssh keys: as this package is essentially intended to **quickly bootstrap** system in order to configure it, it purposely embeds [some ssh keys](https://github.com/macmpi/alpine-linux-headless-bootstrap/tree/main/overlay/etc/ssh) so that bootstrapping is as fast as possible. Those (temporary) keys are moved in RAM /tmp, so they will **not be saved/reused** once permanent configuration is set (with or without ssh server voluntarily installed in permanent setup).
2023-05-11 07:18:46 +00:00
2023-05-12 13:57:37 +00:00
[^2]: These files are linux text files: Windows/macOS users need to use text editors supporting linux text line-ending (such as [notepad++](https://notepad-plus-plus.org/), BBEdit or any similar).
2022-07-09 12:34:58 +00:00
2023-05-12 13:57:37 +00:00
## How to customize ?
2022-07-09 12:34:58 +00:00
This repository may be forked/cloned/downloaded.\
Main script file is [`headless.start`](https://github.com/macmpi/alpine-linux-headless-bootstrap/blob/main/overlay/etc/local.d/headless.start).\
2022-12-05 09:54:35 +00:00
Execute `./make.sh` to rebuild `headless.apkovl.tar.gz` after changes.
2022-07-09 12:34:58 +00:00
## Credits
2023-03-20 10:51:54 +00:00
Thanks for the initial guides & scripts from @sodface and @davidmytton.
2022-07-09 12:34:58 +00:00