Skip to content

Commit f2bb44f

Browse files
committed
README: improve all images, add kexec tarball and netboot images
1 parent 00860bb commit f2bb44f

File tree

1 file changed

+213
-38
lines changed

1 file changed

+213
-38
lines changed

README.md

Lines changed: 213 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,233 @@
11
# nixos-images
22

3-
Automatically weekly updated images for NixOS. This project is intended to extend the images created by hydra.nixos.org.
4-
We are currently creating the images listed below:
3+
This project provides automatically updated NixOS images that complement the official images from hydra.nixos.org. New images are built weekly to ensure you always have access to the latest NixOS features and security updates.
54

6-
## Kexec tarballs
5+
## Available Image Types
76

8-
These images are used for unattended remote installation in [nixos-anywhere](https://github.com/numtide/nixos-anywhere).
7+
We currently offer three types of NixOS images:
98

10-
Kexec is a mechanism in Linux to load a new kernel from a running Linux to
11-
replace the current kernel. This is useful for booting the Nixos installer from
12-
existing Linux distributions, such as server provider that do not offer a NixOS
13-
option. After running kexec, the NixOS installer exists only in memory. At the
14-
time of writing, this requires secure boot off in BIOS settings and at least 1GB
15-
of physical RAM (swap does not count) in the system. If not enough RAM is available,
16-
the initrd cannot be loaded. Because the NixOS runs only in RAM, users can reformat
17-
all the system's discs to prepare for a new NixOS installation.
9+
- **[ISO Installer Images](#iso-installer-images)**: Bootable USB images for installing NixOS on physical hardware
10+
- **[Kexec Tarballs](#kexec-tarballs)**: For booting NixOS installer from an existing Linux system
11+
- **[Netboot Images](#netboot-images)**: For booting NixOS over the network via PXE/iPXE
1812

19-
It can be booted as follows by running these commands as root:
13+
## ISO Installer Images
2014

15+
Our ISO installer images allow you to boot NixOS from a USB drive. These images have been optimized for both local and remote installations.
16+
17+
### Creating a Bootable NixOS USB Drive
18+
19+
#### Step 1: Download the ISO image
20+
21+
Choose the appropriate image for your system architecture:
22+
23+
**For x86_64 (64-bit Intel/AMD):**
24+
```bash
25+
wget https://github.com/nix-community/nixos-images/releases/download/nixos-unstable/nixos-installer-x86_64-linux.iso
26+
```
27+
28+
**For aarch64 (64-bit ARM):**
29+
```bash
30+
wget https://github.com/nix-community/nixos-images/releases/download/nixos-unstable/nixos-installer-aarch64-linux.iso
31+
```
32+
33+
You can also download the images directly from the [releases page](https://github.com/nix-community/nixos-images/releases).
34+
35+
#### Step 2: Identify your USB drive
36+
37+
**On Linux:**
38+
```bash
39+
lsblk
40+
```
41+
42+
**On macOS:**
43+
```bash
44+
diskutil list
2145
```
46+
47+
Make careful note of the device name (e.g., `/dev/sdb`, `/dev/disk2`, etc.) - **writing to the wrong device can cause data loss!**
48+
49+
#### Step 4: Write the ISO to the USB drive
50+
51+
**On Linux:**
52+
```bash
53+
# Replace /dev/sdX with your USB drive device
54+
sudo dd if=nixos-installer-x86_64-linux.iso of=/dev/sdX bs=4M status=progress conv=fsync
55+
```
56+
57+
**On macOS:**
58+
```bash
59+
# First unmount the drive (replace N with your disk number)
60+
diskutil unmountDisk /dev/diskN
61+
62+
# Write the image (replace N with your disk number)
63+
sudo dd if=nixos-installer-x86_64-linux.iso of=/dev/rdiskN bs=1m
64+
```
65+
66+
**On Windows:**
67+
We recommend using tools like [Rufus](https://rufus.ie/), [balenaEtcher](https://www.balena.io/etcher/), or [Ventoy](https://www.ventoy.net/) to write the ISO:
68+
1. Download and run one of these tools
69+
2. Select the downloaded ISO file
70+
3. Select your USB drive (the tool will show available drives)
71+
4. Start the writing process
72+
73+
#### Step 5: Boot from the USB drive
74+
75+
1. Insert the USB drive into the target computer
76+
2. Restart the computer
77+
3. **Disable Secure Boot in BIOS/UEFI** (NixOS installer currently requires Secure Boot to be disabled)
78+
4. Enter the boot menu (usually by pressing F12, F2, or Del during startup)
79+
5. Select the USB drive as the boot device
80+
81+
### Special Features of the NixOS Installer
82+
83+
Our installer has been optimized for both local and remote installations (like with [nixos-anywhere](https://github.com/numtide/nixos-anywhere) and [clan](https://docs.clan.lol/getting-started/installer/)):
84+
85+
* **SSH Access**: OpenSSH server is enabled by default for remote installations
86+
* **Security**: A random root password is generated on each boot
87+
* **Remote Access via Tor**: A Tor hidden SSH service is enabled, allowing access via `torify ssh <hash>.onion`
88+
* **Easy Configuration**: A QR code is displayed that contains local addresses and the root password
89+
* **Simplified WiFi Setup**: Includes [IWD](https://wiki.archlinux.org/title/iwd) daemon:
90+
* Run `iwctl` in the terminal for an interactive WiFi setup interface
91+
* Use `iwctl station list` to list WiFi adapters
92+
* Use `iwctl station <adapter> scan` to scan for networks
93+
* Use `iwctl station <adapter> connect <SSID>` to connect
94+
95+
### What's Next?
96+
97+
After booting the installer, you can:
98+
1. Use [disko](https://github.com/nix-community/disko) for declarative disk partitioning
99+
2. Follow the [NixOS manual](https://nixos.org/manual/nixos/stable/) for installation
100+
3. Use [nixos-anywhere](https://github.com/numtide/nixos-anywhere) for automated installation
101+
102+
![Screenshot of the installer](https://github.com/nix-community/nixos-images/releases/download/assets/image-installer-screenshot.jpg)
103+
104+
105+
## Kexec Tarballs
106+
107+
Kexec tarballs provide a way to boot the NixOS installer directly from an existing Linux system without requiring physical media or rebooting.
108+
109+
### What is Kexec?
110+
111+
Kexec is a mechanism in Linux that allows you to load and boot a new kernel from within a currently running Linux system. This is particularly useful for:
112+
113+
- **Remote server installations** where you don't have physical access
114+
- **Cloud providers** that don't offer NixOS as an installation option
115+
- **Quick system reinstalls** without needing to create bootable media
116+
117+
### Requirements
118+
119+
- Secure Boot must be disabled in BIOS/UEFI
120+
- At least 1GB of physical RAM (swap does not count)
121+
- Root access on the existing Linux system
122+
123+
### Using the Kexec Installer
124+
125+
#### Step 1: Download and Run the Installer
126+
127+
Run these commands as root on your existing Linux system:
128+
129+
```bash
22130
curl -L https://github.com/nix-community/nixos-images/releases/latest/download/nixos-kexec-installer-noninteractive-x86_64-linux.tar.gz | tar -xzf- -C /root
23131
/root/kexec/run
24132
```
25133

26-
The kexec installer comes with the following features:
134+
After executing these commands, there will be a short delay (6 seconds) before the kexec process replaces your current kernel with the NixOS installer kernel. This delay allows you to disconnect cleanly if running the commands over SSH.
27135

28-
- Re-uses ssh host keys from the sshd to not break `.ssh/known_hosts`
29-
- Authorized ssh keys are read from `/root/.ssh/authorized_keys`, `/root/.ssh/authorized_keys2` and `/etc/ssh/authorized_keys.d/root`
30-
- Static ip addresses and routes are restored after reboot.
31-
Interface that had dynamic addresses before are configured with DHCP and
32-
to accept prefixes from ipv6 router advertisement
136+
#### What Happens Next?
33137

34-
The actual kexec happens with a slight delay (6s). This allows for easier
35-
integration into automated nixos installation scripts, since you can cleanly
36-
disconnect from the running machine before the kexec takes place. The tarball
37-
is also designed to be run from NixOS, which can be useful for new installations
138+
- Your system will boot into a minimal NixOS installer environment
139+
- The installer runs entirely in RAM, allowing you to reformat all disks
140+
- Your previous system is no longer accessible until you reboot
38141

39-
## Iso installer images
142+
### Special Features
40143

41-
This image allows to boot a NixOS installer off a USB-Stick.
42-
This installer has been optimized for remote installation i.e.
43-
with [nixos-anywhere](https://github.com/numtide/nixos-anywhere) and [clan](https://docs.clan.lol/getting-started/installer/) notably:
144+
The kexec installer includes several features to make remote installation easier:
44145

45-
* Enables openssh by default
46-
* Generates a random root password on each login
47-
* Enables a Tor hidden SSH service so that by using the `torify ssh <hash>.onion`,
48-
one can log in from remote machines.
49-
* Prints a QR-Code that contains local addresses, the root password
50-
* Includes the [IWD](https://wiki.archlinux.org/title/iwd) deamon for easier wifi setups:
51-
* Run `iwctl` in the terminal for an interactive wifi setup interface.
146+
- **SSH Host Key Preservation**: Reuses SSH host keys from the existing system to prevent breaking `.ssh/known_hosts` on client machines
147+
- **SSH Key Authorization**: Automatically imports authorized keys from:
148+
- `/root/.ssh/authorized_keys`
149+
- `/root/.ssh/authorized_keys2`
150+
- `/etc/ssh/authorized_keys.d/root`
151+
- **Network Configuration Preservation**: Maintains static IP addresses and routes from your previous system
152+
- Interfaces with dynamic addresses are configured to use DHCP
153+
- IPv6 router advertisement is enabled for prefix delegation
52154

53-
![Screenshot of the installer](https://github.com/nix-community/nixos-images/releases/download/assets/image-installer-screenshot.jpg)
155+
### Automated Installation
156+
157+
The kexec installer is designed to work seamlessly with [nixos-anywhere](https://github.com/numtide/nixos-anywhere) for fully automated NixOS installations.
158+
159+
## Netboot Images
160+
161+
Netboot images allow you to boot NixOS over the network without requiring local installation media.
162+
163+
### What is Netboot?
164+
165+
Network booting (netboot) enables computers to boot and load an operating system from the network rather than from local storage. This is useful for:
166+
167+
- **Diskless workstations** that run entirely from network resources
168+
- **PXE boot environments** in data centers or computer labs
169+
- **Remote installations** where physical media is not available
170+
- **Testing and development** environments that need clean systems
171+
172+
### Components
173+
174+
Our netboot package consists of three main components:
175+
176+
1. **iPXE Script**: A configuration file that tells the network boot client what to load
177+
2. **Kernel Image**: The Linux kernel that will be booted
178+
3. **Initial RAM Disk (initrd)**: Contains the essential files needed to boot NixOS
179+
180+
### Using Netboot Images
181+
182+
#### Option 1: Direct iPXE Boot
183+
184+
If you already have an iPXE environment set up, you can use our prepared iPXE script:
185+
186+
```bash
187+
# Boot directly using our iPXE script
188+
chain https://github.com/nix-community/nixos-images/releases/download/nixos-unstable/netboot-x86_64-linux.ipxe
189+
```
190+
191+
#### Option 2: Manual Configuration
192+
193+
If you're setting up your own PXE/TFTP server, you'll need:
194+
195+
1. **Kernel**: [bzImage-x86_64-linux](https://github.com/nix-community/nixos-images/releases/download/nixos-unstable/bzImage-x86_64-linux)
196+
2. **Initial RAM Disk**: [initrd-x86_64-linux](https://github.com/nix-community/nixos-images/releases/download/nixos-unstable/initrd-x86_64-linux)
197+
198+
Configure your DHCP server to point to your TFTP server, and configure the TFTP server to serve these files.
199+
200+
### Server Configuration Example
201+
202+
Here's a basic example for setting up a TFTP/PXE server with dnsmasq:
203+
204+
```bash
205+
# Create a temporary environment with dnsmasq
206+
nix-shell -p dnsmasq
207+
208+
# Create a configuration file
209+
cat > dnsmasq.conf << EOF
210+
interface=eth0
211+
dhcp-range=192.168.1.100,192.168.1.150,12h
212+
dhcp-boot=pxelinux.0
213+
enable-tftp
214+
tftp-root=/srv/tftp
215+
EOF
216+
217+
# Create the TFTP directory
218+
mkdir -p /srv/tftp/nixos
219+
220+
# Download the netboot files
221+
curl -o /srv/tftp/nixos/bzImage https://github.com/nix-community/nixos-images/releases/download/nixos-unstable/bzImage-x86_64-linux
222+
curl -o /srv/tftp/nixos/initrd https://github.com/nix-community/nixos-images/releases/download/nixos-unstable/initrd-x86_64-linux
223+
224+
# Run dnsmasq
225+
dnsmasq --conf-file=dnsmasq.conf --no-daemon
226+
```
227+
228+
### Further Resources
54229

55-
## Netboot images
230+
For more detailed information on network booting:
56231

57-
You can boot the netboot image using this [ipxe script](https://github.com/nix-community/nixos-images/releases/download/nixos-unstable/netboot-x86_64-linux.ipxe).
58-
It consists of the [kernel image](https://github.com/nix-community/nixos-images/releases/download/nixos-unstable/bzImage-x86_64-linux) and [initrd](https://github.com/nix-community/nixos-images/releases/download/nixos-unstable/initrd-x86_64-linux).
232+
- [NixOS Netboot Documentation](https://wiki.nixos.org/wiki/Netboot)
233+
- [iPXE Documentation](https://ipxe.org/start)

0 commit comments

Comments
 (0)