To put a Live CD distro into a pen drive is very simple. I am using Slax as an example. The technique is generic. Also you can assemble several iso together in the same pen drive.
The key steps are
- Expand the iso by extracting the content into a temporary directory
- Create a /boot/grub directory and copy stage1 and stage2 into it
- Write a menu.lst for Grub (to substitute isolinux with Grub using information from isolinux.cfg)
- copy the temporary directory content into a pen drive
- setup up Grub in the MBR of pen drive
When you download Slax and extract it temporarily into a directory, say /home/pen_iso, you will find there are only two folders
/boot
/slax
Here I assume you have access to a Live CD like Ubuntu with which you can open a Slax iso file with "Archive Manager", highlight the two files and the click "extract" to /home/pen_iso.
Grub always searches /boot/grub for two files, stage1 and stage2, for booting. You will find these two files in Ubuntu Live CD /usr/lib/grub/i386-pc. If in doubt do a search by command.
Code:
sudo su
find / -name stage1
So create the necessary directories and copy the two file across.
Code:
mkdir /home/pen_iso/boot/grub
cp /usr/lib/grub/i386-pc/stage1 /home/pen_iso/boot/grub/
cp /usr/lib/grub/i386-pc/stage2 /home/pen_iso/boot/grub/
Now you shall use an editor to write a menu.lst and save it inside /home/pen_iso/boot/grub directory.
Code:
cd /home/pen_iso/boot/grub
gedit menu.lst
Writing a menu.lst sounds challenging but it is very easy for Slax, as shown below, because in a CD iso it is always booted by isolinux which has a configuration file /boot/isolinux/isolinux.cfg that you can copy. The content of Slax's isolinux.cfg is
Code:
PROMPT 0
TIMEOUT 200
DEFAULT /boot/vesamenu.c32
LABEL xconf
MENU LABEL Slax Graphics mode (KDE)
KERNEL /boot/vmlinuz
APPEND vga=769 initrd=/boot/initrd.gz ramdisk_size=6666 root=/dev/ram0 rw autoexec=xconf;kdm
LABEL pchanges
MENU LABEL Slax Graphics mode with Persistent Changes
KERNEL /boot/vmlinuz
APPEND vga=769 initrd=/boot/initrd.gz ramdisk_size=6666 root=/dev/ram0 rw changes=/slax/slaxsave.dat autoexec=xconf;kdm
LABEL copy2ram
MENU LABEL Slax Graphics mode, Copy To RAM
KERNEL /boot/vmlinuz
APPEND vga=769 initrd=/boot/initrd.gz ramdisk_size=6666 root=/dev/ram0 rw copy2ram autoexec=xconf;kdm
LABEL startx
MENU LABEL Slax Graphics VESA mode (1024x768)
KERNEL /boot/vmlinuz
APPEND vga=769 initrd=/boot/initrd.gz ramdisk_size=6666 root=/dev/ram0 rw autoexec=kdm
LABEL slax
MENU LABEL Slax Text mode
KERNEL /boot/vmlinuz
APPEND vga=normal initrd=/boot/initrd.gz ramdisk_size=6666 root=/dev/ram0 rw
LABEL memtest86
MENU LABEL Run Memtest utility
KERNEL /boot/mt86p
This bits that are of interest to you are marked in red.
You basically copy the red bits and slightly re-arrange them to suit Grub's syntax, as follow
Code:
title Slax Graphics mode (KDE)
kernel /boot/vmlinuz vga=769 ramdisk_size=6666 root=/dev/ram0 rw autoexec=xconf;kdm
initrd /boot/initrd.gz
You will note I have only changed the following
(1) I used the first line as the "title". The word "title" must be spelled correctly because it is a command.
(2) I combined the last two lines together and remove the word "APPEND".
(3) I changed the "KERNEL" to the lower case
(4) I moved the "initrd=/boot/initrd.gz " to a new line and replace the "=" with a space.
Now I plug in a pen drive which is usually preformatted in fat16 or fat32. No need to do anything as long as it has sufficent space to hold the the content of /home/pen_iso. Assuming the pen drive is detected as sdb1 I shall create a mount point /mnt/sdb1, mount the device on it and copy the two folders across.
Code:
mkdir /mnt/sdb1
mount /dev/sdb1 /mnt/sdb1
cp -r /home/pen_iso/* /mnt/sdb1
Lastly I invoke a Grub shell in Ubuntu, check the disk order and install Grub in the pen drive
Code:
grub
geometry (hd0)
geometry (hd1)
Since I am using an existing PC and so the internal hard disk, assuming there is only one, will be my first boot disk (hd0) and the pen drive should show up as the second drive (hd1), as Grub counts from zero. Having checked the capacity of the pen drive matches (hd1) I install Grub into the pen drive by commands
Code:
root (hd1,0)
setup (hd1)
quit
I then reboot, set the Bios to boot the USB pen drive as my first boot disk, enable the USB legacy support, save the Bios and Slax will appear in a Grub screen awaiting to be fired up.