This article explains how to create a LiveUSB stick using the 'syslinux boot loader.' If you take nothing else away from reading this, the most important tip is to start with the latest version of 'syslinux.' After installing version 3.86, all of the strange problems that I was having on my PC went away. This article also explains adding an 'EFI' boot loader such that a LiveUSB can be booted on both an Intel-based Mac and a PC.
None of what follows is original work on my part, but was accumulated from many bits and pieces that I found on the Web. I have made changes to some of the pieces for better integration into the examples. See the Reference section, below, for links to where I found things. Special thanks go to Mathieu Carbou for a very nice example of syslinux menu configuration.
Dispelling Some of the Myths
The concepts of booting a PC from a USB are fairly simple, and it no longer needs to be obscure and arcane dark magic that is known by only a few voodoo priests.
I have tested all of the steps described in this article using USB sticks made by Kingston (2GB), PQI (4GB), and Sandisk (16GB) on an older Gateway tower PC, a newer HP laptop, a MacBook white model, and a MacBook Pro black model.
Most PCs sold since the turn of the century can be configured to boot from a USB memory stick with only a couple of simple changes. Unfortunately, the way to do this can be very different depending on the manufacturer.
To check if this is possible, start your PC and press the key to enter "Setup Mode" which is sometimes called the "BIOS Menu." To do this, notice what the initial startup message tells you. It may flash by rather quickly, so be ready to react. On many computers you must press and hold the F2 key, but sometimes it's a different key.
Once you get the Setup Menu, look for a menu labeled "Boot Order" or "Startup Sequence." If nothing is obvious, try some of the menu choices. What you are looking for is a list that determines the way your computer searches for a 'bootable' device.
Warning: Making changes to your PC's BIOS settings can potentially
prevent your computer from booting or working correctly. If you are not
comfortable making these changes, it may be best to have someone else do
this part.
Usual choices include
After you have made any necessaary changes to the Boot Priority order, remember to save the changes. As the way to do this often varies, read the menus to determine how to accomplish this.
Then, to confirm that everything works, make a USB stick 'bootable' as described next, and give it a try.
To get started, download the following little zip file.
\boot\syslinix
Select the correct script to run depending on the Operating System
that you are using
(thanks to Mathieu Carbou for these, with a fix from "Judago"
[see response #11]).
\boot\syslinux\setup.bat (for Windows users, all versions)
/boot/syslinux/setup.sh (for Linux, and OS X users)
Warning: Altering memory devices connected to your PC can potentially prevent your computer from booting or working correctly. If you are not comfortable making these changes, it may be best to have someone else do this part.
Run the selected setup script to make your USB memory stick 'bootable' — this will alter the Master Boot Record (MBR) of your USB stick, but it shoud not alter or harm any data on the device. That said, it's always best to back up anything that you don't want to loose before altering or reconfiguring any memory device.
That's all it takes. Your USB stick should now be 'Live.'
Give It A Try
With your new 'LiveUSB' memory stick connected, reboot your computer. You should soon see a menu screen with several choices. Use the arrow keys on your keyboard to move up and down, then use the 'Enter' key to select an entry.
If it doesn't work, confirm that your PC can and will boot from a USB memory stick, as explained above. Of course, none of the entries to actually boot things will work until you install applications onto your new LiveUSB memory stick.
Download the following syslinux menu archive file. If you want the new menus to actually boot things, install one or both of the applications as explained below, which can be done either before or after you complete the steps here. The demo here contains only the menus, and not the application files.
\ubcd\menus2
That it. You're ready to go.
Give It A Try
With your new 'LiveUSB' memory stick connected, reboot your computer. The menu entry for 'Ultimate Boot USB' should now include a lot of sub-menus. The menu shown here is from the sample configs by Mathieu Carbou.
When you see a "scroll bar" on the right-hand side of the menu, you can use the arrow keys to scroll, or you can use the "page up" and "page down" keys.
Most entries will have sub-menus. When in a sub-menu, you can use the "Return..." entry to return up one level, or you can use the 'Esc' key as well.
If it doesn't work, confirm that your PC can and will boot from a USB memory stick, as explained above. Of course, none of the entries to actually boot things will work until you install the applications onto your new LiveUSB memory stick.
Many Linux distributions assume they will be the only thing installed to a given USB drive. In addition, the many applications available to assist with creating a LiveUSB assume this as well. An easy solution is to create a separate top-level directory on your USB memory stick to hold each of the various applications that you may want to install and boot.
However, after the installation, the boot menus included with a given application will not work as originally designed. Fortunately, it is fairly simple to change the menus as explained below.
These two applications were chosen for several reasons. They are both small. they are both useful, and installing Puppy first makes it very easy to install UBCD and other 'Live' distributions.
Note that it is not necessary to install this software. The menu examples, above, will work as examples. However, for the menu entries to actually boot anything, you must install something for syslinux to boot.
This is a small yet elegant and fully featured version of Linux. Puppy is a wonderful introduction to using Linux. In addition, Puppy makes it very easy to extract the contents of ISO files, as explained below, which is useful when installing from the UBCD ISO file (App II in this section).
Puppy is included here as an example of eliminating the ISO file and distributing via ZIP. You should note that this is a custom version of Puppy Linux.
\puppy
For Windows simply right-click on the file name and click "Extract..." then enter the drive letter of your USB stick and the puppy subdirectory. For example, if drive 'E:'
E:\puppy
unzip pup-431-ebank-006.zip -d /mnt/sdb1/puppy
If you are familiar with Puppy Linux: This version is from a project I did to create a safe way to do online banking. To ensure that no trojan or 'malware' is retained on the system, the 'save session' option is disabled. To re-enable 'saved sessions' boot Puppy Linux from your LiveUSB and then delete the following file (this is a hidden file so either delete using a terminal window or, if from the File browser, click the 'Eye' icon to show hidden files)
/root/.disable_save_session
This is a collection of many great utilities for diagnosing and repairing problems with PCs. These are specialized tools and are probably not something that casual PC users should attempt, but they are very useful to PC technicians.
These are also nice for this tutorial because they come packaged with simple text-based menus. The menus included above are an example of how to convert the original menus into graphical menus.
If you do decide to download this collection of utility tools, start by downloading the ISO format file. From the following link it may be tempting to download the ZIP file, but this simply contains the ISO file which means you have to extract things twice.
To install this application, create a top-level folder on your USB stick named ubcd, and copy everything from the ISO file into this new top-level folder. You should then have a directory on your USB stick that looks like this, and contains all of the UBCD distribution files and sub-directories.
\ubcd
Using Puppy Linux makes it very easy to open ISO files. (This example assumes that the ISO file is already on the PC, and that Puppy Linux 4.31 is booted.)
First, from the Puppy Desktop, click the icon of a house labeled 'File,' which is located in the far upper left-hand corner of the screen.
Second, using this new window, navigate to the directory on the PC where you stored the ISO file. If you use Puppy Linux to download the ISO file, best to download it to the /root subdirectory. If you get an error message, see the note, below.
Third, to open the ISO file, all you need to do is click on the ISO file in the 'File' browser window. A new window will open showing the contents. At this point, click the icon near the lower left-hand corner of the desktop that looks like a little USB memory stick. If you don't see this icon, make sure that your new LiveUSB stick is plugged in.
Fourth, to copy the contents, 'drag-select' to highlight all of the files in the ISO window, and then 'drag-n-drop' to the USB window. You may need to make the ISO window a little larger to easily select all of the contents.
Fifth, to ensure that all files are copied, right-click on the USB icon (lower-left hand corner) and select 'Unmount sdxx (if currently mounted)', which is the equivalent of a 'safe removal' of a USB device under Windows. It may take a few moments for this to complete as the files finish copying to the USB. When the green dot on the USB icon goes away, it's safe to remove. Have a little patience and remember that you're copying a lot of data to your USB stick.
I did encounter one problem: If, in the second step, you get a message that the ISO file could not be opened, open another 'File' browser (which will be the /root subdirectory), and copy the ISO file into this new window. (Simply drag-n-drop, then click the 'copy' menu entry.) Then open the ISO file from this window, by clicking on the file, and it should work.
I'm not sure why this error occurs. it may be because my ISO file was in a directory tree that was too deep, or maybe it doesn't like spaces in the directory names.
Making Necessary Menu Changes
Because we are installing the software in a location that is not expected by the designers of the application, we need to alter the syslinux boot menu entry(ies) for the things we wish to boot. This can be rather a tedios part of the process.
You must locate the syslinux menu file(s). There may only be one file, and it may have one or more entries, or there may be multiple menu files.
For a first example, this shows the Puppy Linux boot entry. There is only one file with a single menu entry, and the changes are straight forward. Each file needs the path updated. The changes are shown in bold.Making changes to syslinux menus can be quick and simple if you only need to change an entry or two. Otherwise it can be tedious. It would be nice if application developers would not assume that their product is the only one installed.
Once you become familiar with what parts need changing, it becomes a matter of identifying the entries you want, and making the necessary changes.
At this point I have not yet got Puppy Linux booting on the Mac. However, I have successfully booted the latest Ubuntu Desktop (9.10 for i386) on both my PC and my MacBook using the same USB.
Start by downloading the following little zip file.
\efi\boot
That's all there is to it.
Just remember that to boot the OS you need to use one, such as Ubuntu, that has been built with EFI support.
Give It A Try
To prove that it will boot, insert your LiveUSB into your MacBook. Hold down the 'Option' key, and then press the power button to turn on the computer. Continue holding the 'Option' key until you see an image with the USB logo displayed on the screen. After that appears, you should soon see a second image of a hard disk. It should also work if you connect the USB stick after you see the hard disk image, so long as you hold down the 'Option' key.
Click on the arrow underneath the USB image to select that, and then click on the image a second time to start the boot loader. You should soon see a simple menu screen. Of course, none of the entries to actually boot things will work until you install the applications onto your new LiveUSB memory stick.
If you download and install from the Ubuntu ISO, open the ISO file and copy the contents into a top-level folder on your USB stick named '\ubuntu' you should then be able to boot Ubuntu Linux on both your PC and your Mac using the existing menus that are included with these examples. (One way to open the ISO file is described above.)
Two additional notes: The Ubuntu ISO file is nearly 700 Megabytes, so make sure you have the space and a reasonably fast network connection. Also, while my MacBook worked fine, I was unable to boot Ubuntu on my neighbor's MacBook Pro, and have yet to determine the problem. (It could be as simple as not waiting long enough — booting on the MacBook seems to take somewhat longer than on the PC, and the USB stick I used did not have an LED so I couldn't tell if there was any activity or not.)
And one update: It's now possible to boot Ubuntu and some of the other Linux distros directly from the ISO file without copying any files out. However, this relies on using a boot loader that supports ISO booting. The EFI boot mechanism described here is based on Grub2, which does suport this feature. If you want to try this, sample Grub2 menu entries for Ubuntu are available on this site.
Also stay away from the many little applications that 'help' to create a LiveUSB by copying the contents of an ISO file to your USB stick. Of the dozen or so that I tried, all of them copy the ISO file contents to the root directory of the USB stick. This is not helpful if you ever decide to add another application.
In addition, all of these little 'helpers' will update the Master Boot Record (MBR) on your USB stick but, with one exception (see below), they don't bother to let you know how it is done, or using what version of the syslinux boot loader. This is not helpful either.
One of these 'helpers' named Linux Live USB Creator, or LiLo, actually removed the /boot subdirectory from one of my USB sticks. I would avoid this one at all costs until such time as this serious defect is fixed.
What would be helpful is a LiveUSB creator that
provides the option to install everything into a subdirectory,
and gives the option to not update the MBR.
For extra credit, if it could copy the syslinux menus for that
app and create new versions that pointed to the correct location
that would be fantastic. Something similar to how FireFox
can save a web page, create a subdir with all of the graphic elements,
and change all of the links to access the new subdir. It can be done.
(There is maybe one exception to this list of things to avoid:
the Pendrivelinux
Universal USB Installer was the nicest of all the 'helpers'
that I tried — even though it copies files to the root subdir and
forces an update of the MBR every time it is run.)
(Another exception to this list is MultiBootUSB, a great script that runs on Linux systems and can install around 100 different Linux distros to a Live USB. However, this relies on the Grub2 bootloader — which can boot directly from ISO files, when they are built correctly. The problem is that Grub2 doesn't install correctly on all USB sticks. See the other resource links, below, for details.)
The 'ISO' distribution files and complicated instructions to create (or 'burn') CD-ROMs can become a thing of the past. If you don't think that instructions to install software from ISO files are complicated, it's probably because you have some experience doing this. For people who may only ever do this once or twice, it's daunting and unpleasant.
As a software distribution mechanism CDs do remain somewhat useful, so long as you don't have to create the silly things yourself. For archival purposes CDs, and even DVDs, are limited in space. Newer DVDs will hold more but, for archival use, even the best DVDs have a limited life span. A 1- or 2-terabyte hard disk is an inexpensive backup solution, and can keep a lot of backups instantly available.
Perhaps it's time for CDs and DVDs to follow floppy disks into extinction, and the 'ISO' file should become extinct as well. I'm sure there will always be people who think they need ISO files for some reason, but don't let them force you to think that way. (There are also people who still think that the Earth is flat, but most people now agree that the Earth is a round speck of dust nestled in a pink clover which is held safe by the trunk of an elephant named Horton. Who?)
As USB memory sticks increase in capacity and reduce in size and price, the
usefulness of optical disks will be limited even further. 32GB sticks are
now around US$100, and Kingston has a new 256GB stick available in Europe.
Granted this beast is currently US$900, but remember how expensive 4GB
sticks were only a few years ago. A 4GB PQI stick today is under US$15 on
Amazon and is smaller than any of the keys on my keychain. It won't be long
before 64GB and 128GB sticks are as common as 1GB and 2GB sticks are today.
If the results have been helpful, I'd appreciate hearing from you. If you experience problems following these notes, post a comment and I will attempt to further clarify the examples.
Additional links specific to Intel-based Macs
Why not use Grub2 as the boot loader?
[Added 07-Nov-2011]
At least two reasons
(these are problems with MBR booting on a PC, not EFI booting on a Mac).
None of the following details are necessary to make a USB Flash Memory stick bootable. They are included here as further reading. However, the first two links are useful if you are interested in getting the maximum possible performance from your USB stick. [Updated 15-Nov-2011]
Post any
comments or questions on the blog.