3
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
4
<title>4.3. Preparing Files for USB Memory Stick Booting</title>
5
<link rel="stylesheet" type="text/css" href="install.css">
6
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
7
<link rel="home" href="index.html" title="Ubuntu Installation Guide">
8
<link rel="up" href="ch04.html" title="Chapter 4. Obtaining System Installation Media">
9
<link rel="prev" href="ch04s02.html" title="4.2. Downloading Files from Ubuntu Mirrors">
10
<link rel="next" href="ch04s04.html" title="4.4. Preparing Files for Hard Disk Booting">
12
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
13
<div class="navheader">
14
<table width="100%" summary="Navigation header">
15
<tr><th colspan="3" align="center">4.3. Preparing Files for USB Memory Stick Booting</th></tr>
17
<td width="20%" align="left">
18
<a accesskey="p" href="ch04s02.html"><img src="images/prev.png" alt="Prev"></a> </td>
19
<th width="60%" align="center">Chapter 4. Obtaining System Installation Media</th>
20
<td width="20%" align="right"> <a accesskey="n" href="ch04s04.html"><img src="images/next.png" alt="Next"></a>
27
<div class="titlepage"><div><div><h2 class="title">
28
<a name="boot-usb-files"></a>4.3. Preparing Files for USB Memory Stick Booting</h2></div></div></div>
31
To prepare the USB stick, you will need a system where GNU/Linux is
32
already running and where USB is supported. With current GNU/Linux systems
33
the USB stick should be automatically recognized when you insert it. If
34
it is not you should check that the usb-storage kernel module is loaded.
35
When the USB stick is inserted, it will be mapped to a device named
36
<code class="filename">/dev/sdX</code>, where the <span class="quote">“<span class="quote">X</span>”</span> is a letter
37
in the range a-z. You should be able to see to which device the USB
38
stick was mapped by running the command <span class="command"><strong>dmesg</strong></span> after
39
inserting it. To write to your stick, you may have to turn off its write
43
<div class="warning"><table border="0" summary="Warning">
45
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Warning]" src="images/warning.png"></td>
46
<th align="left">Warning</th>
48
<tr><td align="left" valign="top"><p>
50
The procedures described in this section will destroy anything already
51
on the device! Make very sure that you use the correct device name for
52
your USB stick. If you use the wrong device the result could be that all
53
information on for example a hard disk could be lost.
58
<div class="titlepage"><div><div><h3 class="title">
59
<a name="usb-copy-isohybrid"></a>4.3.1. Preparing a USB stick using a hybrid CD or DVD image</h3></div></div></div>
62
Ubuntu CD and DVD images can now be written directly to a USB stick,
63
which is a very easy way to make a bootable USB stick. Simply choose
64
a CD or DVD image that will fit
65
on your USB stick. See
66
<a class="xref" href="ch04s01.html" title="4.1. Official Ubuntu CD-ROMs">Section 4.1, “Official Ubuntu CD-ROMs”</a> to get a CD or DVD image.
72
for very small USB sticks, only a few megabytes in size, you can download
73
the <code class="filename">mini.iso</code> image from the <code class="filename">netboot</code>
74
directory (at the location mentioned in <a class="xref" href="ch04s02.html#where-files" title="4.2.1. Where to Find Installation Images">Section 4.2.1, “Where to Find Installation Images”</a>).
79
The CD or DVD image you choose should be written directly to the USB stick,
80
overwriting its current contents. For example, when using an existing
81
GNU/Linux system, the CD or DVD image file can be written to a USB stick
82
as follows, after having made sure that the stick is unmounted:
85
<div class="informalexample"><pre class="screen">
86
<code class="prompt">#</code> <strong class="userinput"><code>cp <em class="replaceable"><code>debian.iso</code></em> /dev/<em class="replaceable"><code>sdX</code></em></code></strong>
87
<code class="prompt">#</code> <strong class="userinput"><code>sync</code></strong>
92
<a class="ulink" href="http://sf.net/projects/win32diskimager/" target="_top">
94
utility can be used under other operating systems to copy the image.
97
<div class="important"><table border="0" summary="Important">
99
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Important]" src="images/important.png"></td>
100
<th align="left">Important</th>
102
<tr><td align="left" valign="top"><p>
104
The image must be written to the whole-disk device and not a
105
partition, e.g. /dev/sdb and not /dev/sdb1.
106
Do not use tools like <span class="command"><strong>unetbootin</strong></span> which alter the image.
110
<div class="important"><table border="0" summary="Important">
112
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Important]" src="images/important.png"></td>
113
<th align="left">Important</th>
115
<tr><td align="left" valign="top"><p>
117
Simply writing the CD or DVD image to USB like this should work fine
118
for most users. The other options below are more complex, mainly for
119
people with specialised needs.
125
The hybrid image on the stick does not occupy all the storage space, so
126
it may be worth considering using the free space to hold firmware files
127
or packages or any other files of your choice. This could be useful if
128
you have only one stick or just want to keep everything you need on one
134
Create a second, FAT partition on the stick, mount the partition
135
and copy or unpack the firmware onto it. For example:
138
<div class="informalexample"><pre class="screen">
139
# mount /dev/<em class="replaceable"><code>sdX2</code></em> /mnt
141
# tar zxvf <em class="replaceable"><code>/path/to/</code></em>firmware.tar.gz
150
You might have written the <code class="filename">mini.iso</code> to the USB
151
stick. In this case the second partition doesn't have to be created as,
152
very nicely, it will already be present. Unplugging and replugging the
153
USB stick should make the two partitions visible.
158
<div class="titlepage"><div><div><h3 class="title">
159
<a name="usb-copy-easy"></a>4.3.2. Manually copying files to the USB stick</h3></div></div></div>
162
An alternative way to set up your USB stick is to manually copy
163
the installer files, and also a CD image to it.
164
Note that the USB stick should be at least 1 GB in size (smaller
165
setups are possible if you follow <a class="xref" href="ch04s03.html#usb-copy-flexible" title="4.3.3. Manually copying files to the USB stick — the flexible way">Section 4.3.3, “Manually copying files to the USB stick — the flexible way”</a>).
170
There is an all-in-one file
171
<span class="phrase"><a class="ulink" href="http://archive.ubuntu.com/ubuntu/dists/focal/main/installer-i386/current//images/netboot/boot.img.gz" target="_top">netboot/boot.img.gz</a></span>
173
which contains all the installer files (including the kernel)
174
<span class="phrase">as well as <code class="classname">syslinux</code> and its
175
configuration file</span>
181
To use this image simply extract it directly to a partition on your USB
185
<div class="informalexample"><pre class="screen">
186
# zcat boot.img.gz > /dev/<em class="replaceable"><code>sdX1</code></em>
193
<div class="titlepage"><div><div><h3 class="title">
194
<a name="usb-copy-flexible"></a>4.3.3. Manually copying files to the USB stick — the flexible way</h3></div></div></div>
197
If you like more flexibility or just want to know what's going on, you
198
should use the following method to put the files on your stick. One
199
advantage of using this method is that — if the capacity of your
200
USB stick is large enough — you have the option of copying any
201
ISO image, even a DVD image, to it.
205
<div class="titlepage"><div><div><h4 class="title">
206
<a name="idm846"></a>4.3.3.1. Partitioning the USB stick</h4></div></div></div>
209
We will show how to set up the memory stick to use the first partition,
210
instead of the entire device.
213
<div class="note"><table border="0" summary="Note">
215
<td rowspan="2" align="center" valign="top" width="25"><img alt="[Note]" src="images/note.png"></td>
216
<th align="left">Note</th>
218
<tr><td align="left" valign="top">
221
Since most USB sticks come pre-configured with a single FAT16
222
partition, you probably won't have to repartition or reformat the
223
stick. If you have to do that anyway, use <span class="command"><strong>cfdisk</strong></span>
224
or any other partitioning tool to create a FAT16 partition<a href="#ftn.idm852" class="footnote" name="idm852"><sup class="footnote">[2]</sup></a>, install an MBR using:
227
<div class="informalexample"><pre class="screen">
228
# install-mbr /dev/<em class="replaceable"><code>sdX</code></em>
232
The <span class="command"><strong>install-mbr</strong></span> command is contained in the
233
<code class="classname">mbr</code> Ubuntu package. Then create the filesystem using:
236
<div class="informalexample"><pre class="screen">
237
# mkdosfs /dev/<em class="replaceable"><code>sdX1</code></em>
241
Take care that you use the correct device name for your USB stick. The
242
<span class="command"><strong>mkdosfs</strong></span> command is contained in the
243
<code class="classname">dosfstools</code> Ubuntu package.
250
In order to start the kernel after booting from the USB stick, we will
251
put a boot loader on the stick. Although any boot loader
252
(e.g. <code class="classname">lilo</code>) should work, it's convenient to use
253
<code class="classname">syslinux</code>, since it uses a FAT16 partition and can
254
be reconfigured by just editing a text file. Any operating system
255
which supports the FAT file system can be used to make changes to the
256
configuration of the boot loader.
261
To put <code class="classname">syslinux</code> on the FAT16 partition on your USB
262
stick, install the <code class="classname">syslinux</code> and
263
<code class="classname">mtools</code> packages on your system, and do:
266
<div class="informalexample"><pre class="screen">
267
# syslinux /dev/<em class="replaceable"><code>sdX1</code></em>
271
Again, take care that you use the correct device name. The partition
272
must not be mounted when starting <span class="command"><strong>syslinux</strong></span>. This
273
procedure writes a boot sector to the partition and creates the file
274
<code class="filename">ldlinux.sys</code> which contains the boot loader code.
279
<div class="titlepage"><div><div><h4 class="title">
280
<a name="idm877"></a>4.3.3.2. Adding the installer image</h4></div></div></div>
284
(<strong class="userinput"><code>mount /dev/<em class="replaceable"><code>sdX1</code></em> /mnt</code></strong>)
285
and copy the following installer image files to the stick:
288
<div class="itemizedlist"><ul class="itemizedlist" type="disc">
289
<li class="listitem"><p>
291
<code class="filename">vmlinuz</code> or <code class="filename">linux</code> (kernel binary)
294
<li class="listitem"><p>
296
<code class="filename">initrd.gz</code> (initial ramdisk image)
302
You can choose between either the text-based or the graphical version
303
of the installer. The latter can be found in the <code class="filename">gtk</code>
304
subdirectory. If you want to rename the files, please note that
305
<code class="classname">syslinux</code> can only process DOS (8.3) file names.
310
Next you should create a <code class="filename">syslinux.cfg</code> configuration
311
file, which at a bare minimum should contain the following line (change
312
the name of the kernel binary to <span class="quote">“<span class="quote"><code class="filename">linux</code></span>”</span>
313
if you used a <code class="filename">netboot</code> image):
316
<div class="informalexample"><pre class="screen">
317
default vmlinuz initrd=initrd.gz
321
For the graphical installer you should add <strong class="userinput"><code>vga=788</code></strong> to the
322
line. Other parameters can be appended as desired.
327
To enable the boot prompt to permit further parameter appending, add a
328
<strong class="userinput"><code>prompt 1</code></strong> line.
333
If you used an <code class="filename">hd-media</code> image, you should now copy the ISO file of
334
an Ubuntu ISO image<a href="#ftn.idm904" class="footnote" name="idm904"><sup class="footnote">[3]</sup></a> onto the stick. When you are done, unmount the USB memory stick
335
(<strong class="userinput"><code>umount /mnt</code></strong>).
340
<div class="footnotes">
341
<br><hr width="100" align="left">
342
<div id="ftn.idm852" class="footnote"><p><a href="#idm852" class="para"><sup class="para">[2] </sup></a>
343
Don't forget to set the <span class="quote">“<span class="quote">bootable</span>”</span> bootable flag.
345
<div id="ftn.idm904" class="footnote"><p><a href="#idm904" class="para"><sup class="para">[3] </sup></a>
346
You can use either a netinst or a full CD image (see
347
<a class="xref" href="ch04s01.html" title="4.1. Official Ubuntu CD-ROMs">Section 4.1, “Official Ubuntu CD-ROMs”</a>). Be sure to select one that fits.
348
Note that the <span class="quote">“<span class="quote">netboot <code class="filename">mini.iso</code></span>”</span> image is
349
not usable for this purpose.
353
<div class="navfooter">
355
<table width="100%" summary="Navigation footer">
357
<td width="40%" align="left">
358
<a accesskey="p" href="ch04s02.html"><img src="images/prev.png" alt="Prev"></a> </td>
359
<td width="20%" align="center"><a accesskey="u" href="ch04.html"><img src="images/up.png" alt="Up"></a></td>
360
<td width="40%" align="right"> <a accesskey="n" href="ch04s04.html"><img src="images/next.png" alt="Next"></a>
364
<td width="40%" align="left" valign="top">4.2. Downloading Files from Ubuntu Mirrors </td>
365
<td width="20%" align="center"><a accesskey="h" href="index.html"><img src="images/home.png" alt="Home"></a></td>
366
<td width="40%" align="right" valign="top"> 4.4. Preparing Files for Hard Disk Booting</td>