Saturday, January 23, 2010

make a usb bootable old school shell way

I always like to have live OS on sticks and tools to check PCs I'm tring to fix at hand, but sometimes I use custom images or the tools comes without a usb-installation procedure so I find pretty annoying to try to use win style several not properly working tools that are supposed to make usb bootable so here it is a procedure that should work for any custom.

To install a live USB system on a memory the following steps need to be done  :

  • A USB flash drive needs to be connected to the system, and be detected by it
  • One or more partitions may need to be created on the USB flash drive
  • The "bootable" flag must be set on the primary partition on the USB flash drive
  • A MBR must be written to the primary partition of the USB flash drive
  • The partition must be formatted (most often in FAT32 format, but other systems can be used too)
  • A bootloader must be installed to the partition (most often using syslinux when installing a Linux system)
  • A bootloader configuration file (if used) must be written
  • The necessary files of the operating system and default applications must be copied to the USB flash drive
  • Language and keyboard files (if used) must be written to the USB flash drive
Anyway I wanted to get Memtest86+ to boot from a USB Drive or Hard Drive (without having to install an entire distro or DOS).

note: drive used here is a usb drive located on /dev/sdb so make changes accordingly (eg a hard drive install would use /dev/hdc instead)

First Step - format the drive
optional, only suggested if you're drive needs a good cleaning
(this may take a long time given the size of the drive)
dd if=/dev/zero of=/dev/sda bs=8M
Second Step - create FAT partitions (syslinux requires FAT)

this will create a FAT16 partition with the boot flag set

fdisk /dev/sda
[enter, enter]
Third Step - format FAT partition
mkdosfs /dev/sdb1
Fourth Step - install syslinux
syslinux /dev/sdb1
Fifth Step - mount drive and setup syslinux
mount /dev/sdb1 /mnt/sdb1
(look inside the partition, it should have a file called ldlinux.sys)

we now need to create a file called syslinux.cfg written with the following:
default memtest
label memtest
kernel memtest
Sixth Step - copy over the Memtest image
either grab the source and compile your own binary, or simple download the Pre-Compiled Bootable Binary from the memtest86+ site:

gunzip the file, and you will find a file called memtest86+xxxx.bin, rename this file to memtest and copy it to the drive:

cp memtest86+xxxx.bin /mnt/sdb1/memtest

Seventh Step - install MBR
you can unmount the drive now:
umount /dev/sdb1

now install the Master Boot Record:
dd if=/usr/lib/syslinux/mbr.bin of=/dev/sdb bs=512 count=1

Done. You can now boot the drive. Make sure you make the appropriate changes to your BIOS.

and as a last reference following are several live distros links:
  • BackTrack: A distribution of linux that is made with security in mind and is commonly used for cracking WEP passcodes and has live installs including USB and CD.
  • BeleniX: Customized OpenSolaris installs including live CD and live USB.[4]
  • Billix: A multiboot distribution and system administration toolkit with the ability to install any of the included distributions.
  • Damn Small Linux: Knoppix derived small installation, uses a 2.4 kernel, with JWM as default user interface.
  • Debian
  • Devil-Linux: for service installations e.g. firewall/router, no graphical interface, can boot from CD or USB.
  • dyne:bolic: 100% free distribution for multimedia production, boots from CD and USB stick, with Xfce as default user interface.
  • FaunOS: a live USB distribution based on Arch Linux
  • Fedora (with Fedora Live USB creator)
  • Gentoo Gentoo USB Live.
  • Knoppix: Full live CD/USB based on Debian distro.
  • Knopperdisk: A small distribution based on Gentoo but designed to be run from USB pen drives or floppy disks.
  • MCNLive: Mandriva derived live CD, and live USB distribution.
  • MilaX: Small OpenSolaris live CD and live USB distribution.
  • Minix
  • MooLux: Live-USB Linux based on linux Slackware that can be installed to hard drive with focus on Internet applications, multimedia and programming tools.
  • NimbleX: A small (200mb) distribution based on Slackware.
  • OpenBSD
  • OpenSolaris: The Distribution Constructor project has tools allowing users to build an install image.
  • openSUSE
  • OS-9 RTOS: The standard OS-9 Configuration Wizard for X86 creates bootable USB sticks. OS-9 5.0 for X86 will support the creation of bootable CDs.
  • OSx86
  • PCLinuxOS: Version 2009.1 comes with a live USB creator tool, version 2008 "MiniMe" can be installed manually[6]
  • Pentoo: Gentoo based live CD and live USB distribution focused on penetration testing and security assessment.
  • Puppy Linux Designed for easy install on USB.
  • RUNT Linux: Based on Slackware with a 2.4 kernel and Umsdos filesystem. Designed as a network testing tool for students at North Carolina State University.
  • sidux: Based on Debian unstable (sid)
  • Slax: Slackware based installation.
  • Sugar (desktop_environment) - Sugar on a Stick is a LiveUSB for children and learning.
  • Super OS: usb-creator and cd2usb already included on the DVD
  • Ubuntu (can be installed directly to a flash drive or USB external hard drive manually by using tools like usb-creator, UNetbootin, or cd2usb)
  • Windows Preinstallation Environment: Freely available version of a live Windows installation, command-line only.

long live knowledge alex

No comments:

Post a Comment