Manually Create a Live USB Flash Stick

by JohnBoy

Note from the Editor: Recently, my wife asked me to install PCLinuxOS 2009.2 on her Acer Aspire One netbook to replace the crawling Windows XP that was originally installed on it, and to set up a dual boot with Windows XP on her Dell Vostro 1000 notebook. Since I was going to install on the Acer Aspire One first, I decided to make a Live USB. However, repeated attempts at using the Make Live USB utility to create a bootable Live USB, failed. Next, I tried to use Unetbootin. I tried the PCLinuxOS version, but it met with the same results as the Make Live USB utility. I tried the Windows version (from a computer with Windows XP on it), and still had no success. Finally, I tried the method below. At first, I was intimidated by the length of the process. But, as I went through it, step-by-step, I discovered that it was not only easy, but it also successfully created a bootable Live USB — the very first time through. — Paul Arnote, PCLinuxOS Magazine Chief Editor

Pre-requisites:

  • Working from an installed PCLOS ….. either updated to present or a 2009.1 install.
  • Flash stick minimum of 1GB but preferably larger

Aim:

To produce a flash stick that will run PCLOS 2009.1 (or later) from any PC which is capable of booting from USB

Synopsis:

  1. Create an ext3 partition on a flash drive of 1GB size or greater. Give permission to everyone to R/W
  2. Copy the OS files to the partition from an ISO or CD of 2009
  3. Create a boot folder on the partition, and copy the grub folder from a running PCLOS 2009 into the boot folder
  4. Edit the menu.lst file on the flash disk
  5. Install Grub to the MBR of the flash drive

That's it!

Below is my suggestion of one method of achieving this. It is not the only method, nor is it exhaustive, but it should get you through the process if you are in any doubt.

Essentially this is the same method as described here http://pclosmag.com/html/Issues/200804/page01.html, with a few minor changes to the boot stanza and the use of the partition Label to boot, and also includes persistence.

************

Process:

Step 1.

  • Use "PCLOS Control Centre -> Local Disks -> Manage Disk Partitions". Delete all existing partitions on the stick.
  • Create an ext3 partition of minimum 1 GB, but preferably more if persistence is needed.
  • If it is a 4GB flash disk, then make the partition the full size of the flash drive.
  • Set the permissions of the partition to allow everyone to read and write it.
  • Give the partition a Label … let's say, 2009.
  • Format the partition.
  • Select Done from the bottom of the page.

Step 2.

  • Safely remove the drive and then reinsert it after a few seconds.
  • An icon should appear on the Desktop called 2009.
  • It should now mount to /media/2009 when clicked.
  • Right click on the Desktop icon, select Properties and from the Mounting tab, and untick "Access time Updates". Click OK.
  • Next, using a 2009 Live CD open it in Konqueror …

or

  • If you have just the ISO of 2009, right click on it … Actions -> ISO9660 View. This will open the ISO in Konqueror. Click on the folder ISO9660 to display its contents.
  • Then, click on the 2009 Desktop icon so that it opens in Konqueror or other file manager.
  • Now from the Konq view of the CD or ISO, copy the isolinux directory and the livecd.sqfs file to the 2009 flash disk partition.

Step 3.

  • Next create a directory called boot on the 2009 flash disk.
  • Navigate to /boot in the running OS and copy the grub directory to the boot directory of the 2009 flash disk.
  • Your flash disk should now have:
    • isolinux folder
    • boot folder {and inside this folder should be the grub folder}
    • livecd.sqfs file

Step 4.

Open the /boot/grub/menu.lst file on the flash disk for editing. Delete the existing boot stanzas, leaving the headings etc intact. Place a # in front of the gfxmenu line. (If you want a graphical boot, it can be done later.) Add the following boot stanzas:

Code:

title 2009 — With Persistence
kernel (hd0,0)/isolinux/vmlinuz vga=788 livecd=livecd fromusb root=Label=2009 changes_dev=LABEL=2009 acpi=on fstab=rw,noauto
initrd (hd0,0)/isolinux/initrd.gz

title 2009 — No Persistence
kernel (hd0,0)/isolinux/vmlinuz vga=788 livecd=livecd fromusb root=Label=2009 acpi=on fstab=rw,noauto
initrd (hd0,0)/isolinux/initrd.gz

Now, for the terminal stuff.

Step 5.

Open a terminal and su to root. Type grub <enter>. After some little time you get a grub prompt.

grub>

To be sure we work on the correct drive and not interfere with any HDDs in the system, we ask Grub to find all instances of menu.lst file:

grub> find /boot/grub/menu.lst

You will get a response something like:

(hd0,0)
(hd0,5)
(hd2,0)
grub>

This shows I have a menu.lst file in partitions 0 & 5 of hd0 (first HDD) and on the first partition of my third disk. So I reckon that the third disk is my flash drive but I want to confirm it, so:

grub> geometry (hd2)

This gives me:

drive 0x82: C/H/S = 500/255/63, The number of sectors = 8040448, /dev/sdc
Partition num: 0, Filesystem type is ext2fs, partition type 0x83

(Note: There may be other lines like the one above if there are other partitions on the device … such as Partition num: 1, Filesystem type is ext2fs, partition type 0x83)

I can see from this that the third disk is /dev/sdc, and I can confirm that to be my flash drive by hovering the mouse over the icon on the desktop, which will give me the device node of the drive. In my case, it tells me it is /dev/sdc1. So now I am sure I can go ahead and install grub to the MBR of that drive.

grub> root (hd2,0) <enter>  #this specifies the location of the files that Grub is to use when booting
grub> setup (hd2) <enter>   #this installs Grub to the MBR of (hd2) which is /dev/sdc

When this completes and reports success, all is finished. To change your flash stick to 2009.2 or .3 or later all that is required is to replace the isolinux folder and the livecd.sqfs file with the newer version.

Note: Without the fromusb code in the boot line the stick does not shut down properly. I do not know if its presence will affect correct booting in other situations … I have only a limited amount of hardware to try it on. I would appreciate it if others could check this out on their hardware. If the stick has a problem booting in any situation please first try removing the "fromusb" code from the boot line and then reboot.

Finally there is additional information below for those wishing to have more than one choice of OS on their flash drive. This explains how to configure the files to allow different versions of PCLOS to be bootable from the same flash stick.

For those of us who are using USB flash sticks to carry our favourite PCLOS releases around to boot whatever PC we come across, I thought to add a small change here which might make things easier.

The above method called for the various releases to be in their own folder and to change the location of the release files when you wished to boot a different OS. Instead of that method, which is awkward, try this …. Let us imagine that we have the OS files for

  • Minime 2009.1
  • PCLOS 2009.2
  • ZenMini 2009.1

all in their own folders on the USB stick.

Rename each of the pairs of files from isolinux & livecd.sqfs to something reflecting their release. So in the above example they might become

  • kdemini1 & kdemini1.sqfs
  • pclos2 & pclos2.sqfs
  • zenmini1 & zenmini1.sqfs

Now the files can be moved to the root of the stick and they won't interfere with each other as they all have different names, and are named in pairs representing their release.

Because the files are named differently we will need a different boot stanza for each release we have on the stick. So the menu.lst file might look something like this:

Code:

title Minime 2009
kernel (hd0,0)/kdemini/vmlinuz livecd=kdemini fromusb acpi=on fstab=rw,noauto vga=791
initrd (hd0,0)/kdemini/initrd.gz

title Zen Mini Gnome 2009
kernel (hd0,0)/zenmini/vmlinuz livecd=zenmini fromusb acpi=on fstab=rw,noauto vga=791
initrd (hd0,0)/zenmini/initrd.gz

title PCLOS 2009.2
kernel (hd0,0)/pclos2/vmlinuz livecd=pclos2 fromusb acpi=on fstab=rw,noauto vga=791
initrd (hd0,0)/pclos2/initrd.gz

You can of course keep adding releases as long as you have the space for them on your disk. If your files are on other than the first partition just change the (hd0,0) to reflect that … to hd(0,1) if they are on the second partition etc.

NB If you wish to use an older version of PCLOS — I tried Minime2008 — I advise not renaming the files. The change of name by the livecd= boot code was not implemented then it seems.

Have fun!