Talk:Ubuntu Installation from a Flash Drive

From Free Knowledge Base- The DUCK Project: information for everyone
Jump to: navigation, search

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:

   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
   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:).
   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:

   https://bugs.launchpad.net/ubuntu/+source/syslinux/+bug/608382 

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.

   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:

   isolinux (all files)
   casper (vmlinuz and initrd.gz)
   install (all files)
   - Downloaded Jaunty Desktop i386 iso and followed the manual procedure here, moving the files from the above folders. Got a similar result to a user below (could not install), so don't move the files from isolinux, casper and install folders, just copy them to the root directory. [I could then boot and install on my Thinkpad X60s without problems. From Hardy to Jaunty inside 30 minutes!!] -- badwolf 

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.

   Again, for anyone installing Ubuntu 7.04 (Feisty): Just remove the /install/ reference. The only line it is found is kernel /install/mt86plus, which must be changed to kernel mt86plus. -- Boo
   no, it is not. there were 23 entries on isolinux.cfg -- capi
   I found twenty one, with Feisty, and syslinux 3.51 -- Gedanken
   For Karmic, isolinux.cfg doens't contain any references, but it invokes other .cfg files, which invoke more, etc. The references that need to be changed are in text.cfg -- jmkasunich 

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:

   mkdir /cdrom /dev/cdroms
   cd /dev/cdroms
   ln -s ../sda1 cdrom0 (where sda1 is your USB drive)
   mount -t vfat /dev/cdroms/cdrom0 /cdrom 

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

   This was a bit tricky until I got the hang of it. You need to have the hardware detection detect your hda before you can mount it! But just wait until it complains about a missing CD-ROM, then don't try to helpfully tell it where to look. Just accept the dialog where it says that this stage failed, then switch over to the virtual console and mount -t vfat /dev/hda3 /cdrom. (I skipped the gyrations with /dev/cdroms, they don't seem to be necessary.) Back in the installer, you should now be able to proceed from the next point in the dialog. (Remember, I'm talking about the text-only installer. It might be different in the GTK install.) -- Era
   I think just ran into https://launchpad.net/distros/ubuntu/+source/casper/+bug/63277 -- SvenHerzberg
   When installing Ubuntu 7.04 (Feisty), there was no need for me to mount the flash. -- Boo
   This is does not work for me using the alternate gutsy iso - i.e. mount -t vfat usbdev target fails with "no such device". There is a forum thread here: http://ubuntuforums.org/showthread.php?t=405008 Currently I know of no solution but to use the regular iso. -- Stenico 

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

   https://wiki.ubuntu.com/LiveUsbPendrivePersistent