Installing any Live Linux distribution onto a USB pendrive
Posted by Andy Fletcher, 0608230
Installing any Live Linux distribution onto a USB pendrive
Using syslinux, you can now install any Live Linux distribution onto a USB pendrive. This tutorial assumes that you have at least read and understood the Installing Slax Linux onto a USB pendrive tutorial, and have a basic understanding of the command line features of either Windows or Linux.
Some of the steps in this tutorial that were covered in the Installing Slax Linux onto a USB pendrive tutorial are only explained briefly in this tutorial, so if you become stuck, go back and read the Slax tutorial again.
Basic Essentials
- A Live Linux distribution of your choice (Knoppix recommended).
- A USB pendrive with sufficient capacity to store your OS.
- SYSLINUX.
- HP-USB Format Tool.
- WinRAR,WinZip or similar archiving tool (optional).
- Ubuntu Live Linux distribution, CD burner and software and blank CD/DVD (optional).
- Portable Apps (optional).
System Requirements
Please ensure that you sufficient hardware to support your chosen OS. Also ensure that your BIOS supports booting from USB mass storage device. You can view your systems specifications by clicking Start>Run and entering "DXDIAG" followed by "Enter". Refer to your motherboard handbook, or load the BIOS (see #6 of the Installing Slax Linux onto a USB pendrive tutorial for instructions) to check that it allows USB booting.
Tutorial
It is recommended that you read through this tutorial fully before attempting any of the steps. For this tutorial, i will be using the Knoppix Linux Live distribution. You may use whichever distribution suits your tastes and needs, however, before we begin, beware that when i booted Ubuntu from my pendrive, it was very slow and unstable. Plus, the notoriously slow initial boot time of Ubuntu renders it unsuitable for pendrive booting in this writers opinion, in which you may be switching between Linux and Windows on a regular basis. Knoppix, on the other hand, ran much more smoothly for me, and features persistent image and save state functions that allow you to easily save and load your settings and files each time you boot. Choose whichever distribution you wish to use first, and then if it doesn't run all that well, try another, and add your experiences to the Compatibility Thread below. Ubuntu may work much more sucessfully for you than it did for me, so don't be afraid to try new things.
Different sections of this tutorial can be completed in either Windows, or from the Ubuntu Live CD. Some sections are easier in Windows, and other in Linux, so if you get stuck, try loading Ubuntu carrying out the steps from there.
1. Ensure your pendrive has space to store your chosen OS, files and settings (100MB or so) plus any Windows files you may also want to store. Format your pendrive in FAT or FAT16. As usual, backup any important data, as it will be erased.
2. You can complete this step in either Windows or Linux-if you receive an error using Windows, then follow the steps for using Ubuntu. Ensure that you select your pendrive, and not your HDD(s)-to be extra safe, power down, remove any live cables (be safe), then earth yourself and unplug your HDD(s) and boot into Ubuntu, then theres no way of screwing them up. Don't forget to plug your HDD(s) back in. You don't need to carry out the steps twice, just once in your preffered OS:
Windows
Download the latest release of SYSLINUX and extract the contents to a folder named "syslinux" on the root of your C:\ drive. Hit Start>Run and enter "cmd" follwed by enter. The command prompt will open, displaying something like "C:\Documents and Settings\YOURNAME". enter "cd .." followed by enter a number of time until the command line reads "C:\". Type "cd syslinux" to jump to the syslinux folder. The command line should now read "C:\syslinux\". Enter "syslinux.exe X:" where X represents the drive letter of your pendrive. Make sure that you enter the correct drive letter, else you may screw up your Windows installation.
If this has been sucessful, carry on to the next step. If you have received an error message, ensure that you have selected the correct directory and that syslinux.exe is spelt correctly. Boot into Linux if you cannot get it to work.
Ubuntu Linux
Burn the Ubuntu Live Linux distribution to CD or DVD, and set your BIOS to boot from it. Using the Synaptic Package Manager (go to System>Administration>Synaptic package manager) install "mtools" and "syslinux". Then open a command prompt. type "sudo fdisk -l" to list the your drives. Your HDD's should show up as "hda" or similar, and your pendrive should appears as either "sda" or "sde". You can check by mounting and unmounting your pendrive through the command prompt and checking its status in the file browser. Mount or unmount the pendrive by entering "sudo umount /dev/YOURPENDRIVESNAME(e.g sda)" and "sudo mount /dev/YOURPENDRIVESNAME(e.g sda)". If your pendrive mounts and unmounts as you enter these commands, you can be sure that you have the correct device. Another method is to compare the size of your drives as displayed in the command prompt-your pendrive is probably considerably smaller than your HDD's.
Now, enter "cd ~" followed by enter and "sudo umount /dev/YOURPENDRIVESNAME(e.g sda)". This command will install the bootloader on your pendrive: "syslinux /dev/YOURPENDRIVESNAME(e.g sda)".
3. Shut down your OS and reboot. Set the boot priority to boot from USB-HDD or USB-ZIP. Your pendrive should be listed somewhere in the text that appears as your PC boots, and your pendrives status LED should flash (if it has one). If it doesnt, reboot and/or remove and re-insert until it does. You should see the following message: "SYSLINUX 3.11 2005-09-02 EBIOS Copyright (C) 1994-2005 H. Peter Anvin Could not find kernel image: linux boot:". Congratulations-you've just made your pendrive bootable! If not, check to make sure that the file "ldlinux.sys" is present in the root-if it isn't, then you've done something wrong-format, and try again.
4. Boot into either Ubuntu (from the Live CD) or Windows, your choice. Now comes the fun part. Copy all of the files from your chosen distribution into the root of your pendrive.
5. Open the ".boot" or "boot" folder on the pendrive and copy all of the files and folders up one level into the root of your pendrive. You can now delete the ".boot" or "boot" folder-all of its contents however should be in the root directory.
6. Rename "isolinux" to "syslinux", ensuring not to rename it to "syslinux.cfg"-it is already a .cfg file, so this will name it "syslinux.cfg.cfg", so just call it "syslinux".
7. Boot into Linux and open a root shell by clicking the penguin icon. Enter "passwd". Knoppix will then ask you to enter a password, followed by enter. It will then ask you to repeat this. Keep a note of the password that you have used-you might be asked for it later.
8. Open a root shell and enter "mount -o remount,rw /cdrom" followed by "mount --bind /cdrom /media/YOURPENDRIVESNAME(e.g sda)". This allows us to write data to the pendrive (remember, Linux still thinks that we are booting from CD, so up until now it wouldn't let us write any data to the pendrive).
9. We are now going to save a persisent home image-this saves all of the data in your home directory as an image, and mounts it on the next boot. From the penguin icon, follow the steps to create a persistent image, and save it on your pendrive. Be patient whilst the image is created, and don't touch anything-Knoppix crashed a couple of times whilst creating my image when i tried to do other things whilst i waited, so just sit tight for a few minutes. Then set up a save configuration file, again from the penguin menu, and set it to save on the pendrive. When you shut down, you will need to save your configuration if you wish to keep system changes (e.g installed programs, wallpapers etc...) but you won't have to follow the persistent image walkthrough each time, that takes care of itself automatically.
10. Finally, boot back into Ubuntu Live CD or Windows (Ubuntu is recommended as Windows doesn't display the syslinux.cfg file correctly) and open the syslinux.cfg file. Change the number "300" at the top to "50". This sets the wait time to 5 seconds at the Knoppix menu, meaning that the OS will boot itself automatically and you can go and make a cup of tea. Add the following to the end of line 2: "noswap noeject noprompt dma home=scan myconfig=scan". Here's a little explanation of what each option does, courtesy of the Knoppix Wiki:
noswap
Security fix: assuming you're going to be using the USB key on a bunch of different computers you don't own, you don't want to be swapping your memory onto their hard drives.
noeject
You can't physically eject a USB key.
noprompt
Gets rid of the "remove CD and close drive door" prompt when shutting down, as this prompt is rather misleading when it's really a USB key instead.
dma
Gets you a significant speed increase when dealing with many IDE drives, a good thing to have.
home=scan
This will cause Knoppix to pick up your persistent home directory automatically the next time you boot up, asking you for the password as needed. You will get an extra menu during bootup, asking you if you want to mount your home directory or not.
myconfig=scan
This will cause Knoppix to pick up your configuration file automatically the next time you boot up.
Now when you boot, Knoppix will ask you what you want to do with the home image that its found-select the first option, and hit OK-if you don't select an option, the prompt will time out after thirty seconds, and no option will be selected.
11. Optional - You can still use your pendrive as normal in Windows, but its a bit ugly with all those Linux files everywhere. Installing Portable Apps allows you to work within Windows in a clean, sophisticated manner, thanks to a plethora of freeware utilities and its smart UI. When installing Portable Apps, it usually complains about overwriting Knoppix's Autorun.inf file-this is perfectly OK. You can just about squeeze Knoppix and Portable Apps onto a 1GB pendrive.
Troubleshooting
Q. Help, i can't boot into Linux!
A. First, try removing all other USB devices-sometimes they can interrupt the boot process and cause problems. Also, ensure that you completed the tutorial exactly as described in the above steps. If you formatted in FAT32, try formatting in FAT or vice-versa. Try another USB port (the frontal USB ports often don't allow booting), or failing that another pendrive, or a friends machine. Ensure that you have set the BIOS to boot from USB-HDD, and failing this, try booting with the boot priority set to boot from USB-ZIP, or similar.
Q. Can this damage any of my files on my PC?
A. Its highly unlikely, so long as you only run Makeboot.exe from your pendrive and not your HDD(s). It's still always a good idea to backup any data however before attempting this tutorial. Bear in mind though that messing with the BIOS, other Linux distributions, and generally doing things you don't understand will probably result in you messing something up, so don't push buttons if you don't know what they do.
Q. Im tired of Linux, how do i get my pendrive back to how it was?
A. Load up the HP USB Format Tool and format the drive as before, ensuring that you select the correct drive from the drop down menu.
Q. The HP USB Format Tool gives me an error!
A. This is a common problem; under Windows XP, open the "Control Panel", make sure you are in "Classic View" and click "Administrative Tools" followed by "Computer Management". Select "Disk Managment" from the menu on the left, and delete any partitions on the drive, making sure that you have selected your pendrive and not your HDD(s) by mistake, then format it in either FAT or FAT32. It is then recommended that you format again using the HP Format Tool, for compatibility reasons. Failing this, try formatting the drive using the above methods on a different machine, or use a different pendrive.
Q. Can i use a USB-HDD?
A. Compatibility with USB-HDD's is not guaranteed. I couldn't get a single distro to boot using my Hitachi HDD in a USB caddy. Try it, and add your findings to the Wiki.
Q. I love Linux, where can i find out more?
A. Check out pendrivelinux.com for more Linux distributions that run from USB pendrives.
Q. I really love Linux, can i install it to my hard drive?
A. Yes! But this may involve formatting your Windows HDD. It is possible to install most Linux distributions alongside Windows, but you risk destroying your data doing this if anything goes wrong. Before undertaking any OS installation, always backup any important data, and if possible make a complete copy of your HDD using Norton Ghost or similar.
Q. Can i still read from/write to my Windows disks whilst running Linux?
A. Yes and no. If your partitions are formatted in NTFS (which if you are running XP then they probably are) then you can only read from them, if they are formatted in FAT then you can read and write to them. There is no way to change the filesystem from NTFS so FAT without formatting the drive. You can browse your Windows drives whilst running Linux through the "Konqueror" browser.
Q. Should i make backups of my files?
A. Absolutely! If your pendrive becomes unreadable, or physically broken or damaged, recovery of data will be difficult. Always keep a recent backup of your files on at least one other storage device.
Q. Can i still browse my local area network/surf the net?
A. Yes! Linux will automatically set up filesharing and internet acess. To access your networked files, open "Konqueror">"Network Folders">"Samba Shares" in Linux. Your shared folders on your Windows HDD will not be available from another machine while you are running Linux, however.
Q. Can i load Linux on another machine?
A. Yes, just insert the pendrive into a USB port, configure the BIOS and boot as usual.
Q. I can't get back into Windows-HELP!
A. Calm down, it's pretty much impossible to screw anything up using this tutorial, so long as you install syslinux to your pendrive and not your HDD(s) you'll be fine. Remove the pendrive, and check that you have reset the boot priority in the BIOS to boot from the HDD (usually set it to "HDD-0"). Are there any floppy disks or CD's inserted? If so remove them. If all else fails, seek help from somebody in the know, or key your exact problem into Google.
Q. I still can't get this to work/You haven't answered my questions-HELP!
A. Whats your problem? Somebody somewhere will have already experienced it and probably solved it whatever it is, so enter it into Google Groups, ask friends, try another distro, or email a lecturer, or myself - (Andrew Fletcher).
If you have experienced problems and have overcome them, please add your experiences to the Wiki to help others.
Credits
All props go to those out there who figured this out before me, the guys and girls behind Ubuntu, Knoppix, SYSLINUX, and pendrivelinux.com.
Disclaimer
I take no credit whatsoever for any of the files or methods used here. I will not take any responsibility for any damage dealt to your computer, your pendrive, yourself or others around you when follwing this tutorial. You follow this tutorial entirely at your own risk, and by installing and running Linux, you agree to this.
Compatibility
Distribution | Stability (A, B, C) | Minimum Size Pendrive Required | Persistent Home Directory | Save Configuration | KDE or Gnome |
---|---|---|---|---|---|
Slax Linux | A | 256MB | Yes, but not working yet | Unknown | KDE |
KNOPPIX_V5.0.1CD-2006-06-01-EN | A | 1GB | Yes | Yes | KDE |
Ubuntu 6.10 | B | 1GB | Unknown | Unknown | Gnome (see Kubuntu for KDE) |
Stability Key - A=Stable and running smoothly, B=Runs, but with errors or slowdown, C=Unusable
"Minimum Size Pendrive Required" - is a minimum capacity for loading and running the OS-a larger capacity pendrive maybe necessary for saving files and settings.