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.
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.
- 1 Prerequisites
- 2 dd
- 3 Linux
- 3.1 Manual installation
- 3.1.1 Preparing the USB drive
- 3.1.2 Copying the files
- 3.1.3 Installing a bootloader
- 3.1 Manual installation
- 4 Windows
- 5 Booting
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)
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:
dd if=/path/to/image.iso of=/dev/sdc bs=8192k
The remainder of this document explains how to setup a manual vfat partition that is writable using the syslinux bootloader instead of isolinux.
Preparing the USB drive
Partitioning the drive
These instructions will erase all data from the USB drive. Make sure to backup any pre-existing data first.
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:
If the USB drive is 4GB or larger, use partition type
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:
If the drive is 4GB or larger, use
-F 32to create a FAT32 filesystem.
emerge --ask sys-fs/dosfstools
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:
emerge --ask --verbose sys-boot/syslinux
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:
mkdir -p /mnt/cdrom
mount -o loop,ro -t iso9660 /path/to/isofile.iso /mnt/cdrom
/path/to/isofile.iso as necessary to the location of the downloaded Minimal Installation CD ISO.
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 supportoption 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:
mkdir -p /mnt/usb
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:
cp -r /mnt/cdrom/* /mnt/usb
mv /mnt/usb/isolinux/* /mnt/usb
mv /mnt/usb/isolinux.cfg /mnt/usb/syslinux.cfg
rm -rf /mnt/usb/isolinux*
mv /mnt/usb/memtest86 /mnt/usb/memtest
Unmount the ISO image:
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.
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:
Finally install the syslinux bootloader on the USB drive:
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.
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!
This article 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 as the 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 the history page.