Tag/tag.png

Duplicate Article
This article covers the same material as another article. More info...

Tag/tag.png

Content Cleanup Required
This article should be cleaned-up to follow the content standards in the Wiki Guide. More info...

Tag/tag.png

Style Cleanup Required
This article does not follow the style standards in the Wiki Guide. More info...

Technical details and custom USB Installation Media

Startup Disk Creator

Ubuntu distributions from 8.04 'Hardy' onwards have 'Startup Disk Creator' a usb-creator tool that creates a bootable USB flash drive from a Ubuntu CD or iso image. Most users should use Startup Disk Creator or Unetbootin instead of many alternatives described here that perform similar steps. Current Ubuntu versions can also be cloned directly from the iso file to a USB drive. See Installation/FromUSBStick.

UNetbootin (Windows or Linux)

UNetbootin automates this task by providing a GUI to create a bootable Ubuntu Live USB drive from an ISO file, and can be run from both an installed Windows or Linux system, or from a liveCD.

Optional: If you need to activate the original Ubuntu livecd boot menu, for example if you want to disable the framebuffer or read the Ubuntu livecd HELP screens and cheatcodes, please make these changes to your USB drive after your UNetbootin installation is completed:

1) Delete the SYSLINUX.CFG file or rename it to be SYSLINUX.OLD

2) Enter the ISOLINUX folder and rename the ISOLINUX.CFG file to be SYSLINUX.CFG. You may or may not need to rename ISOLINUX.BIN to SYSLINUX.BIN, but it won't hurt.

3) Move up to the top level and rename the ISOLINUX folder to be SYSLINUX

Portable Linux

http://rudd-o.com/new-projects/portablelinux/screenshot

This will install the LiveCD environment from your install CD onto the USB drive. When you boot from USB, it will show you a GRUB menu with one option in it, which will then take you directly into the LiveCD environment.

You can use this to install Ubuntu onto the computer's hard drive by using the Install icon on the desktop.

Persistence is setup automatically, so it will remember any changes you make between reboots. You can also use the built-in GRUB to launch other disk images, like MS-DOS or memory test. The USB drive has a single normal partition on it, with a casper-rw image and a boot directory for GRUB. You can use the drive normally when not in the Live environment, and access it from the Live environment through a loopback.

Live USB creator (GUI-based, runs from Live CD)

Live USB creator automates the process of creating a bootable Live USB system from a running Ubuntu Live CD. Simply run the Live CD, install the tool and start the Live USB installation from the System administration menu.

https://launchpad.net/liveusb -- probono

http://klik.atekon.de/liveusb/screenshot.png

You can run the tool from your normal desktop, just insert the Ubuntu Live CD and run it.

You may encounter an error when trying to boot from the USB drive, something like "Missing operating system". Make sure that you can mount the USB drive on a normal Ubuntu install, and that you can browse it in the file browser. If you can't, it hasn't been created properly. I found that using fdisk to delete the partition on the drive first, then running liveusb, worked nicely.

isotostick.sh (Command-line shell script, runs from Linux)

Warning: Running scripts from untrusted websites is potentially dangerous! Warning: Something's wrong with the script as it wants to use vol_id which was removed in newer versions of Ubuntu. Simply replacing the path by the blkid one won't solve this isse.

The easiest way, which also works with the Desktop installer, is to use the isotostick.sh script from http://www.ymer.org/files/isotostick-jj.sh. Download the script, make it executable and run the script like this ( alternate link with older version: http://download.ubuntu-fr-secours.org/isotostick.sh ):

sudo apt-get install syslinux mtools
wget -O isotostick.sh http://www.ymer.org/files/isotostick-jj.sh
chmod +x isotostick.sh
sudo ./isotostick.sh ubuntu-7.10-desktop-i386.iso /dev/sdX1

Don't forget to replace /dev/sdX1 with the partition name of your USB drive found in the previous section! You will see some "operation not permitted" errors when the script tries to copy the symlinks for /dists/stable and /dists/unstable. This is because fat16 file systems do not handle symlinks, but it will not cause any problems.

Now you can boot from the USB drive and install Ubuntu like as if you had booted from the Desktop CD.

ubuntu-server-flashdrive-installer.sh (Command-line shell script, runs from Linux)

The UbuntuServerFlashDriveInstaller was developed from the instructions at this forum post.

Comment: Does not work with ubuntu-8.10-server-amd64.iso - says no usable ISO found - any ideas?

liveusb-creator (from Fedora)

If you are currently running Fedora you can use the liveusb-creator to create a live Ubuntu USB drive. Use the Use existing live CD option to select an Ubuntu Live CD that you have downloaded.

Creating bootable USB manually

In short here's what you have to do:

Make your USB stick bootable with SYSLINUX

SYSLINUX is a boot loader that operates off an MS-DOS/Windows FAT filesystem. Most USB flash drives come with a FAT filesystem. Here's how you can add a SYSLINUX bootblock to your USB drive:

  1. Make sure that "syslinux" is installed. SYSLINUX is available for both Linux and MS Windows (the executable is in the archive under \win32\syslinux.exe). For more information check the SYSLINUX homepage: http://www.syslinux.org/. On Ubuntu Linux, install it with:

     sudo apt-get install syslinux mtools
  2. Attach your USB drive to your computer and mount it. This may happen automatically. If you are using Linux and it does not get mounted automatically, you can mount it by using a command such as mount -t vfat /dev/sda1 /mnt . Note the mountpoint (i.e. /mnt in the example. If you are using Windows, it should get mounted automatically. (If it doesn't your version of Windows is probably pretty old, and you'll need to install a driver for the USB drive first. Check the vendor's homepage.) Note the drive letter that Windows assigns to it (for example F:).

  3. Make the USB drive bootable. If you're using Linux and your USB drive is mounted as in the above example, use: syslinux -s /dev/sda1. If you are using Windows and the flash drive has the letter F: assigned to it as in the above example, use: syslinux -s -m F:

Those using Lucid (10.04) to make a pen drive to boot Precise (12.04)--that is to say, using the previous LTS release to go to the next one--will need to be aware of this incompatibility between the syslinux versions involved:

there are a couple of work-arounds (eg, typing 'help' at the prompt and then hitting 'enter') but the bug has been triaged and labeled WONTFIX since Maverick and as late as March 2012.

  1. You should see a new file called ldlinux.sys in the root directory of your flash drive. (Note that it is a hidden file, you might not see it in Windows Explorer; try dir /a F: from a command prompt). Now you can boot from your USB drive. Read on once you get a SYSLINUX message and a ""boot:"" prompt.

    • Regarding the IDE disk: When in the USB cradle, the disk is sda, whereas when I mount it in the Libretto as the primary IDE disk, it is of course hda. (I shot myself in the foot a couple of times because of this ...)

      The automatic mounting is a bit distracting at times. My recommendation would be to pumount any device you intend to do any low-level operations on, and then mount and unmount as root as necessary. -- Era

      Make sure to include the -m option with the Windows version of syslinux, to ensure that it copies a fresh ISOLINUX master boot record (MBR.) Otherwise the preexisting MBR may be used, which therefore may not point to your syslinux.cfg file.

      If you have problems with your MBR on a Linux install, do something like "cat /usr/lib/syslinux/mbr.bin > /dev/<your_usb_device>" to write the standard SYSLINUX MBR to the device as documented here: http://syslinux.zytor.com/wiki/index.php/Doc/syslinux

Copy the Ubuntu CD to your USB stick

Copy the contents of the Ubuntu installation CD to your USB drive (i.e. all files and directories that are on the installation CD). Please do not copy an ISO image of the installation CD. Note that you don't have to burn the iso to copy it's contents, from linux it can be mounted like so:

mount -o loop /path/to/ubuntu.iso /path/to/mount/point

Make sure you also copy hidden files and directories (eg. ones with names beginning with a "."). In Gnome, press ctrl-H to see hidden files. In MS Windows you can use the following command, assuming that D: is your CD-ROM drive and F: is the USB drive:

xcopy /e /h /k d:\*.* f:

'cp' doesn't copy hidden files, by default, but the following command line works:

cp -a /path/to/iso/mount/point/. /path/to/usbstick/mount/point

Note the /. after the source, and the lack of / after the destination...

Move files to the root directory

This step is not needed if you prepared the flash drive with syslinux 3.35 or newer (Ubuntu 7.10).

Copy (or move) the files stated from the following directories to the root directory of your USB drive:

Adjust SYSLINUX.CFG

For recent versions of syslinux, you just need to rename the isolinux directory to syslinux and rename the file isolinux.cfg inside this directory to syslinux.cfg .

For older versions: Copy (or rename) the file isolinux.cfg to syslinux.cfg. Then edit the file and remove the /casper/ or /install/ reference in all paths. For example you would change the line containing DEFAULT /casper/vmlinuz to DEFAULT vmlinuz. Save the file, and make sure it is called syslinux.cfg. It does not matter whether the line breaks are in DOS or Linux format.

Boot from the USB stick

Boot the computer from the USB drive. The installation can now be done as if you would be booting from the installation CD.

Mounting the USB stick as /cdrom

This step is only needed for the Alternate install CD and Ubuntu 6.10 or older.

Switch to the second virtual console during the first couple of dialogs (when asked about your preferred language for the installation etc.) by pressing the ""ALT-F2"". Do the following:

Then switch back to the first virtual console by pressing ""ALT-F1"". Continue installing Ubuntu as if you were running from CD.

Alternate Install (Ubuntu 9.10)

The procedure above causes problems for people when using the Alternate Install CD-ROM. This variant works for me:

Download harddisk kernel to replace CD-ROM kernel

Download 'vmlinuz' and 'initrd.gz' from http://archive.ubuntu.com/ubuntu/dists/karmic/main/installer-amd64/current/images/hd-media (adjust 'karmic' and 'amd64' to suit your needs)

Set a shell variable to the files' directory, e.g.: HD_MEDIA=your-browser-download-directory

Make your USB stick bootable with SYSLINUX

Same as above. Set a shell variable to your USB disk mount point, e.g.: USB_MNT=/media/disk

Copy the Ubuntu CD to your USB stick, Adjust SYSLINUX

Note: in this variant, the USB stick only contains a few boot-supporting files and the raw .iso image.

ISO_FILE=ubuntu-XXX.iso
ISO_MNT=/mnt

mount  -o loop  $ISO_FILE  $ISO_MNT
cd $USB_MNT

cp -R  $ISO_MNT/isolinux  syslinux
cd syslinux
mv  isolinux.cfg  syslinux.cfg
cd ..

cp -R  $ISO_MNT/install  .
cp  $HD_MEDIA/vmlinuz  $HD_MEDIA/initrd.gz  $USB_MNT/install    # Overwrite CD-ROM versions

cp  $ISO_FILE  ubuntu.iso

umount $ISO_MNT
umount $USB_MNT

After Installing

After finishing the installation, edit /etc/fstab and make sure that /media/cdrom0 points to the CD drive and not to the USB drive. If you don't, you might get this error when trying to mount a USB drive: "Cannot mount volume. Invalid mount option when attempting to mount the volume." This is because the installer believes it is installing from a CD drive (bug 150872).

Open /etc/fstab for editing, e.g.

  • sudo gedit /etc/fstab

Find a line like this (usually at the end):

  • /dev/sdb1       /media/cdrom0   udf,iso9660 user,noauto,exec,utf8 0       0

and comment it out by placing a # at the beginning:

  • #/dev/sdb1       /media/cdrom0   udf,iso9660 user,noauto,exec,utf8 0       0

You can also rename the real cdrom mount point to /media/cdrom0 if you like.

Save the file, and you're done.

See also

Comments and Troubleshooting

Check your USB drive

Booting from USB storage can be very handy, but there is no guarantee that it will work with your particular combination of computer and USB drive. Even if you are able to boot from your USB drive on one computer, this does not mean that it is going to work with the next one. You can try experimenting with different settings in your PC's BIOS to make it work.

In order to boot from a USB drive, there are a few requirements to meet. The drive must contain at least one partition with a Master Boot Record (MBR) sector. (Some BIOSs do not require this, but many, especially older ones, do.) Formatting using the built-in windows tools will not create an MBR, so you will need to use another tool to do so. For more information, see USB boot without bios support or google "boot from usb" and read a lot. For more technical details, check out Prepping a USB flash device for boot. For a tool from HP which will format a USB stick with an MBR, download the HP USB Disk Storage Format Tool v2.1.8. Make sure you do any partitioning/formatting before you proceed with the following methods.

Make sure to pick a drive that is large enough to hold the contents of the installation CD (about 700MB), 1GB is recommended. Versions of SYSLINUX 3.53 and before require the use of a FAT16 file system, which most 2GB or smaller USB drive come formatted with anyway. This is the most compatible file system, and is recommended. As of version 3.00, SYSLINUX works with FAT32 as well.

Insert the USB drive you want to use for the installer. A few seconds after plugging in the USB drive run the dmesg command or sudo fdisk -l to find the device name it was assigned. The rest of the instructions refer to /dev/sdX1, remember to replace X with your device location.

Other notes

   title Ubuntu
   root (hd0,0) # Assuming /casper on first partition of USB media
   kernel               /casper/vmlinuz file=/cdrom/preseed/ubuntu.seed boot=casper initrd=/casper/initrd.gz quiet splash ignore_uuid
    initrd              /casper/initrd.gz

On Partitioning the Flash drive

Confusion

Is this page about installing Ubuntu from a USB stick, or installing it to a USB stick? Those are completely different things, you know...

There seem to be many different methods for doing these things, with necessarily similar names. They should all be summarized at the top.


Ubuntu distributions from 8.04 'Hardy' onwards have 'Startup Disk Creator' a usb-creator tool that creates a bootable USB flash drive from a Ubuntu CD or iso image. Most users should use Startup Disk Creator or Unetbootin instead of many alternatives described here that perform similar steps. Current Ubuntu versions can also be cloned directly from the iso file to a USB drive. See Installation/FromUSBStick.

USB Installation Media (last edited 2017-09-22 19:01:48 by ckimes)