1<section xmlns="http://docbook.org/ns/docbook"
2 xmlns:xlink="http://www.w3.org/1999/xlink"
3 xmlns:xi="http://www.w3.org/2001/XInclude"
4 version="5.0"
5 xml:id="sec-booting-from-usb">
6 <title>Booting from a USB Drive</title>
7
8 <para>
9 For systems without CD drive, the NixOS live CD can be booted from a USB
10 stick. You can use the <command>dd</command> utility to write the image:
11 <command>dd if=<replaceable>path-to-image</replaceable>
12 of=<replaceable>/dev/sdb</replaceable></command>. Be careful about specifying
13 the correct drive; you can use the <command>lsblk</command> command to get a
14 list of block devices.
15 </para>
16
17 <para>
18 On macOS:
19<programlisting>
20$ diskutil list
21[..]
22/dev/diskN (external, physical):
23 #: TYPE NAME SIZE IDENTIFIER
24[..]
25$ diskutil unmountDisk diskN
26Unmount of all volumes on diskN was successful
27$ sudo dd bs=1m if=nix.iso of=/dev/rdiskN
28</programlisting>
29 Using the 'raw' <command>rdiskN</command> device instead of
30 <command>diskN</command> completes in minutes instead of hours. After
31 <command>dd</command> completes, a GUI dialog "The disk you inserted was not
32 readable by this computer" will pop up, which can be ignored.
33 </para>
34
35 <para>
36 The <command>dd</command> utility will write the image verbatim to the drive,
37 making it the recommended option for both UEFI and non-UEFI installations.
38 For non-UEFI installations, you can alternatively use
39 <link xlink:href="http://unetbootin.sourceforge.net/">unetbootin</link>. If
40 you cannot use <command>dd</command> for a UEFI installation, you can also
41 mount the ISO, copy its contents verbatim to your drive, then either:
42 <itemizedlist>
43 <listitem>
44 <para>
45 Change the label of the disk partition to the label of the ISO (visible
46 with the blkid command), or
47 </para>
48 </listitem>
49 <listitem>
50 <para>
51 Edit <filename>loader/entries/nixos-livecd.conf</filename> on the drive
52 and change the <literal>root=</literal> field in the
53 <literal>options</literal> line to point to your drive (see the
54 documentation on <literal>root=</literal> in
55 <link xlink:href="https://www.kernel.org/doc/Documentation/admin-guide/kernel-parameters.txt">
56 the kernel documentation</link> for more details).
57 </para>
58 </listitem>
59 <listitem>
60 <para>
61 If you want to load the contents of the ISO to ram after bootin (So you
62 can remove the stick after bootup) you can append the parameter
63 <literal>copytoram</literal> to the <literal>options</literal> field.
64 </para>
65 </listitem>
66 </itemizedlist>
67 </para>
68</section>