Installing DSL to a USB Flash Drive (Linux way)


Installing Damn Small Linux to a USB Flash Drive from your Linux Desktop

Here the steps for doing that:
Minimum size for USB Drive: 128MB.
Save all of your data on your USB to another storage medium, such as a CD/DVD or hard drive.

  • Begin by determining the location of your flash drive. It will be something like /dev/sda
 fdisk -l
  • 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 here.
  • 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).
 dd if=/dev/zero of=/dev/sdX bs=512 count=1

( BE *VERY* CAREFUL NOT TO WIPE YOUR HARD DRIVE'S MBR HERE!!!)

Download ms-sys then install and put another MBR in its place:

 ms-sys -s /dev/sdX

Another way to put MBR in its place is using 'mbr.bin' 512 bytes file from the Syslinux package:

   locate mbr.bin
cat /somepath/share/syslinux/mbr.bin > /dev/sdX
  • 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

mkfs.vfat -F 32 /dev/sdX1 ("-F 32" will do FAT32; "-F 16" will do FAT16)
  • Mount the pendrive & unzip the dsl-embedded.zip file onto this.
  • Unmount the pendrive
  • Type syslinux -s /dev/sdX1 to make it bootable.
  • 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. 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.

Method 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/
mkdir -p /tmp/pendrive
mount /dev/ /tmp/pendrive/

where 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/

Note: Replace with the corresponding file which represents your USB storage device/partition.
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 << root="/dev/sda1" lang="us">

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

Method 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

Here is 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
  • 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 cvf - . | (cd /mnt/usb; tar xvf - )
  • mkdir /mnt/usb/boot/grub
  • cp /boot/grub/*stage* /mnt/usb/boot/grub/
  • cat > /mnt/usb/boot/grub/menu.lst
 title Damn Small Linux
root (hd0,1)
kernel /boot/isolinux/linux24 root=/dev/sda1 ro lang=us toram noeject frugal
initrd /boot/isolinux/minirt24.gz
boot
  • 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
Done! Your DamnSmallLinux on USB is ready. Reboot and try it!!

1 comments:

Anonymous said...

TOO CONVOLUTED !!!!!

Stick with booting from an ISO till the hacks get all the bugs worked out.
Ive tried this with puppy linux,Slax and D@m small linux.

It's not worth the headache !!!!
Half the time it won't work anyway due to some idiot writing the instructions wrong or #2 you having to fiddle or change the boot config cause the one you were told to use just won't work.

Use a live CD along with a Portable keychain device to save stuff on.

It's clean and it works on any machine without fiddling and pulling your hair out.

Delicious Digg Technorati Reddit Furl BlinkList Yahoo! NewsVine Netscape Google Live Bookmark Netvouz Squidoo StumbleUpon Magnolia.png