Saturday, December 14, 2013

Multi-Boot USB Flash Drive with Syslinux

Why create a USB Drive bootable?
|--- Recover your data when the system no longer boots
|--- Surf the internet without any OS installed
|--- Hardware Diagnostics (i.e. Seatools)
|--- Offline Virus Scanner (i.e. Avg-rescue-cd)
|--- Optical Drive is broken or not available
‘--- Easy to carry…and so forth...

Requirements:
|--- Atleast 1GB + USB Drive
|--- Download Syslinux-6.02.zip
|--- Lightweight linux distros like Puppy Wary 5.5  and Slitaz 4.0
|--- Archiving utility for extracting iso files such as 7zip
‘--- Patience :-)

NOTE: No need to format the drive if the filesystem type is FAT or FAT32

INSTRUCTION: Windows Machine

I. Syslinux Components

Inside the drive create a folder and name it “boot”
  -----------------------------------------------------------------------------------------------------------
  | x:\boot>
  '----------------------------------------------------------------------------------------------------------

Inside the folder “boot” create another folder and name it “syslinux”
  -----------------------------------------------------------------------------------------------------------
  | x:\boot\syslinux>
  '----------------------------------------------------------------------------------------------------------

Extract Syslinux-6.02.zip to desktop

Copy all this files to the folder you had created on step #2 "syslinux"
  -----------------------------------------------------------------------------------------------------------
  |--- syslinux-6.02\bios\win32\syslinux.exe
  |--- syslinux-6.02\bios\com32\menu\menu.c32
  |--- syslinux-6.02\bios\com32\chain\chain.c32
  |--- syslinux-6.02\bios\memdisk\memdisk
  |--- syslinux-6.02\bios\com32\modules\reboot.c32
  |--- syslinux-6.02\bios\com32\modules\linux.c32
  '----------------------------------------------------------------------------------------------------------

The folder should look like this
  -----------------------------------------------------------------------------------------------------------
  |-- x:\boot\syslinux>
  |                   |--- syslinux.exe
  |                   |--- menu.c32
  |                   |--- chain.c32
  |                   |--- memdisk
  |                   |--- reboot.c32
  |                   ‘--- linux.c32
  '----------------------------------------------------------------------------------------------------------


II. Lightweight Linux Distros

Puppy Linux Wary 5.5

Create a folder and name it “puppy” and extract wary-5.5.iso to that folder and transfer it to Flash Drive
  ---------------------------------------------------------------------------------------------------------------------------------------------------------------
  |-- x:\puppy>
  |            |--- puppy_wary_5.5.sfs
  |            |--- vmlinuz
  |            |--- initrd.gz
  |            |--- logo.16
  |            ‘--- etc..…..
  '--------------------------------------------------------------------------------------------------------------------------------------------------------------

Slitaz 4.0

Extract slitaz-4.0.iso to a folder and rename the extracted “boot” folder to “slitaz” and transfer it to to Flash Drive
  ---------------------------------------------------------------------------------------------------------------------------------------------------------------
  |-- x:\slitaz>
  |           |--- vmlinuz-2.6.37-slitaz
  |           |--- bzImage
  |           |--- rootfs1.gz
  |           |--- rootfs2.gz
  |           |--- rootfs3.gz
  |           |--- rootfs4.gz
  |           ‘--- etc..………
  '--------------------------------------------------------------------------------------------------------------------------------------------------------------


III. The Configuration File

Open notepad and copy this code
::--------------------------------------------------------------------------------------------------------------------------------------------------------------
  default menu.c32
  prompt 0
  menu title YOUR NAME

  label puppy
  menu label Puppy Wary 5.5
  kernel /puppy /vmlinuz
  append pmedia=usbflash psubdir=/puppy lang=en pkeys=us
  initrd /puppy/initrd.gz

  LABEL slitaz
  menu label Slitaz 4.0
  KERNEL /slitaz/bzImage
  append initrd=/slitaz/rootfs4.gz,/slitaz/rootfs3.gz,/slitaz/rootfs2.gz,/slitaz/rootfs1.gz rw root=/dev/null
  lang=C kmap=us vga=normal autologin
::--------------------------------------------------------------------------------------------------------------------------------------------------------------

Save the file as “syslinux.cfg” and transfer it to syslinux folder
  --------------------------------------------------------------------------------------------------------------------------------------------------------------
  |-- x:\boot\syslinux>
  |                   |--- syslinux.cfg
  |                   |--- syslinux.exe
  |                   |--- menu.c32
  |                   |--- chain.c32
  |                   |--- memdisk
  |                   |--- reboot.c32
  |                   ‘--- linux.c32
  '-------------------------------------------------------------------------------------------------------------------------------------------------------------


|V. Make the USB Flash Drive Bootable

Open notepad and copy this code
::--------------------------------------------------------------------------------------------------------------------------------------------------------------
  @ECHO OFF

  :HOME
  CLS
  ECHO ---------------------------------------------
  ECHO      SYSLINUX INSTALLER     
  ECHO ---------------------------------------------

  IF NOT EXIST "syslinux.exe" (
   ECHO Syslinux.exe does not exist
    PAUSE > nul
   EXIT
  )

  :DRIVE
  SET /p USB=Drive letter:
   IF EXIST %USB%:\WINDOWS\explorer.exe (
     GOTO OS
    ) ELSE (
   GOTO INSTALL
  )

  :INSTALL
  syslinux.exe -mad \boot\syslinux -f %USB%:
    IF EXIST %USB%:\boot\syslinux\ldlinux.sys (
      ECHO Syslinux successfully installed on drive %USB%:
       PAUSE > nul
      EXIT
     ) ELSE (
    PAUSE > nul
   GOTO HOME
  )

  :OS
   ECHO Cannot run Syslinux from your local system hard drive
    PAUSE > nul (
   GOTO HOME
  )
::--------------------------------------------------------------------------------------------------------------------------------------------------------------

Save the file as “syslinux-installer.bat” and transfer to syslinux folder

The contents of your USB Drive should now look like this...
  --------------------------------------------------------------------------------------------------------------------------------------------------------------
  |-- x:\boot\syslinux>
  |                   |--- syslinux-installer.bat
  |                   |--- syslinux.cfg
  |                   |--- syslinux.exe
  |                   |--- menu.c32
  |                   |--- chain.c32
  |                   |--- memdisk
  |                   |--- reboot.c32
  |                   ‘--- linux.c32
  |-- x:\puppy>
  |            |--- puppy_wary_5.5.sfs
  |            |--- vmlinuz
  |            |--- initrd.gz
  |            |--- logo.16
  |            ‘--- etc..…..
  |-- x:\slitaz>
  |           |--- vmlinuz-2.6.37-slitaz
  |           |--- bzImage
  |           |--- rootfs1.gz
  |           |--- rootfs2.gz
  |           |--- rootfs3.gz
  |           |--- rootfs4.gz
  |           ‘--- etc..………
  '--------------------------------------------------------------------------------------------------------------------------------------------------------------
When all contents are complete just execute the file “syslinux-installer.bat”




No comments:

Post a Comment