This is Gentoo's testing wiki. It is a non-operational environment and its textual content is outdated.

Please visit our production wiki at https://wiki.gentoo.org

LiveUSB/Guide

From Gentoo Wiki (test)
Jump to:navigation Jump to:search


This article explains how to create a Gentoo LiveUSB or, in other words, how to emulate a x86 or amd64 Gentoo LiveCD using a USB drive. This is particularly useful for installing Gentoo on a modern laptop with no CD-ROM drive.

Although the instructions found in this document aim at emulating a Gentoo LiveCD using a USB drive, they should work for any arbitrary block device as long as the device names are adjusted accordingly.

Note
In Gentoo the sys-boot/unetbootin package provides a much easier alternative to create a bootable USB stick from any bootable CD image. See the Linux section below for instructions on the manual creation of a LiveUSB in Gentoo.

Prerequisites

In order to use a Gentoo LiveUSB the following will be needed:

  • Bootable USB drive with at least 1GB (the bigger the better);
  • i686 or x86_64 computer with support for booting from USB

Access to the following is needed for creating a LiveUSB:

  • A computer running Gentoo (or alternatively another Linux distribution);
  • A computer running Microsoft Windows with the appropriate software (see the Windows section below)

dd

When using the latest install ISOs (installcds or livedvd), it is sufficient to directly copy the ISO contents on the USB device. The dd command can be used to accomplish this. For instance, assuming the USB device is at /dev/sdc:

root #dd if=/path/to/image.iso of=/dev/sdc bs=8192k

On Windows, the dd command is also available through various projects, such as GNUWin32 or Chrysocome.

The remainder of this document explains how to setup a manual vfat partition that is writable using the syslinux bootloader instead of isolinux.

Linux

Manual installation

Preparing the USB drive

Partitioning the drive
Warning
These instructions will erase all data from the USB drive. Make sure to backup any pre-existing data first.
Important
This article assumes that the /dev/sdc device node corresponds to the USB drive. If other SCSI-like devices exist be sure to use the correct device node. Major data loss could occur if the wrong device node is selected!

Create a FAT16 partition on the USB drive and mark it bootable using fdisk. An example partitioning scheme can be seen below:

Note
If the USB drive is 4GB or larger, use partition type b (W95 FAT32).
root #fdisk -l /dev/sdc
Disk /dev/sdc: 2063 MB, 2063597056 bytes
255 heads, 63 sectors/track, 250 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
  
   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1   *           1         250     2008124+   6  FAT16
Creating the filesystem

Create a FAT16 filesystem on the USB drive using mkfs.fat:

Note
If the drive is 4GB or larger, use -F 32 to create a FAT32 filesystem.
root #emerge --ask sys-fs/dosfstools
root #mkfs.fat -F 16 /dev/sdc1
mkfs.fat 3.0.22 (2013-07-19)
Installing a Master Boot Record (MBR)

Install the precompiled Master Boot Record (MBR) from syslinux on the USB drive:

root #emerge --ask --verbose sys-boot/syslinux
root #dd if=/usr/share/syslinux/mbr.bin of=/dev/sdc
0+1 records in
0+1 records out
440 bytes (440 B) copied, 0.00522668 s, 84.2 kB/s

Copying the files

Mounting the Gentoo Minimal Installation CD

Download a Gentoo Minimal Installation CD for the system's architecture from a the main site's download page and mount the ISO image on /mnt/cdrom as shown below:

root #mkdir -p /mnt/cdrom
root #mount -o loop,ro -t iso9660 /path/to/isofile.iso /mnt/cdrom

Adjust the /path/to/isofile.iso as necessary to the location of the downloaded Minimal Installation CD ISO.

Note
If a Could not find any loop device error message is displayed when mounting the ISO, a kernel recompile may be required. Verify the Loopback device support option in the kernel configuration has been enabled. For more information on kernel configuration see the kernel configuration article.
Mounting the LiveUSB

Mount the newly formatted USB drive on /mnt/usb as shown below:

root #mkdir -p /mnt/usb
root #mount -t vfat /dev/sdc1 /mnt/usb
Copying the files

Copy the files from the Minimal Installation CD to the LiveUSB. The files need to be reordered since syslinux will be used as the bootloader instead of isolinux:

root #cp -r /mnt/cdrom/* /mnt/usb
root #mv /mnt/usb/isolinux/* /mnt/usb
root #mv /mnt/usb/isolinux.cfg /mnt/usb/syslinux.cfg
root #rm -rf /mnt/usb/isolinux*
root #mv /mnt/usb/memtest86 /mnt/usb/memtest

Unmount the ISO image:

root #umount /mnt/cdrom
Adjusting the bootloader configuration

Adjust the syslinux configuration file using sed as shown below. The slowusb parameter will introduce some extra delays before attempting to mount the filesystem. This is needed to allow the USB drive to settle upon detection.

root #sed -i -e "s:cdroot:cdroot slowusb:" -e "s:kernel memtest86:kernel memtest:" /mnt/usb/syslinux.cfg

Installing a bootloader

Unmounting the drive

Make sure the USB drive has been unmounted before installing the bootloader:

root #umount /mnt/usb
Installing syslinux

Finally install the syslinux bootloader on the USB drive:

root #syslinux /dev/sdc1

Windows

Rufus

Rufus is a free and open source project created to successfully image USB drives with a variety of operating systems. It tends to be faster than the Universal USB installer (see in the next section).

Rufus can be downloaded from the project's homepage.

Rufus is so easy to use that instructions for its use are not needed for this article. Seriously, go check it out! If questions do come up, check out Rufus' FAQ page.

Universal USB Installer

Universal USB installer is one of the oldest Linux-capable LiveUSB creators for Windows systems. It supports most Linux distributions, and has a simple, helpful wizard for selecting the Linux distribution. For Gentoo Minimal Installation CDs, however, select the Try Unlisted Linux ISO which is at the very bottom of the list. Select the proper USB drive to format and extract Linux to, and click Create.

Universal USB installer can be downloaded from its homepage.

Booting

Insert the USB drive and turn on the computer, make sure the BIOS (or EFI firmware) has been set to boot from USB. If all goes well a standard syslinux prompt should appear on the screen.

Follow the generic installation instructions found in the Gentoo Handbook appropriate to the system's architecture from here on to install Gentoo!

External resources


This page is based on a document formerly found on our main website gentoo.org.
The following people contributed to the original document: brix, neysx
They are listed here because wiki history does not allow for any external attribution. If you edit the wiki article, please do not add yourself here; your contributions are recorded on each article's associated history page.