Installing on a USB flash drive

# Installing on a USB flash drive

- From a Unix system
- From Windows

Booting Haiku from a USB memory stick is currently one of the best ways to test out the operating system. No changes will be made to your computer, so you can test a pre-Alpha OS without any worries. It is also the easiest method to install Haiku, so it is recommended for beginners. The installation process differs from a Unix system (This includes many operating systems like Linux, Mac OS X, FreeBSD and such) to that of Windows.

You will need a small USB memory stick (512MB should be more than enough) that you are ready to erase and a recent HDD raw image. Note that these are test images, they are not complete distributions that include a lot of software. Future releases will include a more complete set of software, obviously. Your motherboard should also support booting from USB Drives (most recent computers do).

## Using a Unix system (Linux, Mac OS X, FreeBSD etc.)

Now that you've downloaded the raw image, you will need to expand this image on your USB Drive you intend to install it to. You will first need to know the name of your drive (something like /dev/sdb, /dev/disk1 or a variant).

First connect your flash drive.

Under Linux, open your shell and type:

    fdisk -l

On Mac OS X, open the terminal (Utilities > Terminal) and type:

    df -hl

The output should resemble something like,

    Disk /dev/sda: 4034 MB, 4034838528 bytes
    255 heads, 63 sectors/track, 490 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    Disk identifier: 0x000740f4

    Device Boot Start End Blocks Id System
    /dev/sda1 * 1 462 3710983+ 83 Linux
    /dev/sda2 463 490 224910 5 Extended
    /dev/sda5 463 490 224878+ 82 Linux swap / Solaris

    Disk /dev/sdb: 16.1 GB, 16139354112 bytes
    255 heads, 63 sectors/track, 1962 cylinders
    Units = cylinders of 16065 * 512 = 8225280 bytes
    Disk identifier: 0xf26d47c4

or

    Filesystem     Size   Used  Avail Capacity  Mounted on
    /dev/disk0s2  186Gi  112Gi   74Gi    61%    /
    /dev/disk1s1  1.9Gi  265Mi  1.6Gi    14%    /Volumes/KINGSTON

Now you need to use the dd tool to extract the raw image to your USB Key. Make sure you have the right drive selected here, since this will erase all data on the specified location. Recheck with a partition tool to verify for example. You might need administrative rights, so add the sudo or su command before the next step to run the process as administrator (a password will be required).

Note: You will want to put the image at the absolute start of the drive, make sure that you write to the whole raw drive and not to a partition. You do that by specifying a raw device instead of a partition. Under Linux you would for example omit the partition number resulting in sdb instead of sdb1. Under BeOS you would pick the .../raw path instead of one with a number. If you use such a command, you overwrite the MBR containing the partition table of your USB memory stick. This means, that all the partitions on that drive will become inaccessible (not only the first part of the drive). So be sure that you want to do such a destructive operation!

Still in the terminal, enter:

    dd if=/path/to/image of=/dev/sdb

Where /dev/sdb stands for your USB memory stick's name found earlier.

Congratualtions! You have just installed Haiku to a USB memory stick. You can now restart your computer to boot from Haiku. Note that you will probably have to enable USB drive booting in your BIOS and change the hard drive boot priority order. If Haiku's splash screen stops in the middle of the icons, and then sends you to Kernel Debug Land, you might have to disable the Plug and Play OS option in your BIOS.

## Using Windows

You will need basic knowledge of your command prompt to go through this step-by-step guide. You can type help inside your command prompt to get some information on the required navigation commands.

You have to download and install the latest Flashnul utility.

Note:The Flashnul website isn't in English. You can simply click on the "Download" link and then select the upper-most entry (the latest version) to download.

Extract your raw image zip file and the Flashnul program in the same directory (ex. c:\haiku). Rename the raw image's extension to .img (ex. haiku.img).

Open your command prompt (go to Start > Run, then type cmd and press ENTER). You will see a black window with a blinking cursor, this is your command line editor (commonly named command prompt or shell).

Note:If you are using Windows Vista, you will need administrator rights to see the available physical drives. To run the command prompt in administrator mode, go to Start > All Programs > Accessories > Command prompt, right click on the program and select Run as Administrator.

Navigate to the directory containing your raw image and the Flashnul utility. For example,

    cd \haiku

if the directory is c:\haiku

You need to find the number of your USB flash drive. This is very important, because if you do not select the right drive, your whole hard drive will be erased. To find out your flashdrive's name, in the command prompt, type:

    flashnul -p

The output should resemble something like,

    Available physical drives:
    0       size = 81961123328 (76 Gb)
    1       size = 1000341504 (954 Mb)

You are now ready to extract the raw image over the memory stick. Make sure the number you have noted is the one of your flash drive. X being your memory stick's number, type:

    flashnul X -L haiku.img

And your shell should output:

    Disk PhysicalDrive1 (UNC name: \\.\PhysicalDrive1)
    ------------------------------------------------------------[Drive geometry]--
    Cylinders/heads/sectors  = 121/255/63
    Bytes per sector         = 512
    CHS size                 = 995258880 (949 Mb)
    ---------------------------------------------------------------[Device size]--
    Device size              = 1000341504 (954 Mb)
    delta to near power of 2 = 73400320 (70 Mb), 7%
    Surplus size             = 5082624 (4963 kb)

    -----------------------------------------------[Adapter & Device properties]--
    Bus type                 = (7) USB
    Removable device         = Yes
    Command Queue            = Unsupported
    Device vendor            = Kingston
    Device name              = DataTraveler 2.0
    Revision                 = PMAP
    --------------------------------------------------------------[Hotplug info]--

    Device hotplug           = Yes
    Media hotplug            = No
    	Selected operation:      load file content
    	Selected drive:          PhysicalDrive1, 1000341504b (954 Mb)
    	THIS OPERATION IS DESTRUCTIVE!!!
    	Type 'yes' to confirm operation. All other text will stop it.
    	Really destroy data on drive PhysicalDrive1?  :yes

    -----------------------------------------------------------------------[Log]--
    Running operation [load file content] for drive PhysicalDrive1
    Writing 0xf9f0000 (250 Mb), 899733 b/s
    image load finished
    ----------------------------------------------------------[Operation result]--
    passes:                 1
    errors:                 0
    write bytes:            262144000 (250 Mb)
    avg. write speed:       899731 (878 kb/s)
    	max/min write speed:    0 (0 b/s) / 0 (0 b/s)
    Press ENTER to exit.

Congratualtions! You have just installed Haiku to a USB memory stick. You can now restart your computer to boot from Haiku. Note that you will probably have to enable USB drive booting in your BIOS and change the hard drive boot priority order. If Haiku's splash screen stops in the middle of the icons, and then sends you to Kernel Debug Land, you might have to disable the option Plug and Play OS in your BIOS.