| 1 |
rane |
1.1 |
<?xml version='1.0' encoding="UTF-8"?> |
| 2 |
|
|
<!DOCTYPE guide SYSTEM "/dtd/guide.dtd"> |
| 3 |
nightmorph |
1.19 |
<!-- $Header: /var/cvsroot/gentoo/xml/htdocs/doc/en/liveusb.xml,v 1.18 2009/01/26 20:19:31 nightmorph Exp $ --> |
| 4 |
rane |
1.1 |
|
| 5 |
neysx |
1.17 |
<guide> |
| 6 |
rane |
1.1 |
<title>Gentoo Linux LiveUSB HOWTO</title> |
| 7 |
|
|
|
| 8 |
|
|
<author title="Author"> |
| 9 |
neysx |
1.17 |
<mail link="brix"/> |
| 10 |
rane |
1.1 |
</author> |
| 11 |
neysx |
1.13 |
<author title="Editor"> |
| 12 |
nightmorph |
1.18 |
<mail link="neysx"/> |
| 13 |
neysx |
1.13 |
</author> |
| 14 |
rane |
1.1 |
|
| 15 |
|
|
<abstract> |
| 16 |
|
|
This HOWTO explains how to create a Gentoo Linux LiveUSB or, in other words, |
| 17 |
neysx |
1.13 |
how to emulate an x86 or AMD64 Gentoo Linux LiveCD using a USB flash drive. |
| 18 |
rane |
1.1 |
</abstract> |
| 19 |
|
|
|
| 20 |
|
|
<!-- The content of this document is licensed under the CC-BY-SA license --> |
| 21 |
|
|
<!-- See http://creativecommons.org/licenses/by-sa/2.5 --> |
| 22 |
|
|
<license/> |
| 23 |
|
|
|
| 24 |
nightmorph |
1.19 |
<version>7</version> |
| 25 |
|
|
<date>2009-11-20</date> |
| 26 |
rane |
1.1 |
|
| 27 |
|
|
<chapter> |
| 28 |
|
|
<title>Introduction</title> |
| 29 |
|
|
<section> |
| 30 |
|
|
<title>The LiveUSB</title> |
| 31 |
|
|
<body> |
| 32 |
|
|
|
| 33 |
|
|
<p> |
| 34 |
|
|
This HOWTO explains how to create a <e>Gentoo Linux LiveUSB</e> or, in other |
| 35 |
neysx |
1.13 |
words, how to emulate an x86 or AMD64 Gentoo Linux LiveCD using a USB flash |
| 36 |
|
|
drive. This is particularly useful for installing Gentoo Linux on a modern |
| 37 |
|
|
laptop with no CD-ROM drive. |
| 38 |
rane |
1.1 |
</p> |
| 39 |
|
|
|
| 40 |
neysx |
1.17 |
<note> |
| 41 |
|
|
The <c>sys-boot/unetbootin</c> package provides a much easier alternative to |
| 42 |
|
|
create a bootable USB stick from any bootable CD image. |
| 43 |
|
|
</note> |
| 44 |
|
|
|
| 45 |
rane |
1.1 |
<p> |
| 46 |
vanquirius |
1.4 |
Although the instructions found in this document aim at emulating a Gentoo |
| 47 |
neysx |
1.13 |
Linux LiveCD using a USB flash drive, they should work for any arbitrary block |
| 48 |
|
|
device as long as you adjust the device names accordingly. |
| 49 |
rane |
1.1 |
</p> |
| 50 |
|
|
|
| 51 |
|
|
</body> |
| 52 |
|
|
</section> |
| 53 |
|
|
<section> |
| 54 |
|
|
<title>Prerequisites</title> |
| 55 |
|
|
<body> |
| 56 |
|
|
|
| 57 |
|
|
<p> |
| 58 |
|
|
In order to use a Gentoo Linux LiveUSB you need the following: |
| 59 |
|
|
</p> |
| 60 |
|
|
|
| 61 |
|
|
<ul> |
| 62 |
neysx |
1.13 |
<li>Bootable USB flash drive with at least 1GB</li> |
| 63 |
|
|
<li>i686 or x86_64 computer with support for booting from USB</li> |
| 64 |
rane |
1.1 |
</ul> |
| 65 |
|
|
|
| 66 |
|
|
<p> |
| 67 |
|
|
You will also need access to the following for creating the LiveUSB: |
| 68 |
|
|
</p> |
| 69 |
|
|
|
| 70 |
|
|
<ul> |
| 71 |
|
|
<li> |
| 72 |
|
|
A computer running Gentoo Linux (or alternatively another Linux |
| 73 |
|
|
distribution) |
| 74 |
|
|
</li> |
| 75 |
|
|
</ul> |
| 76 |
|
|
|
| 77 |
|
|
</body> |
| 78 |
|
|
</section> |
| 79 |
|
|
</chapter> |
| 80 |
|
|
<chapter> |
| 81 |
|
|
<title>Preparing the USB flash drive</title> |
| 82 |
|
|
<section> |
| 83 |
|
|
<title>Partitioning the drive</title> |
| 84 |
|
|
<body> |
| 85 |
|
|
|
| 86 |
|
|
<warn> |
| 87 |
|
|
These instructions will erase all data from the USB flash drive. Make sure to |
| 88 |
|
|
backup your data first. |
| 89 |
|
|
</warn> |
| 90 |
|
|
|
| 91 |
|
|
<impo> |
| 92 |
neysx |
1.13 |
This HOWTO assumes that the <path>/dev/sdc</path> device node corresponds to |
| 93 |
rane |
1.1 |
your USB flash drive. If you have other SCSI-like devices make sure to use the |
| 94 |
|
|
correct device node. |
| 95 |
|
|
</impo> |
| 96 |
|
|
|
| 97 |
|
|
<p> |
| 98 |
neysx |
1.13 |
Create a FAT16 partition on your USB flash drive and mark it bootable using |
| 99 |
rane |
1.1 |
<c>fdisk</c>. An example partitioning scheme can be seen below: |
| 100 |
|
|
</p> |
| 101 |
|
|
|
| 102 |
neysx |
1.13 |
<note> |
| 103 |
|
|
If your key is 4GB or larger, use partition type <c>b</c> (W95 FAT32). |
| 104 |
|
|
</note> |
| 105 |
|
|
|
| 106 |
rane |
1.1 |
<pre caption="Example partitioning scheme"> |
| 107 |
neysx |
1.13 |
# <i>fdisk -l /dev/sdc</i> |
| 108 |
rane |
1.1 |
|
| 109 |
neysx |
1.13 |
Disk /dev/sdc: 2063 MB, 2063597056 bytes |
| 110 |
|
|
255 heads, 63 sectors/track, 250 cylinders |
| 111 |
|
|
Units = cylinders of 16065 * 512 = 8225280 bytes |
| 112 |
rane |
1.1 |
|
| 113 |
|
|
Device Boot Start End Blocks Id System |
| 114 |
neysx |
1.13 |
/dev/sdc1 * 1 250 2008124+ 6 FAT16 |
| 115 |
rane |
1.1 |
</pre> |
| 116 |
|
|
|
| 117 |
|
|
</body> |
| 118 |
|
|
</section> |
| 119 |
|
|
<section> |
| 120 |
|
|
<title>Creating the filesystem</title> |
| 121 |
|
|
<body> |
| 122 |
|
|
|
| 123 |
|
|
<p> |
| 124 |
neysx |
1.13 |
Create a FAT16 filesystem on the USB flash drive using <c>mkdosfs</c>: |
| 125 |
rane |
1.1 |
</p> |
| 126 |
|
|
|
| 127 |
neysx |
1.13 |
<note> |
| 128 |
|
|
If your key is 4GB or larger, use <c>-F 32</c> to create a FAT32 filesystem. |
| 129 |
|
|
</note> |
| 130 |
|
|
|
| 131 |
rane |
1.1 |
<pre caption="Running mkdosfs"> |
| 132 |
|
|
<comment>(Make sure you have sys-fs/dosfstools installed)</comment> |
| 133 |
|
|
# <i>emerge -av sys-fs/dosfstools</i> |
| 134 |
neysx |
1.13 |
# <i>mkdosfs -F 16 /dev/sdc1</i> |
| 135 |
rane |
1.1 |
mkdosfs 2.11 (12 Mar 2005) |
| 136 |
|
|
</pre> |
| 137 |
|
|
|
| 138 |
|
|
</body> |
| 139 |
|
|
</section> |
| 140 |
|
|
<section> |
| 141 |
|
|
<title>Installing a Master Boot Record</title> |
| 142 |
|
|
<body> |
| 143 |
|
|
|
| 144 |
|
|
<p> |
| 145 |
|
|
Install the precompiled Master Boot Record (MBR) from <c>syslinux</c> on the |
| 146 |
|
|
USB flash drive: |
| 147 |
|
|
</p> |
| 148 |
|
|
|
| 149 |
|
|
<pre caption="Installing a master boot record"> |
| 150 |
|
|
<comment>(Make sure you have sys-boot/syslinux-3.00 or later installed)</comment> |
| 151 |
nightmorph |
1.12 |
# <i>emerge -av '>sys-boot/syslinux-3'</i> |
| 152 |
nightmorph |
1.16 |
# <i>dd if=/usr/share/syslinux/mbr.bin of=/dev/sdc</i> |
| 153 |
rane |
1.1 |
0+1 records in |
| 154 |
|
|
0+1 records out |
| 155 |
neysx |
1.13 |
304 bytes (304 B) copied, 0.0162317 s, 18.7 kB/s |
| 156 |
rane |
1.1 |
</pre> |
| 157 |
|
|
|
| 158 |
|
|
</body> |
| 159 |
|
|
</section> |
| 160 |
|
|
</chapter> |
| 161 |
neysx |
1.13 |
|
| 162 |
rane |
1.1 |
<chapter> |
| 163 |
neysx |
1.13 |
<title>Copying the files to your key</title> |
| 164 |
rane |
1.1 |
<section> |
| 165 |
|
|
<title>Mounting the Gentoo Linux Installation CD</title> |
| 166 |
|
|
<body> |
| 167 |
|
|
|
| 168 |
|
|
<p> |
| 169 |
nightmorph |
1.19 |
Download the Gentoo Weekly Minimal Install CD for your architecture from your |
| 170 |
|
|
local Gentoo Linux <uri link="/main/en/where.xml">mirror</uri> site and mount |
| 171 |
|
|
the ISO image on <path>/mnt/cdrom</path> as shown below: |
| 172 |
rane |
1.1 |
</p> |
| 173 |
|
|
|
| 174 |
|
|
<pre caption="Mounting the Gentoo Linux Installation CD ISO image"> |
| 175 |
neysx |
1.13 |
<comment>(Create the /mnt/cdrom mount point if needed)</comment> |
| 176 |
rane |
1.1 |
# <i>mkdir -p /mnt/cdrom</i> |
| 177 |
nightmorph |
1.19 |
# <i>mount -o loop,ro -t iso9660 /path/to/iso.iso /mnt/cdrom</i> |
| 178 |
rane |
1.1 |
</pre> |
| 179 |
|
|
|
| 180 |
neysx |
1.7 |
<note> |
| 181 |
|
|
If you receive a <e>Could not find any loop device</e> error message when |
| 182 |
|
|
mounting the iso, you need to enable the <c>Loopback device support</c> option |
| 183 |
|
|
in your kernel configuration. |
| 184 |
|
|
</note> |
| 185 |
|
|
|
| 186 |
rane |
1.1 |
</body> |
| 187 |
|
|
</section> |
| 188 |
|
|
<section> |
| 189 |
|
|
<title>Mounting the LiveUSB</title> |
| 190 |
|
|
<body> |
| 191 |
|
|
|
| 192 |
|
|
<p> |
| 193 |
neysx |
1.13 |
Mount the newly formatted USB flash drive on <path>/mnt/usb</path> as shown |
| 194 |
rane |
1.1 |
below: |
| 195 |
|
|
</p> |
| 196 |
|
|
|
| 197 |
|
|
<pre caption="Mounting the USB flash drive"> |
| 198 |
neysx |
1.13 |
<comment>(Create the /mnt/usb mount point if needed)</comment> |
| 199 |
rane |
1.1 |
# <i>mkdir -p /mnt/usb</i> |
| 200 |
neysx |
1.13 |
# <i>mount -t vfat /dev/sdc1 /mnt/usb</i> |
| 201 |
rane |
1.1 |
</pre> |
| 202 |
|
|
|
| 203 |
|
|
</body> |
| 204 |
|
|
</section> |
| 205 |
|
|
<section> |
| 206 |
|
|
<title>Copying the files</title> |
| 207 |
|
|
<body> |
| 208 |
|
|
|
| 209 |
|
|
<p> |
| 210 |
|
|
Copy the files from the Gentoo Linux Installation CD to the LiveUSB. The files |
| 211 |
rane |
1.3 |
need to be reordered a bit as we will be using the <c>syslinux</c> bootloader |
| 212 |
rane |
1.1 |
instead of <c>isolinux</c>: |
| 213 |
|
|
</p> |
| 214 |
|
|
|
| 215 |
|
|
<pre caption="Copying the files"> |
| 216 |
neysx |
1.13 |
# <i>cp -r /mnt/cdrom/* /mnt/usb</i> |
| 217 |
|
|
# <i>mv /mnt/usb/isolinux/* /mnt/usb</i> |
| 218 |
rane |
1.1 |
# <i>mv /mnt/usb/isolinux.cfg /mnt/usb/syslinux.cfg</i> |
| 219 |
|
|
# <i>rm -rf /mnt/usb/isolinux*</i> |
| 220 |
|
|
|
| 221 |
|
|
<comment>(The memtest86 kernel needs to be renamed for loading it via syslinux)</comment> |
| 222 |
|
|
# <i>mv /mnt/usb/memtest86 /mnt/usb/memtest</i> |
| 223 |
|
|
</pre> |
| 224 |
|
|
|
| 225 |
|
|
<p> |
| 226 |
|
|
You can now unmount the ISO image: |
| 227 |
|
|
</p> |
| 228 |
|
|
|
| 229 |
|
|
<pre caption="Unmounting the ISO image"> |
| 230 |
neysx |
1.13 |
# <i>umount /mnt/cdrom</i> |
| 231 |
rane |
1.1 |
</pre> |
| 232 |
|
|
|
| 233 |
|
|
</body> |
| 234 |
|
|
</section> |
| 235 |
|
|
<section> |
| 236 |
|
|
<title>Adjusting the bootloader configuration</title> |
| 237 |
|
|
<body> |
| 238 |
|
|
|
| 239 |
|
|
<p> |
| 240 |
|
|
Adjust the syslinux configuration file using <c>sed</c> as shown below. The |
| 241 |
neysx |
1.13 |
<c>slowusb</c> parameter will introduce some extra delays before attempting to |
| 242 |
|
|
mount the filesystem. This is needed to allow the USB flash drive to settle |
| 243 |
|
|
upon detection. |
| 244 |
rane |
1.1 |
</p> |
| 245 |
|
|
|
| 246 |
|
|
<pre caption="Adjusting the boot parameters"> |
| 247 |
|
|
# <i>sed -i \ |
| 248 |
neysx |
1.13 |
-e "s:cdroot:cdroot slowusb:" \ |
| 249 |
rane |
1.1 |
-e "s:kernel memtest86:kernel memtest:" \ |
| 250 |
|
|
/mnt/usb/syslinux.cfg</i> |
| 251 |
|
|
</pre> |
| 252 |
|
|
|
| 253 |
|
|
</body> |
| 254 |
|
|
</section> |
| 255 |
|
|
</chapter> |
| 256 |
neysx |
1.13 |
|
| 257 |
rane |
1.1 |
<chapter> |
| 258 |
|
|
<title>Installing a bootloader</title> |
| 259 |
|
|
<section> |
| 260 |
|
|
<title>Unmounting the drive</title> |
| 261 |
|
|
<body> |
| 262 |
|
|
|
| 263 |
|
|
<p> |
| 264 |
rane |
1.2 |
Make sure you unmount the USB flash drive before installing the bootloader: |
| 265 |
rane |
1.1 |
</p> |
| 266 |
|
|
|
| 267 |
|
|
<pre caption="Unmounting the USB flash drive"> |
| 268 |
neysx |
1.13 |
# <i>umount /mnt/usb</i> |
| 269 |
rane |
1.1 |
</pre> |
| 270 |
|
|
|
| 271 |
|
|
</body> |
| 272 |
|
|
</section> |
| 273 |
|
|
<section> |
| 274 |
|
|
<title>Installing syslinux</title> |
| 275 |
|
|
<body> |
| 276 |
|
|
|
| 277 |
|
|
<p> |
| 278 |
|
|
Finally install the <c>syslinux</c> bootloader on the USB flash drive: |
| 279 |
|
|
</p> |
| 280 |
|
|
|
| 281 |
|
|
<pre caption="Running syslinux"> |
| 282 |
neysx |
1.13 |
# <i>syslinux /dev/sdc1</i> |
| 283 |
rane |
1.1 |
</pre> |
| 284 |
|
|
|
| 285 |
|
|
<impo> |
| 286 |
neysx |
1.13 |
You will need to rerun <c>syslinux /dev/sdc1</c> each time you modify the |
| 287 |
rane |
1.1 |
<path>syslinux.cfg</path> file for the configuration changes to take affect. |
| 288 |
|
|
</impo> |
| 289 |
nightmorph |
1.19 |
<note> |
| 290 |
|
|
If this is the first time you have used syslinux, you will need to edit |
| 291 |
|
|
<path>/etc/mtools/mtools.conf</path> on your host. Simply commenting out |
| 292 |
|
|
<c>SAMPLE FILE</c> will suffice for the purpose of this guide. |
| 293 |
|
|
</note> |
| 294 |
rane |
1.1 |
|
| 295 |
|
|
</body> |
| 296 |
|
|
</section> |
| 297 |
|
|
</chapter> |
| 298 |
|
|
<chapter> |
| 299 |
|
|
<title>Using the LiveUSB</title> |
| 300 |
|
|
<section> |
| 301 |
|
|
<title>Booting</title> |
| 302 |
|
|
<body> |
| 303 |
|
|
|
| 304 |
|
|
<p> |
| 305 |
|
|
Insert the USB flash drive and turn on the computer, making sure the BIOS is |
| 306 |
|
|
set to boot from USB. If all goes well you should be presented with a standard |
| 307 |
|
|
syslinux prompt. |
| 308 |
|
|
</p> |
| 309 |
|
|
|
| 310 |
|
|
<p> |
| 311 |
|
|
You should be able to follow the generic installation instructions found in the |
| 312 |
|
|
<uri link="/doc/en/handbook/">Gentoo Handbook</uri> from here on. |
| 313 |
|
|
</p> |
| 314 |
|
|
|
| 315 |
|
|
</body> |
| 316 |
|
|
</section> |
| 317 |
|
|
</chapter> |
| 318 |
|
|
</guide> |