summaryrefslogtreecommitdiff
path: root/tinyrd.8
blob: b64ef20f3232641650ef9b595d1e699f1303e730 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
.Dd October 3, 2026
.Dt TINYRD 8
.Os
.Sh NAME
.Nm tinyrd
.Nd the rawnix initramfs
.Sh SYNOPSIS
.Nm
.Fl o Ar file
.Sh DESCRIPTION
.Nm
is one static binary with two roles.
Run with
.Fl o
it writes a cpio archive whose
.Pa /init
is the binary itself; run as
.Pa /init
by the kernel it unlocks an encrypted root if there is one, mounts
root, and hands over to the real init.
.Pp
The archive carries no kernel modules and no configuration, so one
image serves every kernel: nothing has to be regenerated when a kernel
is installed or removed, and
.Xr limine-sync 8
refers to it by a name with no version in it.
The price is that everything needed before root is mounted must be
built into the kernel; see
.Sx KERNEL REQUIREMENTS .
.Pp
The package ships the finished image as
.Pa /boot/tinyrd.img ,
so building one by hand is only necessary when changing
.Nm
itself.
.Sh THE BOOT PATH
As
.Pa /init ,
.Nm
reads the kernel command line and nothing else.
.Bl -tag -width rootfstype=
.It Li root=
Required: the root filesystem, as
.Pa /dev/ Ns Ar ...
or
.Li UUID= Ns Ar uuid .
The UUID form survives the disk being renamed, which
.Pa /dev/sda2
does not: adding a drive, moving a cable or booting the same image in a
virtual machine is enough to change it.
With
.Li cryptroot=
this must be the mapped device,
.Pa /dev/mapper/ Ns Ar name .
.It Li cryptroot=
Optional: the UUID of the
.Em LUKS partition ,
from
.Ic cryptsetup luksUUID ,
not of the filesystem inside it.
.Nm
asks for the passphrase and creates the mapping under the name taken
from
.Li root= .
Without this key it mounts
.Li root=
directly, so the same image boots an unencrypted system.
.It Li rootfstype=
Default
.Li ext4 .
.It Li rootflags=
Passed to
.Xr mount 2
as its data argument.
.It Li ro | rw
Default
.Li ro ;
the last one on the line wins.
.It Li init=
Default
.Pa /sbin/init .
.El
.Pp
After the switch, the new root sees exactly what the kernel would leave
it with no initramfs at all: devtmpfs on
.Pa /dev ,
root mounted, nothing else.
Stage 1 needs no knowledge of
.Nm .
.Sh KERNEL REQUIREMENTS
Because the image carries no modules, the kernel must have built in:
.Bd -literal -offset indent
BLK_DEV_INITRD DEVTMPFS
BLK_DEV_DM DM_CRYPT CRYPTO_XTS
CRYPTO_AES_NI_INTEL CRYPTO_SHA256 CRYPTO_HMAC
CRYPTO_USER_API_SKCIPHER CRYPTO_USER_API_HASH
.Ed
.Pp
plus the root filesystem itself and whatever the keyboard needs to type
a passphrase: i8042 and atkbd on most machines, xhci and usbhid for USB.
.Pp
libcryptsetup here uses the kernel crypto backend, so every hash goes
through AF_ALG.
Without
.Li CRYPTO_USER_API_HASH
the LUKS header will not load and the message is
.Dq Cannot initialize crypto backend .
.Pp
The rawnix kernels have all of this; a hand-rolled configuration is the
place this goes wrong.
.Sh FILES
.Bl -tag -width Ds -compact
.It Pa /boot/tinyrd.img
The image, staged by the package and copied to the ESP by
.Xr limine-sync 8 .
.El
.Sh EXIT STATUS
.Ex -std
As
.Pa /init
there is nowhere to return to: on a failure it reports what went wrong
and stops, leaving the machine at a point where the message can be
read.
.Sh EXAMPLES
Build an image:
.Dl $ tinyrd -o tinyrd.img
.Pp
A command line for an encrypted root, as
.Xr limine-sync 8
would write it:
.Bd -literal -offset indent
cryptroot=UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx \e
    root=/dev/mapper/croot ro quiet
.Ed
.Pp
and for an unencrypted one:
.Bd -literal -offset indent
root=UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx ro quiet
.Ed
.Sh SEE ALSO
.Xr encryption 7 ,
.Xr rawnix 7 ,
.Xr cryptsetup 8 ,
.Xr limine-sync 8
.Sh AUTHORS
.An zorz Aq Mt zorz@rawnix.org
.Sh CAVEATS
The passphrase is typed before any keyboard layout is loaded, so it is
read as if on a US keyboard.