Manual Set up of PCLOS Live on USB drive

by ClareOdie

Forum Thread

Warning: Following these instructions could result in loss of valuable data. You try this entirely at your own risk.

While I like LiveCds I think they suck in operation. They are noisy and slow.

Enter the USB drive - flash drive, USB stick, pendrive or whatever name you might have. Even external USB HDD. All much faster and less noisy than a CD.

So I decided that I wanted to have my Live PCLOS on a USB stick, but I wanted it to be easy for me to change from PCLOS KDE to PCLOS Gnome to BEL Server to Tiny to Flux etc, etc, as the mood and requirements dictated. This is what I have done. It works for me. No guarantees for anyone else.

I see lots of stuff written about putting PCLOS onto a pen drive/ USB stick/flash drive or whatever. Lots of people seem to have difficulty with this, or maybe it is the concept that escapes them. I don't know what it is, but what follows is a very useful way to have a USB drive set up for your favourite PCLOS distro or derivative. I use Grub as the bootloader.

What is required is a 1 GB USB drive. Smaller is manageable but does limit the distros that will fit on it. With a 1 GB drive anything that fits on a CD will fit on it. You can use a larger drive if you wish of course. To do so would make it possible to put your own remaster on the stick.

The Concept:

Create partitions on the drive to hold the OS files and also the boot files. For the sake of security we will keep the OS files separate from the boot files. There is no attempt in this document to extend the capabilities over those of the liveCD. In other words if you want to save changes or have persistence then you will have a little more work to do.

To get started .... while running in PCLOS insert your USB drive and go to PCC - Mount Points and in there delete all partitions on the drive. Press "Done" at the bottom of the screen when completed.

Go back into Mount Points. Ensure you select Expert Mode at the bottom, and select each partition to be Primary Type. Create partitions on the drive as follows:

  1. 5 MB in size VFAT (Fat16 or Fat32) type
  2. The rest of the USB drive or 1 GB also as VFAT (Fat32) type

Format both partitions. Press "Done" again. Unplug the drive and reinsert it after waiting a few seconds. You should now have two partitions available for your use.

Can a single partition be used instead? Yes it can, but here are some reasons I prefer to use two partitions:

  • I like to keep Grub separate from the OS on its own partition.
  • It makes it less likely that someone inexperienced will delete the grub stuff.
  • It also ensures that if a user is copying files to the second partition they will not inadvertently overwrite the grub files and leave the device unbootable.
  • Bear in mind also that a user can do as they like with the second partition - change filesystem type or delete or enlarge the partition, etc, etc, and it should not affect the drive's ability to boot.

If the Grub files were on the second partition then the install procedure would need to be done again.

** We are one-third the way there. **

Copying the Operating System Files

You can copy the needed files from a LiveCD

******** OR ********

Extract the files from an ISO

Next, if you do not have Kiso installed do so now using Synaptic. Once Kiso is installed you can click on an ISO image of your favourite PCLOS and choose:

Actions -> Kiso -> Mount as Virtual Drive

That should bring a CD icon to the Desktop from where you can open it. Copy the isolinux directory and the livecd.sqfs file from the CD to the second (larger) partition of the USB drive. Once the copy is completed go back and right click on the ISO image again and choose:

Actions -> Kiso -> Unmount Virtual Drive

(the ISO can also be mounted at the terminal, but if you know how to do so there is no need to mention it here)

Please note that although the files may have been copied FROM the ISO it will take a while for them to be copied TO the USB device. They are first copied to memory and from there to the drive. The copy dialog disappears when the copy FROM is completed which can be a considerable time before the copy TO completes. Please make sure you do not prevent the copy process from completing.

** We are well on the way ... **

Using your file manager, create, on the smaller partition of the USB drive, a directory called /boot. Also while there, create another directory and call it gfxmenu. Please note that this location may be something like system:/media/sdc1 when viewed in the location bar of your file manager.

Next, in file manager, navigate to the root directory of the running operating system( / ), and there open /boot/ which should display the grub directory and a lot of other files. Copy the grub directory, from the running OS, to within the boot directory on the small partition of the USB drive. That is the directory created above. Next navigate to /usr/share/gfxboot/themes/pclinuxos/boot/ and copy from there to the new gfxmenu directory on the USB drive, the file called message.

** Nearly there! **

On the smaller partition of the USB drive (make sure of what you are doing here), navigate to /boot/grub (maybe like system:/media/sdc1/boot/grub/ ) and open (with Kwrite) the file menu.lst.

Delete all of it's contents and replace them with the following (you can copy & paste):

timeout 10 color black/cyan yellow/cyan
gfxmenu (hd0,0)/gfxmenu/message
default 0
title Live PCLOS
kernel (hd0,1)/isolinux/vmlinuz fromusb vga=788
initrd (hd0,1)/isolinux/initrd.gz

Save the file.

To recap on what should have been done:

  1. Create 2 partitions and format them
  2. Copy the OS files to the second partition
  3. Copy the boot files to the first partition
  4. Copy the boot splash to the first partition (message)
  5. Edit the menu.lst file on the first partition.

** Last leg ..... **

We now install the Grub bootloader to the MBR of the USB drive.

Open a terminal and su to root. At the root prompt (#) type:

grub <enter>

this should return the grub prompt like this:

grub>

At this prompt type:

grub> find /boot/grub/menu.lst

On my PC this returns

(hd0,0)

(hd2,0)

The first is my full install and the second is my USB stick.

Note: This is where it is prudent to be careful that you do not wipe valuable data. To ensure that you have identified the correct device from those returned by the find command, 'safely remove' the USB device and run the command again. Whichever device number is missing is your USB device. Plug it back in and run the command again to be sure you have correctly identified it.

*** Below I use the numbers returned in the find command. If you have different numbers then use those instead ***

Next, type:

grub> root (hd2,0) [be sure to change the numbers to suit your install]

and this returns

Filesystem type is fat, partition type 0x6

Next, type the setup command:

grub> setup (hd2) [this writes Grub to the MBR of (hd2) ]

and this returns the following:

Checking if "/boot/grub/stage1" exists... yes
Checking if "/boot/grub/stage2" exists... yes
Checking if "/boot/grub/fat_stage1_5" exists... yes
Running "embed /boot/grub/fat_stage1_5 (hd2)"... 15 sectors are embedded.
succeeded
Running "install /boot/grub/stage1 (hd2) (hd2)1+15 p (hd2,0)/boot/grub/stage2 /boot/grub/menu.lst"
succeeded
Done.

grub> halt <enter> [ closes the Grub command line. ]

We are finished!

Reboot your PC.

Edit your BIOS to make the USB drive the first boot device.
It is a good idea to have them in this order if they exist:

  1. Floppy
  2. USB
  3. CD ROM
  4. HDD

Once the BIOS boot order has been set you should be able to boot your USB drive.

There is of course no guarantee that this will boot on your hardware, so I will deal with a couple of possible problems.

If you fail to see the boot page then your installation of Grub is faulty. Go back and check that you did every step.

If Grub cannot find files then you need to check that you have entered all the details correctly. Where possible, I suggest that you copy/paste from this document to your own.

Some hardware setups will need specific boot codes. As these are specific to your hardware I have made no attempt to include them. You should be able to get an idea of which ones are needed from the boot codes in your present menu.lst file.

For those who like not to see the boot lines and who may also have special boot codes to get going, I recommend that the boot stanza be copied, the extra boot codes be added to the copy, and the Default=0 be changed to Default=1. That will select the second boot entry as the default.

The fun part about this is, this is the only time you will need to do this installation. Any time you wish to change the OS on the stick to a different PCLOS OS all that is required is that you delete the OS files from the larger partition and replace them with those from your new favourite PCLOS ....... be it Tiny, Flux, BEL, Gnome, or whichever. There is no need to change the contents on the first partition or to reinstall Grub. If you have a larger USB stick then you could put a remaster of your own install on the stick in the very same manner.

I tried the stick on a box that would not boot directly from the USB device, so I used a Smart Boot Manager floppy to call the stick.

Because the drive number of the stick was now not correct I had to make another entry ..... well, actually I temporarily edited the existing entry at the boot page.

First I went to the Grub command line from the boot page, and used the find command to find the menu.lst file again. This time I got results which indicated that the disc was being seen as (hd1) and not as (hd0) or (hd2), so I rebooted and edited the boot entry changing each instance of (hd0,0) with (hd1,0).

The USB stick then booted. I added a second entry to my grub menu.lst and called it Floppy, so now it will be available if required. As you use the drive you can make different boot stanzas to suit differing circumstances.

Please note that when using the floppy to boot the stick, the drive number the stick gets can vary from PC to PC dependent on hardware.

Here is something else for you to consider ....... the quickest method of using the stick to boot different releases.

I just set this up on my 1 GB USB stick.

What I did was to go into PCC - Mount Points and resized the second partition to about 300MBs or a little less. In the remaining space I created two more partitions; another of nearly 300 MBs and a third of about 370MBs. I formatted all three as Linux Native, making them primary partitions. Next I copied the MiniMe OS files to the last partition - the larger one - and the TinyMe and the TinyFlux OS files to the other two partitions. Lastly I edited the menu.lst file ----- below are the entries.

Timeout 10 color black/cyan yellow/cyan gfxmenu (hd0,0)/gfxboot/message default 0 title

Tiny Live kernel (hd0,1)/isolinux/vmlinuz fromusb bootfrom=/dev/sda2 vga=788 initrd (hd0,1)/isolinux/initrd.gz title

Flux Live kernel (hd0,2)/isolinux/vmlinuz fromusb bootfrom=/dev/sda3 vga=788 initrd (hd0,2)/isolinux/initrd.gz title

MiniMe Live kernel (hd0,3)/isolinux/vmlinuz fromusb bootfrom=/dev/sda4 vga=788 initrd (hd0,3)/isolinux/initrd.gz

The bootfrom boot codes are important to prevent the os versions from getting mixed up and failing to work. So now I have three OS versions on the one stick! Hehe, not much left is there?

Note: I should mention that the grub entries are for the device when plugged into a PC that allows USB booting.

I hope it works for you.
Have Fun.

pclinuxos

Top