usb keyfob

October 11th, 2007 Leave a comment Go to comments
This page is now out of date. Since this was written i've successfully installed WinPE 2.0 (Vista WinPE) + DSL + Hiren's on my keyfob - see the post here for how to do this. Did you get the "cursor blinking" problem when you tried to install Hiren's BootCD? I may have found the problem! Reinstall your fob with my new instructions and you may find it works! woot, german version up! Many thanks to Christian Heck for his hard work. There should be a french version coming one day soon... USB KEYFOB TUTORIAL VERSION: 2.0 Last Updated: Oct. 30 '05 - COMPLETELY REWROTE DOCUMENT, as many people were getting errors and when I had to reinstall my keyfob, I got the same ones. Should be better now! For the old version of this document, click here: If you find this page useful, please send me an email with feedback or just saying it worked for you! Email address found on left navbar at bottom. If you really REALLY find it useful, you could donate this needy student (me) some cash using PayPal (safe and secure) to put toward my next term's textbooks or whatever :)

Section 1: IntroDISCLAIMER I am in no way responsible if something goes "wrong"; if your keyfob becomes unusable, your toaster stops working, you suffer massive dataloss across multiple machines -- not my problem. You absolve me of any liability for anything that happens to your keyfob or computer(s) by following one or more of my instructions. I am not responsible for what is found at the end of my hyper-links (links): efforts have been made to ensure they don't contain offensive or illegal material, but if they do it is your responsibility to not accept the content. I host no illegal files on server(s) that I partly or wholly own, don't ask me for them. REQUIREMENTS
  • patience
  • a USB keyfob (flash drive, keydrive, whatever you wanna call it) that you can totally erase (BACKUP your stuff now!)
  • a computer that can boot off your USB keyfob (only newish computers can! see section about this below if you're not sure)
  • Free space on the keyfob (if you want multiple sections, ADD the required space as there are very few bytes shared between them):
    • For DSL (section 1), ~55MB free (if you want embedded too then add ~60MB = ~120MB)
    • For Hiren's BootCD (section 2), ~37MB free
    • For Debian-Sarge installer with "netinst" ISO (section 3), ~112MB free (note that this depends heavily on how big the netinst ISO is when you download it! Check how big the newest version is if you're unsure and you're contemplating this option)
Procedures in this document will erase your keyfob so back it up first! PURPOSE / HOW TO USE THIS DOCUMENT So what's the purpose of this document? The purpose is to make your keyfob more useful. There are many uses for keyfobs, primarily storing files that you wish to have with you at any time, like addresses or contact info, lists of your favourite websites, and so on. One really useful thing is to be able to boot from your keyfob into any kind of operating system you wish, for any purpose you desire. Booting refers to "boot-strapping" your computer, which for you newbies kinda means "what happens when you start up your computer". For instance, the majority of you readers will be booting into Microsoft Windows when you turn on your computer; booting from your USB keyfob would allow you to boot something else, say Linux, without touching/erasing/modifying your Windows installation. GETTING YOUR COMPUTER TO BOOT FROM A USB KEYFOB Since the vast majority of this document is about getting your USB keyfob to boot, it's important that you can actually DO this :) To be more specific, the motherboard inside your computer needs to have a BIOS that supports booting from USB keyfobs. What BIOS is and how it works is way beyond the scope of this page, all you need to know is that it's the thing you get into right when your computer is first powered-on, by punching a key (usually "Delete", F1, or some other F key like F12 etc). If you know you can boot USB keyfobs, you can stop reading this paragraph and skip ahead. Otherwise, we need to determine whether you can -- only "newer" computers have this ability. For instance my ASUS A7N8X-Deluxe motherboard cannot, but my IBM ThinkPad T41 (notebook) can, and so can my wife's computer. This part of this document will evolve over time, and is fairly scant right now, but let's do what we can. If any one of these methods below works, you're done, you can boot from your USB keyfob. Remember to have your USB keyfob plugged in before trying these things, it usually helps as the BIOS may give you more options with it plugged in. Also remember that at this point your keyfob probably isn't bootable, so you can't actually try it out until you've run through the steps in this document.
  • See if your BIOS has a "boot selector" on bootup that doesn't even require you to enter the BIOS to change anything. On my IBM ThinkPad T41 I can press F12 when it initially powers on, and it'll pop up a list of devices I can boot from (I just select USB FLASH HDD and i'm done). On my wife's computer she hits F8 when it powers on, and she gets a similar menu to choose from. See if you have something like this (look for "boot menu" or something in your motherboard's manual or whatever).
  • Try entering BIOS and telling the computer to try booting from your USB keyfob first. To enter BIOS, try hitting "Delete" (sometimes marked "Del", on the keyboard directly to the left of the "End" button if you have a standard english keyboard) or "F1"; consult your motherboard manual if you can't figure out how. Now, you're looking for an area where you set the boot device order (like first try floppy, then try CDROM, then try hard-drive aka HDD). Sometimes you'll find a single row in some advanced page of the BIOS where you change an option like "A/C/SCSI" to "A/USB-HDD/C" or something like that, other BIOS' will have an entire page devoted to the task. My mobo (A7N8X-Deluxe) has a page where you hit + or - on the numpad to move things up or down (things at the top get tried first), and you hit enter to change devices in the categories. What you are looking to do here is to make sure that your USB keyfob gets booted from before your hard-drive (HDD) does. Your USB keyfob may be called one or more of many things: USB, USB-HDD, USB-FDD, USB-ZIP, USB-FLASH, etc. Sometimes some BIOSes will work with USB-FDD whereas others will only work with USB-HDD, you'll have to experiment (doing so does NOT harm the computer in any way; if you get a failure you'll just see "SYSTEM COULD NOT FIND BOOT DEVICE" or something similar, and you then power off your computer, get back into BIOS, and try something else). Before you change the boot device option, remember what it was before! Write it down so you don't forget - you'll need to reset things back to the way they were if you don't want to be able to boot from USB. After you've changed the option to what you want to try, you'll need to exit and save your changes. Usually there's an option that does this - just hitting "ESC" repeatedly exits without saving, bad.
I've received an email from Roger Ligustrom, who has an ASUS M5N laptop and couldn't get it to boot from USB. It turns out his laptop was finding the USB keyfob and labelling it as a normal hard-drive in BIOS. He suggests exploring the lists of hard-drives your BIOS shows (if it lists things this way) and making sure your USB keyfob isn't chucked in there. If it is, you'll see the brand-name of your keyfob (ie. if you have a Mini-Cruzer made by SanDisk you might see "SanDisk Cruzer Mini" or something like that) WHAT TO DO IF YOU DON'T HAVE/USE WINDOWS A very few readers have expressed frustration that this tutorial is written primarily for Windows users. There's a good reason for this: with no offense meant, Windows users are generally less informed than Linux users are, and have more difficulty with the process. That's why these instructions are written for people using Windows (who want to try Linux out by booting from a keyfob and not reinstalling their main O/S). That being said, it is very easy to apply these instructions to Linux. Here are some suggestions.
  • The good news is, unless you have done something odd or have trashed your 'fob, most likely you'll already have an MBR on your 'fob from when you bought it that works fine. So, you may well be able to skip part A. If you get to the end and things don't work (syslinux never comes up when booting from the fob) then you'll have to investigate further. I've noticed that syslinux says it includes a basic MBR in the normal syslinux download, and Xavier Bassery writes,Here is an excerpt of a nice howto on the subject http://darkdust.net/marc/diskimagehowto.php : 5. Install master boot record (found in SYSLINUX source directory). $ dd if=mbr.bin of=/dev/sda
  • you can run the Linux version of syslinux, which works perfectly. I remember having to use one of the options when I ran syslinux in Linux, like -s or some other cmd-line option. Anyone who figures this out, email me.
  • you should be able to follow the fdisk instructions with no problems, from your own installation of Linux.
  • you can mount the DSL ISO without using the Windows Daemon-Tools program; simply mount the file as a loop-device: mount -o loop /path/to/DSL.iso /place/to/mount - you may need to specify -t iso9660 or something close to that if your kernel/distro didn't autodetect the filesystem type.
  • Getting Hiren's BootCD installed to your 'fob in Linux should be exactly the same as doing it in Windows, just make sure you download and use all the modified scripts/files that i've prepared for you (as opposed to trying to do it yourself)
  • Getting Debian's Installer installed to your 'fob in Linux, again, should be exactly the same as doing it in Windows.
MAKE HIDDEN/SYSTEM FILES VISIBLE IN WINDOWS You must be able to see files like io.sys and jo.sys, which are both "hidden" and "system" files. If you're doing this in windows as I suggest, by default windows will hide these files from you. To enable hidden/system file viewing, in windows explorer do the following (instructions are for Win 2K/XP but will be close for 95/98/ME; STFW if these don't work for you):
  • In windows explorer go to the tools menu
  • Hit Folder Options
  • Go to the View tab
  • Disable the "Display simple folder view in Explorer's Folders list" checkbox
  • Enable the "Display the contents of system folders" checkbox
  • Choose the "Show hidden files and folders" radio button
  • Disable the "Hide extensions for known file types" checkbox
  • Disable the "Hide protected operating system files (Recommended)" checkbox, and click "Yes" on the ridiculously annoying confirmation prompt that pops up
  • Hit OK
DSL VERSIONS - important information, read carefully! As of DSL version 0.9.2 there seem to be a few different "versions" of DSL. For my instructions to work you must grab the "normal" version, ie. named dsl-x.x.x.iso, not a version that contains the word syslinux or anything like that (even though we are using syslinux to complete the installation). The reason for this is because the syslinux version doesn't contain the boot directory, so it's missing a whole bunch of files we use. Embedded version: As of DSL version 1.0rc1 there is an "embedded" version, which is quite a cool thing: it allows you to run DSL inside windows, without having to reboot! It does this by using QEMU, an open-source program that translates calls at the CPU level from Linux to Windows. The upshot of which is you get Linux running inside a window -- not like Cygwin which is a bunch of programs that look like Linux but are really specially compiled versions to run on Windows. I've taken a snapshot for you, here. Doing this requires NO EXTRA WORK, as the kind folks at DSL have done it all for you! (Please consider donating to them) To install the embedded version, proceed as normal at first - download the "normal" version as mentioned above (because the embedded distribution doesn't have the needed boot directory), and complete section 1 entirely. Then download the newest embedded version (.zip file), and copy over the QEMU subdirectory and dsl-linux.sh and dsl-windows.bat files, all to the keyfob root directory. Try double-clicking the dsl-windows.bat file, it should start up for you! Note that this requires an extra ~60MB for the QEMU/harddisk file. Also note that you can still boot off your fob to natively start DSL, which is faster than using QEMU to run it under Windows (by a factor of 5-10 times).
Section 2: Install DSL and Hiren's BootCD At this point you should be booted into Windows with your keyfob inserted. We're gonna install the following things on your keyfob (you can skip any of them you wish to):
  • DSL (Damn Small Linux, made from Knoppix, which in turn is made from Debian Linux)
  • Hiren's BootCD (Lots of handy windows utils)
  • Debian Net Installer (Allows installing Debian on machines via the net)
Download these things first
  • Hiren's BootCD. Since Hiren's BootCD contains muchos illegal software, I can't post it on my site. However, I can link you to somewhere where you might find it with Shareaza or your favourite P2P client: eDonkey2k URI and magnet URI. You can find out information about what the CD contains on Hiren's weird homepage, here. Don't ask me to give you Hiren's BootCD, IT IS ILLEGAL TO DOWNLOAD IN MANY COUNTRIES INCLUDING AMERICA, so of course i've only ever downloaded it while I was in countries that permitted it.
  • bootessentials.zip, and expand it to a new directory on your HD (not on your keyfob). These are the files that'll handle the DOS-side of your keyfob being bootable.
  • DSL (Damn Small Linux), being sure you get the right version (see blurb above!)
  • Daemon Tools
  • HP format util (MANDATORY for this tutorial!). I've received an email from Dan who had a bad time with the HP tool. It worked fine for me, but you should be aware of what happened to him:
      I loaded it, pointed it to my attached fob, and clicked format. It jumped drive letters to an attached drive and wiped out the fat tables in an instant. I believe it automatically jumps to whatever is the first USB device drive letter. I was able to restore the data thanks to a powerful utility I keep on hand for such disasters, but others might not be so lucky. I'm don't blame you for this happening one bit. I just suggest you add a warning to your instructions to have no other usb attached storage devices other than the fob for this step.
  1. Install the HP program and take Dan's advice to heart by removing all attached USB devices that have storage other than what we're formatting.
  2. Start the program:
    • for "Device" choose your keyfob
    • for "Filesytem" select FAT (not fat32!)
    • for label put dadskeyfob or something
    • quick-format should be off
    • Create a DOS startup disk should be checked. Radio button should be "use DOS system files located at", and the directory should be set to where you extracted the bootessentials.zip file that you expanded in step 1.
  3. Hit start. One nice thing it's doing is rebuilding your MBR properly for your keyfob, as well as formatting and copying.
  4. Download Hiren's BootCD's bootable files from me, here. Note that this probably requires you to have the same version of Hiren's BootCD I have, version 6. Extract them to the root of your keyfob, saying NO to overwrites.
  5. Delete jo.sys (not io.sys!) from the root of your keyfob
  6. Grab SYSLINUX, from here. You can use the newest version - the version I used with success on 10/30/05 was syslinux-3.11.zip. Expand the zip file to a directory on your HD (not keyfob), and open up a command-prompt to wherever you expanded it.
  7. Go to the subdir "win32" and type the following carefully with your keyfob plugged in, where X represents the drive letter you can see your keyfob as in Windows explorer: syslinux.exe X:   Verify that you now have "ldlinux.sys" on your keyfob! You may need to turn on hidden/system/OS file-viewing to see this. Read further down, instructions on how to do this in Windows XP can be found further on in this document.
  8. Put the following dos boot-sector file onto your keyfob (in the root directory): dos.bss
  9. Grab the parts of Hiren's BootCD that I modified to make work on bootable USB keyfobs from here. Now, extract all the files and put them on the root of your keyfob drive, saying YES to overwrites.
  10. Hopefully by now DSL has finished downloading. Put it somewhere, should have an .ISO file around 50mb.
  11. Hopefully by now Daemon Tools has finished downloading. Extract it somewhere, and install it. By default it will add just one virtual drive to your computer
  12. Right-click the red lightning-bolt in your systray (it's Daemon Tools silly), and mount the DSL .ISO file by going "Virtual CD/DVD-ROM", "Device 0...", "Mount Image", select the DSL .ISO file
  13. Go to the drive you've just mounted (might be like F: -- you can tell which it is from Daemon Tools, the one BEFORE you clicked "Mount Image"), this represents all of the stuff on the DSL .ISO file
  14. Copy everything there to your keyfob drive (can ignore lost+found dir if you want).
  15. In windows explorer, go to your keyfob drive, go into boot\isolinux, and MOVE everything up to the root of the drive. Delete the empty boot\ directory (yes, deletes empty isolinux dir too) that you've just moved everything out of
  16. On the root of the keyfob, delete isolinux.bin, and rename isolinux.cfg to syslinux.cfg
  17. Go to wherever you put Hiren's BootCD, and find the directory called BootCD and copy it to your keyfob (so if your keyfob is G: you now have G:\BootCD
That's it! You should now (hopefully) be able to boot into Hiren's BootCD by typing dos at the syslinux prompt, and DSL by hitting enter. When booting Hiren's, hit Esc when the windows bootup screen is showing to see what's happening behind the scenes. When you boot Hiren's CD you should see Hiren's nice little menu; after you select a choice, there will be a grinding pause as my modifications attempt to figure out WHERE your BIOS has put the boot-device; it better be either A:\ (what Hiren originally expected) or C:\ (where my keyfob gets placed by the BIOS of my IBM ThinkPad T41). If it is C:\, you'll get an error as my script tries to look on A:\ and doesn't find what it wants. Hit 'a' for abort or 'f' for fail until the error goes away; this is ok, it's just figuring out where stuff is. If Hiren's Boot CD starts to boot but doesn't work, the most likely your BIOS is placing your keyfob as something other than A: or C:, in which case you should modify the very top of autoexec.bat (my modified version, not Hiren's original!) -- it should be obvious what to do. Experts should note that i'm not loading any USB/ASPI drivers, i'm presuming after booting your BIOS has made the whole drive accessible (not just the first 1.44mb or something weird!); if that's what you find is happening to you, tough luck, I have no idea how to fix that (try loading some USB/ASPI drivers in autoexec.bat?).
Section 3: Add Debian Sarge installer to your keyfobThese instructions will guide you through putting the additional files you need on your keyfob to make the Debian Installer able to install straight from it to a given computer. The amount of space this takes varies; the skeleton setup without the ISO (payload) will take only ~10mb or so, but the ISOs vary in size from ~40mb (business card iso) to ~110mb (net install iso) and even higher. The choice is yours ! I keep the net install iso (netinst) on my fob, because that's the most useful one. Also, these instructions aren't the "easy" variety where everything's done for you, they outline all the steps you need to grab the latest version, do the changes yourself, and get it on your fob. The reason for this is because Debian is fantastic, and they're always coming out with new versions of the installer and the ISOs themselves. For that reason it'd be silly to just give you some pre-made .gz files because they'd be out of date very quickly.
  1. Download all the files in the directory here: (link goes to Canadian mirror, use your favourite if you like; this is the kernel ver. 2.6 which now works with USB installs): http://mirror.direct.ca/linux/debian/dists/stable/main/installer-i386/current/images/hd-media/2.6/
  2. Rename initrd.gz to initrd26.gz
  3. Rename vmlinuz to sarge26
  4. Copy all of these files onto the root directory of your keyfob
  5. Download one Debian ISO image. I recommend the "netinst" (net install) image. The general page of all available netinst ISOs can be found here, and you likely want the i386 netinst CD image. Put it on the root of your keyfob.
  6. Open up syslinux.cfg that's already on your keyfob, from section 1 (putting DSL on your keyfob) in an editor, like notepad, and add the following lines to the bottom.
    • Note that this relies on the ramdisk size not having changed since I updated this page! At the time of writing Sarge has just been officially released, and the filesize of initrd26.gz is 3,205,673 bytes. If your initrd26.gz is a different size, you'll need to copy these lines but get the right ramdisk_size from the syslinux.cfg that comes in the boot-image. To find this use the link above, go to the parent directory, download boot.img.gz, expand and extract it, and take a look at the similar lines in the syslinux.cfg it contains. If you don't already have a syslinux.cfg on your keyfob because you didn't install DSL already, you could use this syslinux.cfg verbatim.
     label sarge 
     	kernel sarge26 
     	append vga=normal initrd=initrd26.gz ramdisk_size=10396 root=/dev/rd/0 devfs=mount,dall rw  -- 
     label sarge1024x768 
     	kernel sarge26 
     	append vga=791 initrd=initrd26.gz ramdisk_size=10396 root=/dev/rd/0 devfs=mount,dall rw  -- 
     label sarge1280x1024 
     	kernel sarge26 
     	append vga=794 initrd=initrd26.gz ramdisk_size=10396 root=/dev/rd/0 devfs=mount,dall rw  --
That should be it ! Now you should be able to boot off your keyfob, still type "dsl" or "dos" for DSL and Hiren's BootCD respectively, but also you should now be able to type "sarge" and the Debian installer should start up!

*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Anti-spam image