# Puredyne/Creating a live USB stick

This document assumes that you are familiar with, and not afraid of using a command shell.
Simpler instructions for creating a live USB stick if you already have one
BACK-UP YOUR DATA! We do not recommend working on a hdd, or a usb drive, that has important data on it without keeping another copy somewhere else. We can not, and will not ever, assume responsibility, implied or expressed, for any loss of data incurred using this guide. Again, back-up your data Luke!
This guide assumes that you have a working Puredyne CD or DVD (or a running virtualisation image, e.g. using qemu FIXME-does this work??) from which you can create the USB stick. You can create working devices from other gnu/linux distros too, using these instructions.

## Creating a USB bootable drive using make-live-device.sh
### Summary of steps

* Download and install dependencies: bzr (bazaar), grub2 and (g)parted. (If you're running Puredyne these are already installed.)
* Check out bouilloncube source code from launchpad.
* Download the DVD (or CD) iso image from one of the Puredyne mirrors. Refer to the Puredyne/Getting Puredyne page for ways to do that.
* Plug in the USB stick, find out which device file to use and run the make-live-device.sh script (using sudo).

### In detail

Note: if you are creating a stick from a running Puredyne system you already have the script installed, but at the moment it's a good idea to follow all of these steps so that you have the latest version of the script.
* Installing all necessary dependencies to run the make-live-device.sh script strongly depends on which distribution of GNU/Linux you are using. In Debian-based systems (such as Debian, Ubuntu, or Puredyne) you can just open a terminal and type: sudo aptitude install bzr grub2 parted Update: as of Ubuntu 10.10+ aptitude is no longer included with Ubuntu. Use apt-get. Other flavours of GNU/Linux, for instance like gentoo you have to use their respective package management tools to install these programs. Here's an example for gentoo: sudo emerge bzr parted grub2
* To check out the source code of bouilloncube (including make-live-device.sh) type this in a terminal: bzr branch lp:bouilloncube This will create a directory called bouilloncube in your home directory.
* Download the DVD or CD iso image from one of the Puredyne mirrors closest to you. You can get detailed instructions to do this here, for one example for downloading the iso from the Puredyne main mirror using rsync type this in a terminal window: rsync -P rsync.goto10.org::puredyne-pub/ This will give you a directory listing of all releases on our rsync server, as well as an empty entry as a pointer to the newest release (currently "LATEST_IS_CARROT_AND_CORIANDER") To download the lastest DVD release type: rsync -P rsync.goto10.org::puredyne-pub/carrot_and_coriander/puredyne-911-carrot_and_coriander-DVD-amd64.iso puredyne-911-carrot_and_coriander-DVD-amd64.iso TIP: if you already have a DVD or CD iso on your hard disk you can rsync over it (and thus save quite a lot of download bandwidth) by substituting the second argument to rsync with a path to your stored iso image.
* Now plug in the USB pen drive or USB-HDD to your computer and open a terminal. Wait for a couple of seconds until the device has settled and type: dmesg This will show you something like this: In the highlighted line (and in fact the line above that even clearer) you can see what the device file identifier is for the USB device you have just plugged in, and how many partitions are on it already. In this case there are two partitions on /dev/sdb already, /dev/sdb1 and /dev/sdb2 - make sure you have all data on these partitions backed up, as they will be wiped off the drive completely. All data will be lost! Tip: you can use the very great rdiff-backup tool to create, maintain and restore timestamped backups. Next, run the make-live-device.sh script. If you are not using Puredyne to create the stick you have to go into the bouilloncube directory checked out from bazaar earlier: cd /path/to/bouilloncube/sh/grub2 Then, or if you are already running a Puredyne system you can run the command like this: sudo ./make-live-device.sh /path/to/puredyne-911-carrot_and_coriander-DVD-amd64.iso /dev/sdX Make sure that you substitute /dev/sdX for the device you see when running dmesg, as noted above. Failure to do so can result in damaged/overwritten data on hard disk drives, so be careful! Replace the .iso filename if you downloaded the CD or the i386 version of Puredyne. The script will prompt you whether the selected device is correct, so answer this accordingly. After the script is finished you can unplug the device or reboot your computer straight into it.

## Creating a USB bootable drive manually

FIXME-FIXME-FIXME-FIXME-FIXME-FIXME
* Make sure the .iso file you downloaded is available on the file system of the machine where you're going to prepare the USB stick. It's OK if it's a Mac or NTFS partition -- puredyne can mount them.
* Boot from the disk. (Or, if you have a virtual-machine app, you could boot right from the iso.)
* Open an xterm window (terminal icon near lower left), then mount the location of the iso. It might take some trial and error to find out which device to mount. Hard disks and USB drives attached to the system are under /dev/sd(a,b,c...), with a number suffix for partitions. The partition editor gparted can help you find the device ID by size (but note, DON'T make any changes with gparted!):
Then use the drop-down menu at top right to look for the volume that's the same size as the iso location. For instance, on a machine with a 120GB hard drive, /dev/sda shows 111.79 GB and /dev/sdb shows 3.77 GB -- so obviously sda is the built-in hard drive and sdb is the memory stick. sda1 is the HD's first partition; sda2 is the second and so on.
Also, while in gparted, look for the device ID for the USB stick that you're going to prepare.
Once you know that, do this, including the partition number.
e.g.:
If it's a Windows partition, you might need to specify filesystem type:
4. The rest is easy. Use "CD" or "DVD" depending on which you downloaded and replace "path/to" with the real iso location.
(where # is the letter of the target USB stick -- don't include the partition suffix! Write sdc rather than sdc1.)
It'll take a few minutes, but then you'll have a persistent live bootable stick. It will make a smaller partition at the beginning for the iso contents and then use the rest of the stick to save any files that you changed or added later. So it's a good idea to get a stick with more space than you will actually need for the iso.
*** This will not work for me!!! When grub tries to load I get -no module name found-
I am worn out trying to make this work. Apparently there is a bug in grub2. I would like to try this on my netbook but oh well... Any ideas around this?

## Creating a USB bootable drive using unetbootin

Get unetbootin for Linux from http://unetbootin.sourceforge.net/ and a Puredyne iso file from http://puredyne.org/download.html .
On some distro's you may need to give unetbootin permission to run as a program.
Use a partitioning tool to create two ext2 partitions on your keypen.
The first should be 1.5 GB in size to hold Puredyne & should be bootable.
The second can use the remaining space on the drive and should be given the label live-rw (lower case, as typed). Puredyne will detect this and use it to store any changes you make.
Plug in the keypen & then use either mount or dmesg at a terminal to get the name of the first partition on the keypen.
Start unetbootin. Choose the 'Diskimage' option & click the box with three dots to get the file browser & choose the Puredyne iso. Check to make sure that the correct drive (the first on your keypen) is chosen. Click OK & wait for the message that will tell the process is completed.
The first boot will be slower than subsequent boots.