From Fedora Project Wiki

Revision as of 02:31, 7 March 2009 by Beland (talk | contribs) (→‎Download an ISO: more detailed instructions)

This how to explains how to create and use a Live USB drive.

System Requirements

  • A working computer running Fedora or Windows
  • A USB Flash Drive with 1 GB or more of storage space (also known as a USB Storage Stick, USB Thumb Drive, or Jump Drive)

Ability to boot from USB media

Though most modern ones can, not all computers can boot from USB media, due to different BIOS settings and system capabilities. If your computer cannot do so, this procedure will not be useful. If you are not sure and don't mind downloading an installing an image on your USB drive (possibly wiping it of data), the only risk is wasting some time.

If your USB stick is not in working order, this procedure may fail. Watch for error messages during the process.

Some flash drives may not be bootable by default, even if your hardware is capable of doing so. You may need to mark the partition bootable or you may just need to reformat the flash drive. See "Errors and Solutions" below for more information.

Check the size of your USB device

Many USB sticks indicate the size on the packaging or the outside of the device.

If you don't know the size of the device, or want to check it for data, you should be able to auto-mount the USB device by inserting it into a USB port. You can check the contents and size using the graphical file manager. In Linux, you can also use the command line:

[tchung@localhost iso] $ df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
143G   14G  122G  10% /
/dev/sda1              99M   12M   82M  13% /boot
tmpfs                1009M     0 1009M   0% /dev/shm
/dev/sdb1             3.9G  4.0K  3.9G   1% /media/usbdisk

USB drives are usually mounted in /media. In this case, the device is /dev/sdb1 and has a 3.9GB capacity, and is almost empty.

Download an ISO

You can use BitTorrent or your web browser to download a bootable image, or ISO, which you will install on your USB drive. Quick links:

You are looking for a file with "Live" in the name, usually of the form "F<version>-Live-<architecture>.iso". For example, "F10-i686-Live.iso" is the Fedora 10 release for 32-bit Pentium Pro and compatible CPUs. "F11-Alpha-x86_64-Live.iso" is the alpha pre-release version of Fedora 11 for 64-bit Intel-compatible CPUs. Be sure to choose the right file for your architecture. (32-bit releases will generally run on 64-bit hardware, but will not be optimized.)

These instructions will also also work for custom spins of Fedora Live ISO images.

Command Line Method - Linux only

Check livecd-tools

$ rpm -q livecd-tools

If 'livecd-tools' is not installed, install it using yum.

$ su -c 'yum install livecd-tools'

Non-Destructive USB Install

Notice in the screenshot on right, the original content of the USB drive was not deleted by the script. That's because we use 'non-destructive' process.

File:FedoraLiveCD USBHowTo usb flash drive.png

In this demo, I used Imation Swivel Pro Flash Drive 1GB which comes with a Imation software as shown in the screenshot. You should be able to pick one up from local Target under $30 in United States.

Run livecd-iso-to-disk script

Make sure that the USB drive is not mounted before executing the following, and give the root password when prompted.

ls Fedora-<release>-Live-i686.iso
su -c "livecd-iso-to-disk Fedora-<release>-Live-i686.iso /dev/sdb1"
Password:
Copying live image to USB stick
Updating boot config file
Installing boot loader
USB stick set up as live image!

Data Persistence

Data persistence means that your files and settings will remain peristent even after you reboot your live system. Persistence is supported from Fedora 9 (beta) onwards. The primary usage of this feature is booting a USB stick with your live image as well as the persistent changes. To do this, take the live image and you can run the following command:

livecd-iso-to-disk --overlay-size-mb 512 /path/to/iso /path/tousbstick

where 512 is the desired size (in megabytes) of the overlay. The livecd-iso-to-disk shell script won't accept an overlay size value greater than 2047. You can find the livecd-iso-to-disk shell script in the LiveOS directory at the top-level of the CD image. Note that you'll need to have space on your USB stick for the live image plus your overlay plus any other data you want on the stick.

Bootable USB from a running Live CD/DVD

If you are already running a live CD or DVD and want to convert that into a bootable USB stick, run the following command:

livecd-iso-to-disk /dev/live /path/tousbstick

Graphical Method - Windows or Linux

Fedora LiveUSB sticks can be created in Windows and Linux using the liveusb-creator, For Windows using the following steps:

If you are using Linux, You can use Add/Remove Programs and search for liveusb-creator or

yum install liveusb-creator

If you encounter any issues using this method, please create a ticket against the liveusb-creator.


Errors and Solutions

Partition isn't marked bootable!

If you get the following message, you need to mark the partition bootable.

# livecd-iso-to-disk Fedora-<release>-Live-i686.iso /dev/sdb1
Partition isn't marked bootable!
You can mark the partition as bootable with 
    # /sbin/parted /dev/sdb
    (parted) toggle N boot
    (parted) quit
Cleaning up to exit...
# 

To mark the partition bootable,

# parted /dev/sdb
GNU Parted 1.8.6
Using /dev/sdb
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) print                                                            
Model: Imation Flash Drive (scsi)
Disk /dev/sdb: 1062MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End     Size    Type     File system  Flags
 1      32.3kB  1062MB  1062MB  primary  fat16             

(parted) toggle 1 boot
(parted) print                                                    
Model: Imation Flash Drive (scsi)
Disk /dev/sdb: 1062MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End     Size    Type     File system  Flags
 1      32.3kB  1062MB  1062MB  primary  fat16        boot 

(parted) quit                                                             
Information: Don't forget to update /etc/fstab, if necessary.             
#

Partition need a filesystem label!

If you get the following message, you need to label the partition.

# livecd-iso-to-disk Fedora-<release>-Live-i686.iso /dev/sdb1
Need to have a filesystem label or UUID for your USB device
Label can be set with /sbin/dosfslabel
Cleaning up to exit...

To label the partition.

# dosfslabel /dev/sdb1 usbdisk

Partition has different physical/logical endings!

If you get the following message, you may need to reformat the flash drive.

# fdisk -l /dev/sdb

Disk /dev/sdb: 2029 MB, 2029518848 bytes
129 heads, 32 sectors/track, 960 cylinders
Units = cylinders of 4128 * 512 = 2113536 bytes

Device Boot      Start         End      Blocks   Id  System
/dev/sdb1   *           1         961     1981936    6  FAT16
Partition 1 has different physical/logical endings:
phys=(967, 128, 32) logical=(960, 31, 32)

MBR appears to be blank!

If your test boot reports a corrupted boot sector, or you get the following message, you need to install MBR.

# livecd-iso-to-disk Fedora-<release>-Live-i686.iso /dev/sdb1
MBR appears to be blank.
You can add an MBR to this device with
Cleaning up to exit...


To install MBR,

# cat /usr/lib/syslinux/mbr.bin > /dev/sdb

How to reformat flash drive

Use fdisk to reformat the flash drive. If the drive is not new, a reformat is recommended. The fdisk command must be run as root or using the sudo application.

su -c 'fdisk /dev/sdb'

The following session output from fdisk shows the responses to give to the prompts. The line starting Last cylinder ... refers to the size of the flash drive, so may be different than in the example.

 
Command (m for help): d
Selected partition 1

Command (m for help): n
Command action
e   extended
p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-960, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-960, default 960):
Using default value 960

Command (m for help): t
Selected partition 1
Hex code (type L to list codes): 6
Changed system type of partition 1 to 6 (FAT16)

Command (m for help): a
Partition number (1-4): 1

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: If you have created or modified any DOS 6.x
partitions, please see the fdisk manual page for additional
information.
Syncing disks.

To finish, the partition must be initialized with an actual file system using mkdosfs as the root user. Unmount the device before using mkdosfs.

umount /dev/sdb1
su -c 'mkdosfs -F 16 -n usbdisk /dev/sdb1'

SYSLINUX Boot Error!

If you were using the script on previous Red Hat or Fedora Release and getting following error message,

SYSLINUX 3.xx ... EBIOS Load error - Boot error

You may need to upgrade your syslinux to 3.50 or higher from Peter Anvin's SYSLINUX .

Testing Live Image on USB

You can test your Live Image on USB using QEMU as shown in the screenshot on right.

File:FedoraLiveCD USBHowTo usb flash with qemu.png

For example, if your USB flash drive is on /dev/sdb1, you could type following command:

# umount /dev/sdb1
# qemu -hda /dev/sdb -m 256 -std-vga

See also

Red Hat Magazine | I am Fedora, and so can you!

References