Repository navigation
Expand file tree
/
Copy pathboot.html
More file actions
159 lines (143 loc) · 19.7 KB
/
Copy pathboot.html
File metadata and controls
159 lines (143 loc) · 19.7 KB
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
150
151
152
153
154
155
156
157
158
159
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Boot - UraniumOS</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<header><div class="in"><nav class="l"><a href="index.html">Home</a><a href="download.html">Download</a><a href="docs.html" aria-current="page">Documentation</a><a href="rod.html">Packages</a><a href="news.html">News</a><a href="about.html">About</a></nav><nav class="r"><a href="features.html">Features</a><a href="media.html">Install</a><a href="security.html">Security</a><a href="hardware.html">Hardware</a></nav></div></header>
<main class="in docs">
<aside><div class="sbhead"><a class="sbh" href="index.html">⌂ UraniumOS</a><svg aria-hidden="true" viewBox="-50 -50 100 100"><circle r="48" fill="#f2d21b"/><circle r="6.5" fill="#1b1b19"/><path fill="#1b1b19" d="M6.50 -11.26 A13 13 0 0 0 -6.50 -11.26 L-20.00 -34.64 A40 40 0 0 1 20.00 -34.64 Z M-13.00 -0.00 A13 13 0 0 0 -6.50 11.26 L-20.00 34.64 A40 40 0 0 1 -40.00 -0.00 Z M6.50 11.26 A13 13 0 0 0 13.00 0.00 L40.00 0.00 A40 40 0 0 1 20.00 34.64 Z"/></svg><span class="ver">0.1.1</span><input type="search" placeholder="Search docs" aria-label="Search docs"></div><h4>Read first</h4><ul><li><a href="differences.html">Differences and known failures</a></li></ul><h4>1 Installation</h4><ul><li><a href="download.html">1.1 Download</a></li><li><a href="media.html">1.2 Live medium</a></li><li><a href="partitioning.html">1.3 Partitioning notes</a></li><li><a href="manual-install.html">1.4 Manual install</a></li><li><a href="first-steps.html">1.5 First steps</a></li></ul><h4>2 Configuration</h4><ul><li><a href="users.html">2.1 Users and groups</a></li><li><a href="keyboard.html">2.2 Keyboard</a></li><li><a href="time.html">2.3 Date and time</a></li><li><a href="services.html">2.4 Services</a></li><li><a href="cron.html">2.5 Cron</a></li><li><a href="network.html">2.6 Network</a></li><li><a href="ssh.html">2.7 SSH</a></li><li><a href="blastdoor.html">2.8 Firewall</a></li><li><a href="desktop.html">2.9 Desktop</a></li><li><a href="firmware.html">2.10 Firmware</a></li><li><a href="boot.html" aria-current="page">2.11 Boot</a></li><li><a href="kernel.html">2.12 Kernel</a></li><li><a href="storage.html">2.13 Storage</a></li><li><a href="security.html">2.14 Security</a></li><li><a href="geiger.html">2.15 Health report</a></li></ul><h4>3 Packages</h4><ul><li><a href="rod.html">3.1 rod</a></li><li><a href="cheatsheet.html">3.2 rod cheat sheet</a></li><li><a href="not-in-rod.html">3.3 Package not in rod</a></li><li><a href="recipes.html">3.4 Recipes</a></li><li><a href="silo.html">3.5 Containers</a></li><li><a href="hazmat.html">3.6 Sandboxes</a></li></ul><h4>4 Snapshots</h4><ul><li><a href="scram.html">4.1 scram</a></li><li><a href="backups.html">4.2 Backups</a></li></ul><h4>5 Reference</h4><ul><li><a href="system.html">5.1 System and files</a></li><li><a href="troubleshooting.html">5.2 Troubleshooting</a></li><li><a href="hardware.html">5.3 Hardware status</a></li><li><a href="faq.html">5.4 FAQ</a></li></ul><h4>6 Project</h4><ul><li><a href="developers.html">6.1 Developers</a></li><li><a href="contributing.html">6.2 Contributing</a></li><li><a href="about.html">6.3 About</a></li><li><a href="features.html">6.4 Features</a></li><li><a href="news.html">6.5 News</a></li></ul></aside><article><div class="band"><h1>Boot</h1></div>
<p>UraniumOS boots on UEFI machines. The firmware starts limine from the EFI System Partition, limine loads the kernel and an initramfs, and the initramfs finds the root, applies pending changes from <a href="scram.html">scram</a>, mounts the root and starts busybox init, which runs <code>/etc/rc</code> and <code>runsvdir</code> (see <a href="services.html">services</a>). The kernel has no module support. BIOS and Secure Boot are not supported.</p>
<h2>The boot partition</h2>
<p>The partition has the label <code>URANIUMESP</code>, is FAT32 and is mounted on <code>/boot</code> with <code>umask=0077,nodev,nosuid,noexec</code>. <code>scram boot</code> writes everything on it except what the firmware needs to find limine:</p>
<pre><code>/boot/EFI/BOOT/BOOTX64.EFI limine, copied from the profile
/boot/limine.conf the menu
/boot/uranium/vmlinuz the kernel of the profile
/boot/uranium/initrd the initramfs of the profile
/boot/uranium/k-HASH/vmlinuz a kernel kept for older frames
/boot/uranium/k-HASH/initrd</code></pre>
<p>The firmware has to start <code>EFI/BOOT/BOOTX64.EFI</code>, the path UEFI uses for removable media. Nothing in UraniumOS writes a boot entry into the firmware, so if the firmware does not start from this path, add an entry in its setup.</p>
<p>The partition is not part of any frame. To rebuild it, run <code>scram boot</code> from the installed system, or from a live medium with the root mounted. It copies the kernel, the initramfs and limine again and writes the menu. See <a href="manual-install.html">manual install</a> for the chroot.</p>
<h2>The boot menu</h2>
<p><code>scram boot [N]</code> writes <code>limine.conf</code> and the files above. The menu is also rewritten by every <code>scram frame</code> when <code>/boot/limine.conf</code> exists, and after every successful <code>rod +i</code>, <code>+r</code>, <code>+u</code> and <code>+a</code>. Those automatic runs hide errors; run <code>scram boot</code> to see them. The initramfs never writes to the partition, so frames it takes (<code>pre-commit</code>, <code>pre-flash</code>, <code>pre-revert</code>) show in the menu only after the next run.</p>
<pre><code>timeout: 3
serial: yes
/UraniumOS
protocol: linux
path: boot():/uranium/vmlinuz
module_path: boot():/uranium/initrd
cmdline: root=LABEL=uranium rw console=tty0 console=ttyS0,115200 slab_nomerge vsyscall=none debugfs=off randomize_kstack_offset=on
/Frame 20261029-030000-auto
protocol: linux
path: boot():/uranium/vmlinuz
module_path: boot():/uranium/initrd
cmdline: root=LABEL=uranium rw console=tty0 console=ttyS0,115200 slab_nomerge vsyscall=none debugfs=off randomize_kstack_offset=on uranium.frame=20261029-030000-auto
/Frame 20261029-010000-auto
protocol: linux
path: boot():/uranium/k-aaaaaaaaaaaa/vmlinuz
module_path: boot():/uranium/k-aaaaaaaaaaaa/initrd
cmdline: root=LABEL=uranium rw console=tty0 console=ttyS0,115200 slab_nomerge vsyscall=none debugfs=off randomize_kstack_offset=on uranium.frame=20261029-010000-auto
/Rescue shell
protocol: linux
path: boot():/uranium/vmlinuz
module_path: boot():/uranium/initrd
cmdline: root=LABEL=uranium rw console=tty0 console=ttyS0,115200 slab_nomerge vsyscall=none debugfs=off randomize_kstack_offset=on uranium.shell</code></pre>
<p>This is <code>scram boot</code> output, shortened. The second frame was taken with another kernel.</p>
<dl>
<dt><code>timeout: 3</code>, <code>serial: yes</code></dt><dd>limine waits three seconds and then starts the first entry. The menu also shows on the serial port, so a VM or a headless machine can pick an entry there. The kernel console is <code>console=tty0 console=ttyS0,115200</code>.</dd>
<dt><code>UraniumOS</code></dt><dd>The system as it is. It is first, so it is the default.</dd>
<dt><code>Frame ID</code></dt><dd>One entry per frame, newest first. The entry adds <code>uranium.frame=ID</code> to the command line, and the initramfs boots writable copies of the frame, see <a href="#frameboot">below</a>. <code>scram boot 20</code> lists only the newest twenty, but the next automatic run lists all frames again.</dd>
<dt><code>Rescue shell</code></dt><dd>Adds <code>uranium.shell</code>. The initramfs opens a shell before it touches the root.</dd>
</dl>
<p>The command line of each entry is <code>root=LABEL=uranium rw console=tty0 console=ttyS0,115200</code>, then the contents of <code>/etc/cmdline</code> (keep it to one line), then the argument of the entry. The label comes from <code>SCRAM_LABEL</code>. The stage ships <code>/etc/cmdline</code> with <code>slab_nomerge vsyscall=none debugfs=off randomize_kstack_offset=on</code>, see <a href="kernel.html">kernel</a>. Run <code>scram boot</code> after editing the file. Press <code>e</code> in the menu to change one boot without saving it.</p>
<h3>Kernels in frames</h3>
<p>A frame stores the kernel and initramfs of the profile when it was taken, and an <code>id</code> that is a hash of both. <code>scram boot</code> compares that hash with the current kernel. A frame with a different kernel boots from <code>/boot/uranium/k-HASH/</code>. Each kernel is copied there once, and at most three are kept (<code>SCRAM_KERNELS</code>). A frame that would need a fourth boots with the current kernel, and so does a frame without a stored kernel, such as frames taken by the initramfs or received with <code>scram receive</code>. A <code>k-HASH</code> directory that no frame uses is deleted.</p>
<p>After a flash, a commit or a revert the partition still holds the earlier kernel. <code>scram doctor</code> warns about it and <code>scram boot</code> fixes it. A new kernel from <code>rod +u</code> reaches the partition at the next <code>scram boot</code>, which is the next frame or rod operation, or in an hour at the latest through <code>autoframe</code>. <a href="geiger.html">geiger</a> warns when the running kernel differs from the one in the profile.</p>
<h2>Kernel arguments</h2>
<p>The initramfs reads these from <code>/proc/cmdline</code>. Other arguments go to the kernel.</p>
<table>
<tr><td><code>root=SPEC</code></td><td>The btrfs filesystem. SPEC is <code>LABEL=</code>, <code>UUID=</code>, <code>PARTUUID=</code> or <code>PARTLABEL=</code> with a value, or the path of a block device. The initramfs waits up to 20 seconds for it.</td></tr>
<tr><td><code>init=PATH</code></td><td>The program to start after <code>switch_root</code>. Default <code>/rod/init/bin/init</code>.</td></tr>
<tr><td><code>uranium.frame=ID</code></td><td>Boot writable copies of the frame ID. Use the full directory name.</td></tr>
<tr><td><code>uranium.shell</code></td><td>Open a shell in the initramfs before anything else. <code>exit</code> continues the boot.</td></tr>
<tr><td><code>uranium.luks=DEVICE</code></td><td>Unlock an encrypted device first, see <a href="storage.html">storage</a>.</td></tr>
<tr><td><code>uranium.luks.key=FILE</code></td><td>Unlock with this key file and ask no passphrase.</td></tr>
<tr><td><code>uranium.live</code></td><td>Start from the ISO. The live medium sets it.</td></tr>
</table>
<p></p>
<h2>The initramfs</h2>
<p>The initramfs is the package <code>initramfs-uranium</code>: a gzip-compressed cpio archive with <code>uranium-init.sh</code> as <code>/init</code>, <code>btrfs</code> and <code>cryptsetup</code>, and some busybox applets. It has no scram, rsync or <code>cp</code>. The steps, in order:</p>
<ol>
<li>Mount <code>/proc</code>, <code>/sys</code> and <code>/dev</code> and read the command line. With <code>uranium.shell</code>, say that a shell is starting and run it.</li>
<li>With <code>uranium.live</code>, find the medium (below) and stop here.</li>
<li>With <code>uranium.luks</code>, unlock the device as <code>uranium-root</code>.</li>
<li>Wait up to 20 seconds for the root device and mount its top level (subvolume 5) on <code>/top</code>.</li>
<li>Unless a frame boot was asked for, revert an update that was not confirmed.</li>
<li>Carry out the action in <code>.scram/boot-action</code>.</li>
<li>With <code>uranium.frame</code>, make writable copies of the frame.</li>
<li>Mount the root subvolume (and for a frame boot the home copy on <code>/home</code>), move the top level to <code>/run/scram/top</code> in the new root, unmount <code>/proc</code>, <code>/sys</code> and <code>/dev</code> and run <code>switch_root</code>.</li>
</ol>
<p>When a step fails, the initramfs reports what failed, says that it is dropping to a shell, and runs the shell. These are the causes:</p>
<p>The initramfs stops and drops to a shell when the root device does not appear within 20 seconds, when a device or the root subvolume cannot be mounted, when the frame named in <code>uranium.frame=</code> does not exist, when the encrypted device is missing or cannot be unlocked, or when the live medium or its image cannot be found or mounted.</p>
<p>The shell is busybox <code>sh</code>. To look at the filesystem from it, run <code>mount -t btrfs -o subvolid=5 /dev/DEVICE /top</code>. Leaving the shell with <code>exit</code> after a failure ends init and the kernel panics.</p>
<h3>Live medium</h3>
<p>The ISO has its own limine menu with the entries "UraniumOS live" and "UraniumOS live, shell in the initramfs", both with <code>uranium.live</code>. The initramfs looks for an ISO 9660 filesystem with <code>/live/root.squashfs</code> on every <code>/dev/sr*</code>, <code>/dev/vd*</code>, <code>/dev/sd*</code> and <code>/dev/nvme*n*</code> for up to 30 seconds. It mounts the image through a loop device, puts a tmpfs of 75% of the memory on top with an overlay, moves the mounts to <code>/run/live</code> and starts init. Changes in the live system stay in memory.</p>
<h3 id="frameboot">Booting a frame</h3>
<p>The initramfs snapshots <code>.scram/ID/@</code> and <code>@home</code> into <code>.scram/live/@</code> and <code>@home</code>, replacing the copies of an earlier frame boot, and mounts them as root and as <code>/home</code>. The frame itself is not touched. Everything done in a frame boot, including packages, files and home directories, is lost at the next frame boot. To keep the state of a frame, boot it and run <code>scram flash FRAME</code> or <code>scram flash --boot FRAME</code> from there.</p>
<p>A frame boot does not revert an update on trial and does not count as a boot for it.</p>
<h2 id="actions">Changes at boot</h2>
<p>The root subvolume cannot be replaced while it is mounted, so <code>scram commit --boot</code> and <code>scram flash --boot</code> write one line to <code>.scram/boot-action</code> and the initramfs carries it out. <code>scram status</code> shows it while it is waiting, and <code>scram cancel</code> deletes it. The initramfs deletes the file after it acts, whatever the result.</p>
<table>
<tr><td><code>commit</code></td><td>If <code>.scram/try/@</code> exists: take a frame labelled <code>pre-commit</code>, replace <code>@</code> with the copy, delete <code>.scram/try</code>, write the id of <code>pre-commit</code> to <code>.scram/trial</code> and create <code>.scram/trial-boot</code>. It tells you that the update was committed on trial and which frame undoes it. With no copy, it does nothing.</td></tr>
<tr><td><code>flash ID</code>, <code>flash ID @</code></td><td>If the frame exists: take a frame labelled <code>pre-flash</code>, replace <code>@</code> and <code>@home</code> (or only <code>@</code>) with copies of the frame, and tell you which frame it flashed and how to undo it. A frame that does not exist is skipped without a message.</td></tr>
</table>
<p>Replacing a subvolume moves it's left-out subvolumes into the new copy, deletes the old one and moves the new one into its place. Frames taken by the initramfs have two snapshots and nothing else, no note and no kernel copy.</p>
<h3 id="trial">Trial boots and the revert</h3>
<p>A commit at boot leaves the system on trial. Two files in <code>.scram</code> describe it, <code>trial</code> with the id of the <code>pre-commit</code> frame and an empty <code>trial-boot</code>. The initramfs applies these rules in order:</p>
<ol>
<li>At a normal boot, when <code>trial</code> exists: if <code>trial-boot</code> also exists and the <code>pre-commit</code> frame still has its <code>@</code>, take a <code>pre-revert</code> frame, replace <code>@</code> with a copy of <code>pre-commit</code> and tell you that the update was not confirmed and was reverted. Then delete both files. Home directories are not changed.</li>
<li>The <code>commit</code> action, if scheduled, runs after that and starts a new trial.</li>
<li>Booting a frame skips the first rule and leaves the files for the next normal boot.</li>
</ol>
<p>An update survives one boot unless <code>scram confirm</code> removes <code>trial-boot</code> before the next normal boot. The <code>trial</code> service does that by running <code>scram verify</code> at every boot. It waits five minutes, runs <a href="geiger.html">geiger</a> up to three times and confirms on a pass. If geiger still fails, <code>verify</code> reboots and the initramfs reverts. If the system cannot start at all, the next reset boots into the revert. <a href="scram.html">scram</a> lists <code>verify</code> and its variables.</p>
<pre><code># rod +u
updating in a copy of the system
...
update ok, pending: commit with scram commit --boot
# scram commit --boot
commit scheduled for the next boot, it reverts unless you run scram confirm or the system stays healthy
# reboot
...
update committed on trial, undo with frame 20261102-165517-pre-commit</code></pre>
<p>The same update, not confirmed:</p>
<pre><code># reboot
...
update was not confirmed, reverted to frame 20261102-165517-pre-commit, undo with frame 20261102-165524-pre-revert</code></pre>
<p>The ids are examples. To undo a revert, flash the <code>pre-revert</code> frame. To undo a confirmed commit, flash the <code>pre-commit</code> frame.</p>
<p>The revert replaces <code>@</code> and not <code>@home</code>, it applies only at the first normal boot after a commit, and it needs a normal boot to be possible. If limine, the kernel or the partition is broken, choose a frame in the menu or use the live medium.</p>
<h2>After the initramfs</h2>
<p>The init program is busybox init with this <code>/etc/inittab</code>:</p>
<pre><code>::sysinit:/etc/rc
::respawn:/rod/profile/bin/runsvdir -P /etc/service
::ctrlaltdel:/rod/init/bin/reboot
::shutdown:/etc/rc.shutdown</code></pre>
<p><code>/etc/rc</code> mounts <code>/proc</code>, <code>/sys</code>, <code>/dev</code>, <code>/dev/pts</code>, <code>/dev/shm</code>, <code>/tmp</code> and <code>/run</code>, keeps <code>/run/scram/top</code> across the new tmpfs, remounts the root read-write and runs <code>mount -a</code>. Then it sets the hostname, loads the keymap, <code>/etc/sysctl.conf</code> and <code>/etc/nftables.conf</code> if they exist, sets up zram swap, brings up <code>lo</code> and runs <code>/etc/rc.local</code>. <code>runsvdir</code> starts the services in <code>/etc/service</code>. <code>/etc/rc.shutdown</code> runs <code>sync</code> and <code>umount -a -r</code>.</p>
<h2>When it does not boot</h2>
<ol>
<li>Choose a <code>Frame</code> entry from before the change. It changes nothing on disk. If it works, run <code>scram flash FRAME</code> to keep it, see <a href="scram.html">scram</a>.</li>
<li>If no menu appears the firmware did not start limine from the boot partition. If the partition is empty or damaged, boot the <a href="media.html">live medium</a>, mount the root and the partition as in the manual install, and run <code>scram boot</code> in the chroot.</li>
<li>If the initramfs stops in a shell, read the message above it. If it says that no root device was found, the label is not <code>uranium</code>, or the disk is not visible.</li>
<li>The <code>Rescue shell</code> entry gives a shell in the initramfs.</li>
</ol>
<p>More is in <a href="troubleshooting.html">troubleshooting</a>.</p>
<div class="pager"><a href="firmware.html">← Firmware</a><a href="kernel.html">Kernel →</a></div></article>
</main>
<footer><div class="in"><p>Public domain, CC0 1.0</p><p><a href="https://github.com/uranium-os">GitHub</a> <a href="https://texivi.github.io">Blog</a></p></div></footer>
<script>document.querySelectorAll("pre:not(.term):not(.portrait)").forEach(function(p){var b=document.createElement("button");b.textContent="\u29c9";b.title="Copy";b.onclick=function(){navigator.clipboard.writeText(p.innerText.replace(/\u29c9$/,"").trim());b.textContent="\u2713";setTimeout(function(){b.textContent="\u29c9"},900)};p.appendChild(b)});</script>
<script src="docs.js"></script>
<script src="fun.js"></script>
</body>
</html>