git.iko.soy/typeable/nixpkgs
on master help sign in
doc: Reviews partitioning instructions to use parted.

The tests in <nixos/tests/installer.nix> are using `parted`, so they are bound to be better tested than `fdisk`. This is brought on by a couple issues, plus reports on IRC that the `fdisk` instructions didn't work as expected. * #39354 * #46309 * #39942 * #45478 Care was taken so that the other documented steps did not need changes. In all this kerfufle, a slight re-organization of the Chapter has been made, allowing better deep linking.

commit6cfbf403ca327017257ddbd742e312f3304b64cc authorSamuel Dionne-Riel <samuel@dionne-riel.com> dateMon 1 Oct 2018, 23:57 (8 years ago) parent8467dc8
1 file changed+409−298
nixos/doc/manual/installation/installing.xml+409−298
nixos/doc/manual/installation/installing.xml+409−298
@@ -4,60 +4,46 @@
44 version="5.0"
55 xml:id="sec-installation">
66 <title>Installing NixOS</title>
7− <para>
8− NixOS can be installed on BIOS or UEFI systems. The procedure for a UEFI
9− installation is by and large the same as a BIOS installation. The differences
10− are mentioned in the steps that follow.
11− </para>
12− <orderedlist>
13− <listitem>
14− <para>
15− Boot from the CD.
16− </para>
17− <variablelist>
18− <varlistentry>
19− <term>
20− UEFI systems
21− </term>
22− <listitem>
23− <para>
24− You should boot the live CD in UEFI mode (consult your specific
25− hardware's documentation for instructions). You may find the
26− <link xlink:href="http://www.rodsbooks.com/refind">rEFInd boot
27− manager</link> useful.
28− </para>
29− </listitem>
30− </varlistentry>
31− </variablelist>
32− </listitem>
33− <listitem>
34− <para>
35− The CD contains a basic NixOS installation. (It also contains Memtest86+,
36− useful if you want to test new hardware). When it’s finished booting, it
37− should have detected most of your hardware.
38− </para>
39− </listitem>
40− <listitem>
41− <para>
42− The NixOS manual is available on virtual console 8 (press Alt+F8 to access)
43− or by running <command>nixos-help</command>.
44− </para>
45− </listitem>
46− <listitem>
47− <para>
48− You get logged in as <literal>root</literal> (with empty password).
49− </para>
50− </listitem>
51− <listitem>
52− <para>
53− If you downloaded the graphical ISO image, you can run <command>systemctl
54− start display-manager</command> to start KDE. If you want to continue on
55− the terminal, you can use <command>loadkeys</command> to switch to your
56− preferred keyboard layout. (We even provide neo2 via <command>loadkeys de
57− neo</command>!)
58− </para>
59− </listitem>
60− <listitem>
7+ <section xml:id="sec-installation-booting">
8+ <title>Booting the system</title>
9+
10+ <para>
11+ NixOS can be installed on BIOS or UEFI systems. The procedure for a UEFI
12+ installation is by and large the same as a BIOS installation. The
13+ differences are mentioned in the steps that follow.
14+ </para>
15+
16+ <para>
17+ The installation media can be burned to a CD, or now more commonly, "burned"
18+ to a USB drive (see <xref linkend="sec-booting-from-usb"/>).
19+ </para>
20+
21+ <para>
22+ The installation media contains a basic NixOS installation. When it’s
23+ finished booting, it should have detected most of your hardware.
24+ </para>
25+
26+ <para>
27+ The NixOS manual is available on virtual console 8 (press Alt+F8 to access)
28+ or by running <command>nixos-help</command>.
29+ </para>
30+
31+ <para>
32+ You are logged-in automatically as <literal>root</literal>. (The
33+ <literal>root</literal> user account has an empty password.)
34+ </para>
35+
36+ <para>
37+ If you downloaded the graphical ISO image, you can run <command>systemctl
38+ start display-manager</command> to start KDE. If you want to continue on the
39+ terminal, you can use <command>loadkeys</command> to switch to your
40+ preferred keyboard layout. (We even provide neo2 via <command>loadkeys de
41+ neo</command>!)
42+ </para>
43+
44+ <section xml:id="sec-installation-booting-networking">
45+ <title>Networking in the installer</title>
46+
6147 <para>
6248 The boot process should have brought up networking (check <command>ip
6349 a</command>). Networking is necessary for the installer, since it will
@@ -65,58 +51,165 @@
6551 binaries). It’s best if you have a DHCP server on your network. Otherwise
6652 configure networking manually using <command>ifconfig</command>.
6753 </para>
54+
6855 <para>
6956 To manually configure the network on the graphical installer, first disable
7057 network-manager with <command>systemctl stop network-manager</command>.
7158 </para>
59+
7260 <para>
7361 To manually configure the wifi on the minimal installer, run
7462 <command>wpa_supplicant -B -i interface -c &lt;(wpa_passphrase 'SSID'
7563 'key')</command>.
7664 </para>
77− </listitem>
78− <listitem>
65+
7966 <para>
8067 If you would like to continue the installation from a different machine you
8168 need to activate the SSH daemon via <literal>systemctl start
8269 sshd</literal>. In order to be able to login you also need to set a
8370 password for <literal>root</literal> using <literal>passwd</literal>.
8471 </para>
85− </listitem>
86− <listitem>
72+ </section>
73+ </section>
74+ <section xml:id="sec-installation-partitioning">
75+ <title>Partitioning and formatting</title>
76+
77+ <para>
78+ The NixOS installer doesn’t do any partitioning or formatting, so you need
79+ to do that yourself.
80+ </para>
81+
82+ <para>
83+ The NixOS installer ships with multiple partitioning tools. The examples
84+ below use <command>parted</command>, but also provides
85+ <command>fdisk</command>, <command>gdisk</command>,
86+ <command>cfdisk</command>, and <command>cgdisk</command>.
87+ </para>
88+
89+ <para>
90+ The recommended partition scheme differs depending if the computer uses
91+ <emphasis>Legacy Boot</emphasis> or <emphasis>UEFI</emphasis>.
92+ </para>
93+
94+ <section xml:id="sec-installation-partitioning-UEFI">
95+ <title>UEFI (GPT)</title>
96+
8797 <para>
88− The NixOS installer doesn’t do any partitioning or formatting yet, so you
89− need to do that yourself. Use the following commands:
90− <itemizedlist>
98+ Here's an example partition scheme for UEFI, using
99+ <filename>/dev/sda</filename> as the device.
100+ <note>
101+ <para>
102+ You can safely ignore <command>parted</command>'s informational message
103+ about needing to update /etc/fstab.
104+ </para>
105+ </note>
106+ </para>
107+
108+ <para>
109+ <orderedlist>
91110 <listitem>
92111 <para>
93− For partitioning: <command>fdisk</command>.
94−<screen>
95−# fdisk /dev/sda # <lineannotation>(or whatever device you want to install on)</lineannotation>
96−-- for UEFI systems only
97−> n # <lineannotation>(create a new partition for /boot)</lineannotation>
98−> 3 # <lineannotation>(make it a partition number 3)</lineannotation>
99−> # <lineannotation>(press enter to accept the default)</lineannotation>
100−> +512M # <lineannotation>(the size of the UEFI boot partition)</lineannotation>
101−> t # <lineannotation>(change the partition type ...)</lineannotation>
102−> 3 # <lineannotation>(... of the boot partition ...)</lineannotation>
103−> 1 # <lineannotation>(... to 'UEFI System')</lineannotation>
104−-- for BIOS or UEFI systems
105−> n # <lineannotation>(create a new partition for /swap)</lineannotation>
106−> 2 # <lineannotation>(make it a partition number 2)</lineannotation>
107−> # <lineannotation>(press enter to accept the default)</lineannotation>
108−> +8G # <lineannotation>(the size of the swap partition, set to whatever you like)</lineannotation>
109−> n # <lineannotation>(create a new partition for /)</lineannotation>
110−> 1 # <lineannotation>(make it a partition number 1)</lineannotation>
111−> # <lineannotation>(press enter to accept the default)</lineannotation>
112−> # <lineannotation>(press enter to accept the default and use the rest of the remaining space)</lineannotation>
113−> a # <lineannotation>(make the partition bootable)</lineannotation>
114−> x # <lineannotation>(enter expert mode)</lineannotation>
115−> f # <lineannotation>(fix up the partition ordering)</lineannotation>
116−> r # <lineannotation>(exit expert mode)</lineannotation>
117−> w # <lineannotation>(write the partition table to disk and exit)</lineannotation></screen>
112+ Create a <emphasis>GPT</emphasis> partition table.
113+<screen language="commands"># parted /dev/sda -- mklabel gpt</screen>
118114 </para>
119115 </listitem>
116+ <listitem>
117+ <para>
118+ Add a <emphasis>swap</emphasis> partition. The size required will vary
119+ according to needs, here a 8GiB one is created. The space left in front
120+ (512MiB) will be used by the boot partition.
121+<screen language="commands"># parted /dev/sda -- mkpart primary linux-swap 512MiB 8.5GiB</screen>
122+ <note>
123+ <para>
124+ The swap partition size rules are no different than for other Linux
125+ distributions.
126+ </para>
127+ </note>
128+ </para>
129+ </listitem>
130+ <listitem>
131+ <para>
132+ Next, add the <emphasis>root</emphasis> partition. This will fill the
133+ remainder ending part of the disk.
134+<screen language="commands"># parted /dev/sda -- mkpart primary 8.5GiB -1MiB</screen>
135+ </para>
136+ </listitem>
137+ <listitem>
138+ <para>
139+ Finally, the <emphasis>boot</emphasis> partition. NixOS by default uses
140+ the ESP (EFI system partition) as its <emphasis>/boot</emphasis>
141+ partition. It uses the initially reserved 512MiB at the start of the
142+ disk.
143+<screen language="commands"># parted /dev/sda -- mkpart ESP fat32 1M 512MiB
144+# parted /dev/sda -- set 3 boot on</screen>
145+ </para>
146+ </listitem>
147+ </orderedlist>
148+ </para>
149+
150+ <para>
151+ Once complete, you can follow with
152+ <xref linkend="sec-installation-partitioning-formatting"/>.
153+ </para>
154+ </section>
155+
156+ <section xml:id="sec-installation-partitioning-MBR">
157+ <title>Legacy Boot (MBR)</title>
158+
159+ <para>
160+ Here's an example partition scheme for Legacy Boot, using
161+ <filename>/dev/sda</filename> as the device.
162+ <note>
163+ <para>
164+ You can safely ignore <command>parted</command>'s informational message
165+ about needing to update /etc/fstab.
166+ </para>
167+ </note>
168+ </para>
169+
170+ <para>
171+ <orderedlist>
172+ <listitem>
173+ <para>
174+ Create a <emphasis>MBR</emphasis> partition table.
175+<screen language="commands"># parted /dev/sda -- mklabel msdos</screen>
176+ </para>
177+ </listitem>
178+ <listitem>
179+ <para>
180+ Add a <emphasis>swap</emphasis> partition. The size required will vary
181+ according to needs, here a 8GiB one is created.
182+<screen language="commands"># parted /dev/sda -- mkpart primary linux-swap 1M 8GiB</screen>
183+ <note>
184+ <para>
185+ The swap partition size rules are no different than for other Linux
186+ distributions.
187+ </para>
188+ </note>
189+ </para>
190+ </listitem>
191+ <listitem>
192+ <para>
193+ Finally, add the <emphasis>root</emphasis> partition. This will fill the
194+ remainder of the disk.
195+<screen language="commands"># parted /dev/sda -- mkpart primary 8GiB -1s</screen>
196+ </para>
197+ </listitem>
198+ </orderedlist>
199+ </para>
200+
201+ <para>
202+ Once complete, you can follow with
203+ <xref linkend="sec-installation-partitioning-formatting"/>.
204+ </para>
205+ </section>
206+
207+ <section xml:id="sec-installation-partitioning-formatting">
208+ <title>Formatting</title>
209+
210+ <para>
211+ Use the following commands:
212+ <itemizedlist>
120213 <listitem>
121214 <para>
122215 For initialising Ext4 partitions: <command>mkfs.ext4</command>. It is
@@ -169,242 +262,249 @@
169262 </listitem>
170263 </itemizedlist>
171264 </para>
172− </listitem>
173− <listitem>
174− <para>
175− Mount the target file system on which NixOS should be installed on
176− <filename>/mnt</filename>, e.g.
265+ </section>
266+ </section>
267+ <section xml:id="sec-installation-installing">
268+ <title>Installing</title>
269+
270+ <orderedlist>
271+ <listitem>
272+ <para>
273+ Mount the target file system on which NixOS should be installed on
274+ <filename>/mnt</filename>, e.g.
177275<screen>
178276# mount /dev/disk/by-label/nixos /mnt
179277</screen>
180− </para>
181− </listitem>
182− <listitem>
183− <variablelist>
184− <varlistentry>
185− <term>
186− UEFI systems
187− </term>
188− <listitem>
189− <para>
190− Mount the boot file system on <filename>/mnt/boot</filename>, e.g.
278+ </para>
279+ </listitem>
280+ <listitem>
281+ <variablelist>
282+ <varlistentry>
283+ <term>
284+ UEFI systems
285+ </term>
286+ <listitem>
287+ <para>
288+ Mount the boot file system on <filename>/mnt/boot</filename>, e.g.
191289<screen>
192290# mkdir -p /mnt/boot
193291# mount /dev/disk/by-label/boot /mnt/boot
194292</screen>
195− </para>
196− </listitem>
197− </varlistentry>
198− </variablelist>
199− </listitem>
200− <listitem>
201− <para>
202− If your machine has a limited amount of memory, you may want to activate
203− swap devices now (<command>swapon
204− <replaceable>device</replaceable></command>). The installer (or rather, the
205− build actions that it may spawn) may need quite a bit of RAM, depending on
206− your configuration.
293+ </para>
294+ </listitem>
295+ </varlistentry>
296+ </variablelist>
297+ </listitem>
298+ <listitem>
299+ <para>
300+ If your machine has a limited amount of memory, you may want to activate
301+ swap devices now (<command>swapon
302+ <replaceable>device</replaceable></command>). The installer (or rather,
303+ the build actions that it may spawn) may need quite a bit of RAM,
304+ depending on your configuration.
207305<screen>
208306# swapon /dev/sda2</screen>
209− </para>
210− </listitem>
211− <listitem>
212− <para>
213− You now need to create a file
214− <filename>/mnt/etc/nixos/configuration.nix</filename> that specifies the
215− intended configuration of the system. This is because NixOS has a
216− <emphasis>declarative</emphasis> configuration model: you create or edit a
217− description of the desired configuration of your system, and then NixOS
218− takes care of making it happen. The syntax of the NixOS configuration file
219− is described in <xref linkend="sec-configuration-syntax"/>, while a list of
220− available configuration options appears in
221− <xref
307+ </para>
308+ </listitem>
309+ <listitem>
310+ <para>
311+ You now need to create a file
312+ <filename>/mnt/etc/nixos/configuration.nix</filename> that specifies the
313+ intended configuration of the system. This is because NixOS has a
314+ <emphasis>declarative</emphasis> configuration model: you create or edit a
315+ description of the desired configuration of your system, and then NixOS
316+ takes care of making it happen. The syntax of the NixOS configuration file
317+ is described in <xref linkend="sec-configuration-syntax"/>, while a list
318+ of available configuration options appears in
319+ <xref
222320 linkend="ch-options"/>. A minimal example is shown in
223− <xref
321+ <xref
224322 linkend="ex-config"/>.
225− </para>
226− <para>
227− The command <command>nixos-generate-config</command> can generate an
228− initial configuration file for you:
323+ </para>
324+ <para>
325+ The command <command>nixos-generate-config</command> can generate an
326+ initial configuration file for you:
229327<screen>
230328# nixos-generate-config --root /mnt</screen>
231− You should then edit <filename>/mnt/etc/nixos/configuration.nix</filename>
232− to suit your needs:
329+ You should then edit <filename>/mnt/etc/nixos/configuration.nix</filename>
330+ to suit your needs:
233331<screen>
234332# nano /mnt/etc/nixos/configuration.nix
235333</screen>
236− If you’re using the graphical ISO image, other editors may be available
237− (such as <command>vim</command>). If you have network access, you can also
238− install other editors — for instance, you can install Emacs by running
239− <literal>nix-env -i emacs</literal>.
240− </para>
241− <variablelist>
242− <varlistentry>
243− <term>
244− BIOS systems
245− </term>
246− <listitem>
247− <para>
248− You <emphasis>must</emphasis> set the option
249− <xref linkend="opt-boot.loader.grub.device"/> to specify on which disk
250− the GRUB boot loader is to be installed. Without it, NixOS cannot boot.
251− </para>
252− </listitem>
253− </varlistentry>
254− <varlistentry>
255− <term>
256− UEFI systems
257− </term>
258− <listitem>
259− <para>
260− You <emphasis>must</emphasis> set the option
261− <xref linkend="opt-boot.loader.systemd-boot.enable"/> to
262− <literal>true</literal>. <command>nixos-generate-config</command> should
263− do this automatically for new configurations when booted in UEFI mode.
264− </para>
265− <para>
266− You may want to look at the options starting with
267− <option><link linkend="opt-boot.loader.efi.canTouchEfiVariables">boot.loader.efi</link></option>
268− and
269− <option><link linkend="opt-boot.loader.systemd-boot.enable">boot.loader.systemd</link></option>
270− as well.
271− </para>
272− </listitem>
273− </varlistentry>
274− </variablelist>
275− <para>
276− If there are other operating systems running on the machine before
277− installing NixOS, the <xref linkend="opt-boot.loader.grub.useOSProber"/>
278− option can be set to <literal>true</literal> to automatically add them to
279− the grub menu.
280− </para>
281− <para>
282− Another critical option is <option>fileSystems</option>, specifying the
283− file systems that need to be mounted by NixOS. However, you typically
284− don’t need to set it yourself, because
285− <command>nixos-generate-config</command> sets it automatically in
286− <filename>/mnt/etc/nixos/hardware-configuration.nix</filename> from your
287− currently mounted file systems. (The configuration file
288− <filename>hardware-configuration.nix</filename> is included from
289− <filename>configuration.nix</filename> and will be overwritten by future
290− invocations of <command>nixos-generate-config</command>; thus, you
291− generally should not modify it.)
292− </para>
293− <note>
334+ If you’re using the graphical ISO image, other editors may be available
335+ (such as <command>vim</command>). If you have network access, you can also
336+ install other editors — for instance, you can install Emacs by running
337+ <literal>nix-env -i emacs</literal>.
338+ </para>
339+ <variablelist>
340+ <varlistentry>
341+ <term>
342+ BIOS systems
343+ </term>
344+ <listitem>
345+ <para>
346+ You <emphasis>must</emphasis> set the option
347+ <xref linkend="opt-boot.loader.grub.device"/> to specify on which disk
348+ the GRUB boot loader is to be installed. Without it, NixOS cannot boot.
349+ </para>
350+ </listitem>
351+ </varlistentry>
352+ <varlistentry>
353+ <term>
354+ UEFI systems
355+ </term>
356+ <listitem>
357+ <para>
358+ You <emphasis>must</emphasis> set the option
359+ <xref linkend="opt-boot.loader.systemd-boot.enable"/> to
360+ <literal>true</literal>. <command>nixos-generate-config</command>
361+ should do this automatically for new configurations when booted in UEFI
362+ mode.
363+ </para>
364+ <para>
365+ You may want to look at the options starting with
366+ <option><link linkend="opt-boot.loader.efi.canTouchEfiVariables">boot.loader.efi</link></option>
367+ and
368+ <option><link linkend="opt-boot.loader.systemd-boot.enable">boot.loader.systemd</link></option>
369+ as well.
370+ </para>
371+ </listitem>
372+ </varlistentry>
373+ </variablelist>
294374 <para>
295− Depending on your hardware configuration or type of file system, you may
296− need to set the option <option>boot.initrd.kernelModules</option> to
297− include the kernel modules that are necessary for mounting the root file
298− system, otherwise the installed system will not be able to boot. (If this
299− happens, boot from the CD again, mount the target file system on
300− <filename>/mnt</filename>, fix
301− <filename>/mnt/etc/nixos/configuration.nix</filename> and rerun
302− <filename>nixos-install</filename>.) In most cases,
303− <command>nixos-generate-config</command> will figure out the required
304− modules.
375+ If there are other operating systems running on the machine before
376+ installing NixOS, the <xref linkend="opt-boot.loader.grub.useOSProber"/>
377+ option can be set to <literal>true</literal> to automatically add them to
378+ the grub menu.
305379 </para>
306− </note>
307− </listitem>
308− <listitem>
309− <para>
310− Do the installation:
380+ <para>
381+ Another critical option is <option>fileSystems</option>, specifying the
382+ file systems that need to be mounted by NixOS. However, you typically
383+ don’t need to set it yourself, because
384+ <command>nixos-generate-config</command> sets it automatically in
385+ <filename>/mnt/etc/nixos/hardware-configuration.nix</filename> from your
386+ currently mounted file systems. (The configuration file
387+ <filename>hardware-configuration.nix</filename> is included from
388+ <filename>configuration.nix</filename> and will be overwritten by future
389+ invocations of <command>nixos-generate-config</command>; thus, you
390+ generally should not modify it.)
391+ </para>
392+ <note>
393+ <para>
394+ Depending on your hardware configuration or type of file system, you may
395+ need to set the option <option>boot.initrd.kernelModules</option> to
396+ include the kernel modules that are necessary for mounting the root file
397+ system, otherwise the installed system will not be able to boot. (If this
398+ happens, boot from the installation media again, mount the target file
399+ system on <filename>/mnt</filename>, fix
400+ <filename>/mnt/etc/nixos/configuration.nix</filename> and rerun
401+ <filename>nixos-install</filename>.) In most cases,
402+ <command>nixos-generate-config</command> will figure out the required
403+ modules.
404+ </para>
405+ </note>
406+ </listitem>
407+ <listitem>
408+ <para>
409+ Do the installation:
311410<screen>
312411# nixos-install</screen>
313− Cross fingers. If this fails due to a temporary problem (such as a network
314− issue while downloading binaries from the NixOS binary cache), you can just
315− re-run <command>nixos-install</command>. Otherwise, fix your
316− <filename>configuration.nix</filename> and then re-run
317− <command>nixos-install</command>.
318− </para>
319− <para>
320− As the last step, <command>nixos-install</command> will ask you to set the
321− password for the <literal>root</literal> user, e.g.
412+ Cross fingers. If this fails due to a temporary problem (such as a network
413+ issue while downloading binaries from the NixOS binary cache), you can
414+ just re-run <command>nixos-install</command>. Otherwise, fix your
415+ <filename>configuration.nix</filename> and then re-run
416+ <command>nixos-install</command>.
417+ </para>
418+ <para>
419+ As the last step, <command>nixos-install</command> will ask you to set the
420+ password for the <literal>root</literal> user, e.g.
322421<screen>
323422setting root password...
324423Enter new UNIX password: ***
325−Retype new UNIX password: ***
326− </screen>
327− <note>
328− <para>
329− For unattended installations, it is possible to use
330− <command>nixos-install --no-root-passwd</command> in order to disable the
331− password prompt entirely.
332− </para>
333− </note>
334− </para>
335− </listitem>
336− <listitem>
337− <para>
338− If everything went well:
424+Retype new UNIX password: ***</screen>
425+ <note>
426+ <para>
427+ For unattended installations, it is possible to use
428+ <command>nixos-install --no-root-passwd</command> in order to disable
429+ the password prompt entirely.
430+ </para>
431+ </note>
432+ </para>
433+ </listitem>
434+ <listitem>
435+ <para>
436+ If everything went well:
339437<screen>
340− # reboot</screen>
341− </para>
342− </listitem>
343− <listitem>
344− <para>
345− You should now be able to boot into the installed NixOS. The GRUB boot menu
346− shows a list of <emphasis>available configurations</emphasis> (initially
347− just one). Every time you change the NixOS configuration (see
348− <link
438+# reboot</screen>
439+ </para>
440+ </listitem>
441+ <listitem>
442+ <para>
443+ You should now be able to boot into the installed NixOS. The GRUB boot
444+ menu shows a list of <emphasis>available configurations</emphasis>
445+ (initially just one). Every time you change the NixOS configuration (see
446+ <link
349447 linkend="sec-changing-config">Changing Configuration</link>
350− ), a new item is added to the menu. This allows you to easily roll back to
351− a previous configuration if something goes wrong.
352− </para>
353− <para>
354− You should log in and change the <literal>root</literal> password with
355− <command>passwd</command>.
356− </para>
357− <para>
358− You’ll probably want to create some user accounts as well, which can be
359− done with <command>useradd</command>:
448+ ), a new item is added to the menu. This allows you to easily roll back to
449+ a previous configuration if something goes wrong.
450+ </para>
451+ <para>
452+ You should log in and change the <literal>root</literal> password with
453+ <command>passwd</command>.
454+ </para>
455+ <para>
456+ You’ll probably want to create some user accounts as well, which can be
457+ done with <command>useradd</command>:
360458<screen>
361459$ useradd -c 'Eelco Dolstra' -m eelco
362460$ passwd eelco</screen>
363− </para>
364− <para>
365− You may also want to install some software. For instance,
461+ </para>
462+ <para>
463+ You may also want to install some software. For instance,
366464<screen>
367465$ nix-env -qa \*</screen>
368− shows what packages are available, and
466+ shows what packages are available, and
369467<screen>
370468$ nix-env -i w3m</screen>
371− install the <literal>w3m</literal> browser.
372− </para>
373− </listitem>
374− </orderedlist>
375− <para>
376− To summarise, <xref linkend="ex-install-sequence" /> shows a typical sequence
377− of commands for installing NixOS on an empty hard drive (here
378− <filename>/dev/sda</filename>). <xref linkend="ex-config"
469+ install the <literal>w3m</literal> browser.
470+ </para>
471+ </listitem>
472+ </orderedlist>
473+ </section>
474+ <section xml:id="sec-installation-summary">
475+ <title>Installation summary</title>
476+
477+ <para>
478+ To summarise, <xref linkend="ex-install-sequence" /> shows a typical
479+ sequence of commands for installing NixOS on an empty hard drive (here
480+ <filename>/dev/sda</filename>). <xref linkend="ex-config"
379481/> shows a
380− corresponding configuration Nix expression.
381− </para>
382− <example xml:id='ex-install-sequence'>
383− <title>Commands for Installing NixOS on <filename>/dev/sda</filename></title>
384−<screen>
385−# fdisk /dev/sda # <lineannotation>(or whatever device you want to install on)</lineannotation>
386−-- for UEFI systems only
387−> n # <lineannotation>(create a new partition for /boot)</lineannotation>
388−> 3 # <lineannotation>(make it a partition number 3)</lineannotation>
389−> # <lineannotation>(press enter to accept the default)</lineannotation>
390−> +512M # <lineannotation>(the size of the UEFI boot partition)</lineannotation>
391−> t # <lineannotation>(change the partition type ...)</lineannotation>
392−> 3 # <lineannotation>(... of the boot partition ...)</lineannotation>
393−> 1 # <lineannotation>(... to 'UEFI System')</lineannotation>
394−-- for BIOS or UEFI systems
395−> n # <lineannotation>(create a new partition for /swap)</lineannotation>
396−> 2 # <lineannotation>(make it a partition number 2)</lineannotation>
397−> # <lineannotation>(press enter to accept the default)</lineannotation>
398−> +8G # <lineannotation>(the size of the swap partition)</lineannotation>
399−> n # <lineannotation>(create a new partition for /)</lineannotation>
400−> 1 # <lineannotation>(make it a partition number 1)</lineannotation>
401−> # <lineannotation>(press enter to accept the default)</lineannotation>
402−> # <lineannotation>(press enter to accept the default and use the rest of the remaining space)</lineannotation>
403−> a # <lineannotation>(make the partition bootable)</lineannotation>
404−> x # <lineannotation>(enter expert mode)</lineannotation>
405−> f # <lineannotation>(fix up the partition ordering)</lineannotation>
406−> r # <lineannotation>(exit expert mode)</lineannotation>
407−> w # <lineannotation>(write the partition table to disk and exit)</lineannotation>
482+ corresponding configuration Nix expression.
483+ </para>
484+
485+ <example xml:id="ex-partition-scheme-MBR">
486+ <title>Example partition schemes for NixOS on <filename>/dev/sda</filename> (MBR)</title>
487+<screen language="commands">
488+# parted /dev/sda -- mklabel msdos
489+# parted /dev/sda -- mkpart primary linux-swap 1M 8GiB
490+# parted /dev/sda -- mkpart primary 8GiB -1s</screen>
491+ </example>
492+
493+ <example xml:id="ex-partition-scheme-UEFI">
494+ <title>Example partition schemes for NixOS on <filename>/dev/sda</filename> (UEFI)</title>
495+<screen language="commands">
496+# parted /dev/sda -- mklabel gpt
497+# parted /dev/sda -- mkpart primary linux-swap 512MiB 8.5GiB
498+# parted /dev/sda -- mkpart primary 8.5GiB -1MiB
499+# parted /dev/sda -- mkpart ESP fat32 1M 512MiB
500+# parted /dev/sda -- set 3 boot on</screen>
501+ </example>
502+
503+ <example xml:id="ex-install-sequence">
504+ <title>Commands for Installing NixOS on <filename>/dev/sda</filename></title>
505+ <para>
506+ With a partitioned disk.
507+<screen language="commands">
408508# mkfs.ext4 -L nixos /dev/sda1
409509# mkswap -L swap /dev/sda2
410510# swapon /dev/sda2
@@ -416,9 +516,11 @@ $ nix-env -i w3m</screen>
416516# nano /mnt/etc/nixos/configuration.nix
417517# nixos-install
418518# reboot</screen>
419− </example>
420− <example xml:id='ex-config'>
421− <title>NixOS Configuration</title>
519+ </para>
520+ </example>
521+
522+ <example xml:id='ex-config'>
523+ <title>NixOS Configuration</title>
422524<screen>
423525{ config, pkgs, ... }: {
424526 imports = [
@@ -438,10 +540,19 @@ $ nix-env -i w3m</screen>
438540 services.sshd.enable = true;
439541}
440542 </screen>
441− </example>
442− <xi:include href="installing-usb.xml" />
443− <xi:include href="installing-pxe.xml" />
444− <xi:include href="installing-virtualbox-guest.xml" />
445− <xi:include href="installing-from-other-distro.xml" />
446− <xi:include href="installing-behind-a-proxy.xml" />
543+ </example>
544+ </section>
545+ <section xml:id="sec-installation-additional-notes">
546+ <title>Additional installation notes</title>
547+
548+ <xi:include href="installing-usb.xml" />
549+
550+ <xi:include href="installing-pxe.xml" />
551+
552+ <xi:include href="installing-virtualbox-guest.xml" />
553+
554+ <xi:include href="installing-from-other-distro.xml" />
555+
556+ <xi:include href="installing-behind-a-proxy.xml" />
557+ </section>
447558</chapter>