Installing to a USB Flash Drive Old

From DSL Wiki

   This page in other languages: Español, 中文版 (chinese)

Contents

Introduction

It's very common to install DSL to a USB Flash Drive for booting from a USB port. (It's cool to carry your whole OS in your pocket).

A USB Flash Drive is not the same as a USB Hard Drive. Installing to an external USB Hard Drive does work, but some external enclosure hardware won't like being used as a boot source. Expect your mileage to vary.

Requirements

If you're going to install to a USB drive, you'll need:

  • A USB drive of 128 MB or larger. 512 MB is preferable, 64 MB will work in a pinch.
  • A working operating system & internet connection (which you probably have if you're reading this...)

And you're probably going to wipe your USB Drive, so BACK UP YOUR DATA. Enough said.

Tutorials

There are actually lots of how-tos/walkthroughs for installing DSL to a USB Flash Drive. All those tutorials are filed according to the source operating system. Basically, pick the tutorial for your current operating system. You'll probably be installing DSL:

  • From within DSL
  • From within another Linux distribution
  • From within Windows
  • From within Mac OS (tutorial/documentation still needed as of ~~)

If you have figured out another way of installing DSL to a stick, add your knowledge where you see fit.

Common Post-Install Questions

  • Why is it that DSL installed to USB won't finish booting after conversion from .iso?

It appears that the KNOPPIX file is hard-wired to seek for CD-ROM and not USB drive. Use the embedded iso instead.

  • Why does the from-within-Linux method require FAT16, but the Windows method work with FAT32? Could I just leave and reuse an existing FAT32 USB partition using the Linux syslinux version?

Either method should work, but some users have found FAT works more reliably than FAT32. Although the current version of Syslinux should work with FAT32 (3.35+), that was not always the case. If you're using an old version of Syslinux, make sure it supports FAT32.

  • Why don't my keyboard and/or usb mouse work when I enter X windows?

Could be a BIOS problem. Try to enable 'USB device emulation' or 'legacy USB' in your BIOS setup.


From within DSL

The current DSL Live CD ISO includes a script which automates installation to a USB drive. It's way easy and reliable:

  1. Open the Main Menu, go to Apps->Tools
  2. Choose USBZIP or USBHDD install
  3. Follow the prompts

See the page USB Booting for more information.

From within Linux

The basic process for installing DSL from within another Linux distro is:

  1. Reformat/repartition your stick (or just clear it off)
  2. Put the current DSL ISO contents onto the stick
  3. Set the boot flag, put in a boot loader (GRUB or LILO)
  4. Set up the bootloader

To install from Linux, you'll need to know your flash drive location (device node). It will be something like /dev/sda. One way to find out is to open a terminal and run:

       fdisk -l

You may have to use sudo ... but be careful. fdisk is a great tool for mass destruction of your data.

Upgrade Syslinux

Check your syslinux version and upgrade it if you want FAT32 support. (Syslinux 2.11 works for FAT16; Syslinux 3.35 works for FAT32) Compile & install the latest syslinux from kernel.org (in the EU go here).

Optional: Replacing MBR

If you need to wipe the MBR on the Flash Disk, do it with a command like below. This shouldn't be necessary unless there's another funky bootloader in the MBR (like, if you were experimenting with another bootable USB linux distro). BE *VERY* CAREFUL NOT TO WIPE YOUR HARD DRIVE'S MBR HERE!!! Replace sdX with the path to your USB drive

   dd if=/dev/zero of=/dev/sdX bs=446 count=1
Here are two ways to replace MBR
Using 'mbr.bin' from Syslinux:
   locate mbr.bin
   cat /somepath/share/syslinux/mbr.bin > /dev/sdX
Using ms-sys:
Install http://ms-sys.sourceforge.net/ and put another MBR in its place:
   ms-sys -s /dev/sdX

Formatting Flash Drive

Run fdisk on /dev/sdX, so it looks like this:

    Device Boot      Start         End      Blocks   Id  System
 /dev/sdX1   *           1        1021      253177    b  W95 FAT32

Use d to delete existing partitions until none remain. Use n,p,1 to create a new primary partition. Use a to make it bootable. Use t,b to make it W95 FAT32. Don't forget to hit 'a' to make it bootable!

Use w to save the changes and exit

Create a FAT16 or FAT32 partition on the pendrive: ("-F 32" will create a FAT32 partition; "-F 16" will make a FAT16 one)

 mkfs.vfat -F 32 /dev/sdX1

Installing DSL

  • Download the dsl-embedded zipfile
  • Mount the pendrive & unzip the dsl-embedded.zip file onto this.
  • Unmount the pendrive
  • Next use syslinux to make it bootable.
 syslinux -s /dev/sdX1
  • You can now boot via QEMU (from within Linux or windows), OR as native from the USB drive.
  • You can also run DSL from a GRUB bootloader menu on your USB key (see below). This is very useful if you're using DSL as part of a data/system rescue toolkit, as you can include multiple preset configurations of DSL as well as other utilities.

Note: syslinux needs the package "mcopy" included in the package "mtools".

Note: Unfortunately, this method does NOT give a 50MB Linux Distribution because qemu dir and method is (comparatively) big. You will end up with a 110MB distribution.

Note: The iocharset=utf8 option when mounting the USB stick may result in the "KNOPPIX/KNOPPIX" not being found upon booting.

Alternative I: Using GRUB as boot loader

Note: This method has been reported not to work under certain conditions

  • Download the current ".iso" dsl-cd image.
  • Create an ext2 partition (=> 51MB) on pendrive. Mount it.
   mke2fs -v -L "DSL" /dev/<device>
   mkdir -p /tmp/pendrive
   mount /dev/<device> /tmp/pendrive/

where <device> is the corresponding file which represents your USB storage device/partition.

Note: ext3 is ok too.

  • Change to the directory where you mounted the ext2 partition, install GRUB boot loader:
   cd /tmp/pendrive/
   grub-install  --no-floppy  --root-directory=.   /dev/<device>  

Note: Replace <device> with the corresponding file which represents your USB storage device/partition. For example /dev/sdc1

Note 2: This method did not work for me, I used the manual method of running grub and entered "root (hd1,1)" and "setup (hd1)" (your paths will probably vary).

  • Copy the contents of the cd image to the usb drive.
   mkdir /tmp/dsl-cd
   mount [/path_to/]current.iso /tmp/dsl-cd/ -o loop
   cp -vR /tmp/dsl-cd/* /tmp/pendrive/
  • While in the same directory - where you mounted the ext2 filesystem - create a menu.lst file for grub in the directory ./boot/grub/menu.lst
  cat > /tmp/pendrive/boot/grub/menu.lst << EOF
  title           Damn Small Linux
  root            (hd0,0)
  kernel          /boot/isolinux/linux24 root=/dev/sda1 ro lang=us toram noeject frugal
  initrd          /boot/isolinux/minirt24.gz
  boot
  EOF

Note: You might have to change (hd0,0) to the correct partition for your USB drive. However, the default should work on most systems.

  • Unmount the filesystem.
  • You can now boot from your USB storage device.

Alternative II: Using GRUB as boot loader

Someone found the above process doesn't work and has documented for others this working process


The Situation:

  • Running SLED 10 (Suse)
  • The USB key is a 1GB and appears as /dev/sda
  • Logged in as root
  • The DSL ISO is downloaded to /root/Desktop/dsl-3.3.iso
  • Two partitions, the first to use as general USB storage, the second for DSL
  • The DSL partition wanted to be ext3 so that Windows doesn't mess it up
  • The first partition needs to be the big storage one as Windows doesn't like addressing the second partition on flash drives


The procedure:

  • fdisk /dev/sda
    • d - Delete all partitions on the key
    • n - Make a partition
      • p - Primary partition for general storage
      • 1 - First partition
      • 1 - From the first block
      • 948 - Most of the space, about 933MB
    • n - Make a partition
      • p - Primary partition for DSL
      • 2 - Second partition
      • 949 - Start from the next available sector
      • 1012 - To the end of the disk. I give it 64MB
    • a - Make the partition bootable
      • 2 - Mark the DSL partition bootable
    • t - Change the partition type
      • 1 - Change partition 1
      • b - Change it to Win95 FAT32
    • w - Write the changes
  • fdisk -l - Gives the following output:
        Device    Boot      Start         End      Blocks   Id  System
	/dev/sda1               1         948      954131+   b  W95 FAT32
	/dev/sda2   *         949        1012       64416   83  Linux

Your flash drive should now look like this

  • mkdir /mnt/iso
  • mkdir /mnt/usb
  • mount -o loop /root/Desktop/dsl-3.3.iso /mnt/iso
  • mkfs.vfat -F 32 /dev/sda1 # use -F 16 for FAT16
  • mke2fs /dev/sda2

Note: If you want to have an ext3 filesystem, add the -j flag: mke2fs -j /dev/sda2

  • mount /dev/sda2 /mnt/usb/
  • cd /mnt/iso
  • tar cvp . | (cd /mnt/usb; tar xp )
  • mkdir -p /mnt/usb/boot/grub
  • cp /boot/grub/*stage* /mnt/usb/boot/grub/
  • cat > /mnt/usb/boot/grub/menu.lst << EOF
   title Damn Small Linux
   root (hd0,1)
   kernel /boot/isolinux/linux24 root=/dev/sda2 ro lang=us toram noeject frugal
   initrd /boot/isolinux/minirt24.gz
   boot
   EOF
  • cd /mnt/usb/
  • grub-install --no-floppy --root-directory=. /dev/sda
  • cd /root
  • umount /mnt/usb
  • umount /mnt/iso
  • rm -r /mnt/iso
  • rm -r /mnt/usb

From within Windows

Note: This guide assumes that your USB Flash Drive is "F:". Please replace "F" with the correct drive letter.

There are two methods. For either method, you will need:

Method I

  1. Format your flash drive, from cmd.exe (the "DOS" window) type:
    FORMAT F: /fs:FAT32
  2. Unzip "dsl-embedded.zip" to your flash drive (you could use the "Extract all files" built into XP with the destination as "F:\")
  3. Download "syslinux-3.63.zip" from Syslinux - Syslinux can also be used by various other platforms, such as Unix.
  4. Go to a command prompt and run syslinux for your drive from \win32\syslinux.exe typing:SYSLINUX -ma F:
  5. If you are running Windows Vista, remember to start cmd.exe as Administrator, otherwise the normal cmd.exe won't be able to access the MBR of your USB drive.
  6. Reboot.


Note: Booting from USB may or may not work on your computer, mostly dependent on its age and bios setup. Some systems may have problems booting from USB drives formatted as FAT32. Changing the format step to
FORMAT F: /fs:FAT
may allow DSL to boot.

(**) YMMV. Some report this does not work. Some report it does:

  • (Tested 9/27/07 on Hp T5515 thinclient, worked without issue. Generic 512mb drive, fat32, DSL embedded 3.4.3)
  • (Tested 10/16/07 on Custom built dual core PC, Worked Without issue. Adata JOGr 2 gig drive, FAT32, DSL embedded 3.4.4)
  • (Tested 11/25/07 on Asus EEEpc, worked without issue. Generic 128MB drive, FAT32, DSL embedded 4.0)
  • (Tested 12/12/07 on Memorex Traveldrive, worked without issue. 1GB drive, FAT32)
  • Starts booting but stops showing an insmod error (?) on Packard Bell Easynote XS20-005, booted from a Apacer Handy Steno AH123 (1Gb, FAT32) with dsl-4.2.5-embedded, boot parameter "dsl vga=normal", xvesa 800x600x32.
  • Doesnt boot from generic 256Mb usb stick on Packard Bell Easynote XS20-005, tried both FAT and FAT32
  • (Tested 4/22/08 on Dell Inspiron 600m using 1GB Sandisk Cruzer, DSL Embedded 4.2.5 FAT32 - worked without issue)
  • (Tested 07/27/08 on One Mini Notebook A120, worked without issue. Generic 128MB drive, FAT32, DSL embedded 4.2.5)
  • (Tested 08/10/08 on Compaq 2190US Laptop (using Method I) - Lexar 4GB Lightning USB, DSL embedded 4.2.5 - The Lexar USB appeared as 2nd hard drive by default, so I had to go into the Compaq BIOS and change the order so that the Lexar USB was first. When I rebooted, the 2190US booted into DSL with no problem.)
  • (Tested 08/31/08 on Acer Aspire 5672 (using Method I) - Kingston DataTraveler 1Gb FAT formatted (not FAT32), DSL embedded 4.2.4, - needed to enable <F12> multiboot option.)
  • (Tested 09/10/08 on Asus A8Sr (using Method I) - Mobile Disk IV 256 MB FAT32 with DSL 4.4.5 and Syslinux 3.71)
  • (Tested 11/10/08 on a Fujitsu-Siemens Amilo D 8830 and a Kingston DataTraveler 1GB, FAT and dsl-4.4.6-embedded, works nicely)
  • (Tested 10/24/08 on a Dell Latitude D430 BIOS rev. A00 and on a Dell Latitude D820 BIOS rev. A09, with SanDisk Cruzer Micro 4GB, both FAT16 and FAT32 tested, DSL 4.4.0 and Syslinux 3.63, DSL 4.4.6 and Syslinux 3.72, unsuccessful in all test cases. Result: Upon boot, the DSL boot option menu is available, but regardless of which option is selected, the screen turns black and the USB stick LED goes off, indicating contact to the USB key is lost. Exception: Failsafe boot option, which ends with the message "no KNOPPIX file system found".)
  • (Tested 12/15/08) Method I does not work with Centon Data Stick Pro.) Will need to use Method II as well as the last step from Method I (# Go to a command prompt and run syslinux for your drive from \win32\syslinux.exe typing:SYSLINUX -ma F:)

Method II

NOTE: HP USB Key Utility setup will only run on vista if you run the installation in compatibility mode. To apply this, rightclick on the installation file and go to "Properties". Open the tab "Compatibility" and choose "Windows XP Service Pack 2". Apply and then it's working on vista too. Note: You don't need to run the installed program in this mode.

For this method, you will need "HP USB Key Utility for Windows", from http://h20000.www2.hp.com/bizsupport/TechSupport/SoftwareDescription.jsp?lang=en&cc=us&mode=3&taskId=135&swItem=MTX-UNITY-I23839

  1. Install "HP USB Key Utility for Windows"
  2. Plug in the flash disk and let windows find it (check the letter assigned to your flash disk e.g. F:)
  3. Run Start Menu-> Programs -> HP System Tools -> HP Drive Key Boot Utility
    1. On Welcome Screen - click Next
    2. Select your flash drive letter (in my case F:) - click Next
    3. Choose Create New or Replace Existing Configuration - click Next
    4. Choose Hard Drive - click Next
    5. Choose Create New Filesystem - click Next
    6. Wait until the drive is formated...
    7. Choose HP Firmware Flash Package - click Next, click Finish.
  4. Now extract the content of the dsl-embedded.zip file directly onto your flash disk (F: in my case) overwriting all files(!!).
  5. Done! Your DamnSmallLinux on USB is ready :-) Reboot and try it!!

NOTE: This method did not work for me using DSL v3.3 with a Sandisk Cruzer Titanium USB drive.

User Tested: This method worked perfectly using HP Utility and dsl-4.2.1-embedded.zip

Method III

Use if top two methods do not work

  • Low Level Format Blank Disk with diskWipe
   diskwipe.exe
  • Make sure to select correct drive
  • Unmount Drive
  • Physically remove
  • Mount Drive
  • Physically add
  • Format FAT with usb_format
   usb_format.exe
   dsl-<current>-embedded.zip
   syslinux.exe -ma <drive letter>:

Convert .iso to USB installation

With the guide from [1] you can install the .iso contents non-destructively onto a USB partition. Leave out all the partitioning or formating stuff to prepare an existing and used USB drive for DSL booting:

Note: All path names are examples! Please adapt or you may corrupt existing partitions or files.

  • Mount USB drive, with e.g. mount /dev/sdx1 /flash - can be either FAT16 or FAT32!
  • Mount ISO image, with e.g. mount /tmp/dsl-3.2.iso /tmp/iso -o loop
  • Copy all contents from ISO to USB drive: cp -vr /tmp/iso/* /flash/
  • Rename and move syslinux files to root directory: mv /flash/boot/isolinux/* /flash/
  • Rename isolinux.cfg: mv /flash/isolinux.cfg /flash/syslinux.cfg
  • Unmount USB drive: umount /flash
  • Install syslinux: syslinux /dev/sdx1 and eventually set the MBR boot flag for this partition (with fdisk).


Modifications for v 3.2 Embedded

After installation I added autorun.inf penguin.ico /USB /tightvnc

Trying to run the dsl-linux.sh in my distro did not work I had to modify the file (it was setup for a second drive and qemu did not exist in the download)

Here are some configuration settings that I found I had to modify after the installation. I also created an autorun.inf that works flawlessly with this. The autorun.inf file is also configured for use of TightVNC if the folder tightvnc is created at the root of the drive. I also created a context link to the folder USB.

  • autorun.inf
  [autorun]
  icon=penguin.ico
  label=Damn Small Linux
  open=dsl-base.bat
  action=Run Damn Small Linux in qemu
  shell\vncviewer\command=tightvnc\vncviewer.exe
  shell\vncviewer=Run the VNC Viewer Application
  shell\tightvnc\command=tightvnc\tightvnc-1.2.9-setup.exe
  shell\tightvnc=Run the TightVNC Server Installation
  shell\usbfolder\command="explorer.exe USB\"
  shell\usbfolder=Open the USB folder in Windows Explorer


This next file I modified and paired up with the windows equivalent so you do not have to answer the questions every boot. Some people might find the -m 256 beyond and should change as needed.

  • dsl-linux.sh
   qemu/qemu -L qemu/ -no-kqemu -soundhw sb16 -m 256 -localtime \
      -kernel linux24 -initrd minirt24.gz -hda KNOPPIX/KNOPPIX \
      -append "qemu vga=791 quiet noscsi nousb nofirewire atapicd noideraid \
       noacpi acpi=off noapm noagp ide1=noprobe ide2=noprobe nomce frugal"


You must also download qemu and copy these files to the qemu dir on the usb drive.

  • qemu
  • qemu-img
  • qemu-i386

If you wish to use the rest of the context menu I've created, download the TightVNC installer, vncviewer and put them in a \tightvnc.

At this point I made all of the damn small linux files hidden and hid the TightVNC, USB folders. Its a low level of security but works nicely. To use anything you just right click the drive in My Computer. =)

Other References

Pendrive Linux

Pendrive Linux - DSL specific instructions