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
7<title>Booting from a USB Drive</title>
8
9<para>For systems without CD drive, the NixOS live CD can be booted from
10a USB stick. You can use the <command>dd</command> utility to write the image:
11<command>dd if=<replaceable>path-to-image</replaceable>
12of=<replaceable>/dev/sdb</replaceable></command>. Be careful about specifying the
13correct drive; you can use the <command>lsblk</command> command to get a list of
14block devices. If you're on macOS you can run <command>diskutil list</command>
15to see the list of devices; the device you'll use for the USB must be ejected
16before writing the image.</para>
17
18<para>The <command>dd</command> utility will write the image verbatim to the drive,
19making it the recommended option for both UEFI and non-UEFI installations. For
20non-UEFI installations, you can alternatively use
21<link xlink:href="http://unetbootin.sourceforge.net/">unetbootin</link>. If you
22cannot use <command>dd</command> for a UEFI installation, you can also mount the
23ISO, copy its contents verbatim to your drive, then either:
24
25<itemizedlist>
26 <listitem>
27 <para>Change the label of the disk partition to the label of the ISO
28 (visible with the blkid command), or</para>
29 </listitem>
30 <listitem>
31 <para>Edit <filename>loader/entries/nixos-livecd.conf</filename> on the drive
32 and change the <literal>root=</literal> field in the <literal>options</literal>
33 line to point to your drive (see the documentation on <literal>root=</literal>
34 in <link xlink:href="https://www.kernel.org/doc/Documentation/kernel-parameters.txt">
35 the kernel documentation</link> for more details).</para>
36 </listitem>
37 <listitem>
38 <para>If you want to load the contents of the ISO to ram after bootin
39 (So you can remove the stick after bootup) you can append the parameter
40 <literal>copytoram</literal>to the <literal>options</literal> field.</para>
41 </listitem>
42</itemizedlist>
43</para>
44
45</section>