===== Install (K)ubuntu on a USB stick ===== ==== Requirements ==== * a fast //USB// stick is obviously an advantage. You can recognize the fast sticks with indication of read / write speed, sometimes it is indicated with something like "200x". * to use the stick like a live CD, or if you do not want to update the original release, you need at least 1GB of free space on the stick. * to use the stick as a writeable installation and update the original release (apt-get), you need at least 3GB of free space on the stick. * the (K)ubuntu installation can co-exist with a Windows XP partition on the same stick. The following guide will describe how to set up the stick accordingly. * this guide is made for Edgy 6.10, as the Feisty 7.04 persistent feature is reported to be broken. If you plan to use the stick as live CD (read-only), then you may also use Feisty to install. * measures are proposed to make the stick more secure, e.g. prepare for the case you would loose the stick and don't want your data to be accessible by others. __Note__: This guide is based on my own trials and the following articles, which did not work for me but were a tremendous help: * http://www.pendrivelinux.com * http://www.mayrhofer.eu.org/Default.aspx?pageindex=6&pageid=45 * http://nsaunders.wordpress.com/2006/11/06/a-usb-stick-grub-and-ubuntu ==== Setup (K)ubuntu ==== - If you do not plan to use a Windows XP partition on the same stick, then you need to replace all future references to partition 2 with partition 1, partition 3 with partition 2, etc. This guide will assume you setup partition 1 with Windows XP. Note that XP only recognizes partition 1 to be a valid USB stick partition. - Download the Kubuntu (http://www.gtlib.gatech.edu/pub/ubuntu-releases/kubuntu/edgy/) or Ubuntu (http://www.gtlib.gatech.edu/pub/ubuntu-releases/edgy/) Edgy 6.10 ISO and burn it to a CD - If you are not running (K)ubuntu Edgy 6.10 reboot your computer into Ubuntu from the Live CD - Insert your USB flash drive - Open a terminal window and type **sudo -s** - Type **fdisk -l** to list available drives/partitions. Note which device is your flash drive (In my case: /dev/sdb). Throughout this tutorial, replace b with your flash drive letter. For example, if your flash drive is sdf, replace b with f. - type **umount /dev/sdb1** - repeat for other partitions if you stick contains more than one partition - type **fdisk /dev/sdb** - type **p** to show the existing partition and **d** to delete it - if your stick contains more than one partition: enter partition number to confirm delete, then repeat until all partitions are deleted - type **n** to make a new partition - type **p** for primary partition - hit //enter// to use the default 1st cylinder - type **+sizeM** to set the partition size to size MB. For a 16GB stick, a reasonable size would be 12GB, e.g. type +12000M. verify with **p** that the partition is allocated with the correct size. - type **t** to change the partition filesystem - type **7** to select the NTFS file system - type **n** to make a new partition. This will be the "live" partition which will not be modified during usage and needs to have a FAT file system. - type **p** for primary partition - type **2** to make this the second partition - hit //enter// to use the default cylinder - type **+700M** to set the partition size - type **a** to make this partition active - type **2** to select partition 2 - type **t** to change the partition filesystem - type **2** to select partition 2 - type **6** to select the FAT16 file system - type **n** to make another new partition - type **p** for primary partition - type **3** to make this the third partition - hit //enter// to use the default cylinder - hit //enter// again to use the default last cylinder - type **w** to write the new partition table and quit fdisk - Type **umount /dev/sdb2** to ensure the 2nd partition is unmounted - Type **mkfs.vfat -F 16 -n edgy /dev/sdb2** to format the 2nd partition which is the Ubuntu live partition the boot loader will boot into (__note__: you may choose any name to replace //edgy//) - Type **umount /dev/sdb3** to ensure the 3rd partition is unmounted - Type **mkfs.ext2 -b 4096 -L casper-rw /dev/sdb3** to format the 3rd partition which is the extension partition where all your later changes to the base system will be safed (__note__: the partition label //casper-rw// must be entered with the exact spelling and in lower case. This partition will be invisible once you run (K)ubuntu from the stick) - formatting the Windows XP partition must be done from a running XP system (see next paragraph) - Remove and Re-insert your flash drive - Type **apt-get install syslinux mtools** (to obtain the boot manager) - Type **syslinux -sf /dev/sdb2** - Download this custom {{comp:usyslinux.tar|usyslinux.tar}} file and extract the //syslinux.cfg// file to /media/edgy (the root directory of /dev/sdb2) - Type **cd /media/cdrom0** (running installed Edgy) or **cd /cdrom** (running the Edgy LiveCD) - Type **cp -rf casper disctree dists install pics pool preseed .disk isolinux/* md5sum.txt README.diskdefines kubuntu.ico casper/vmlinuz casper/initrd.gz install/mt86plus /media/edgy/** - If you are installing Ubuntu from a running Ubuntu Edgy, replace kubuntu.ico with ubuntu.ico. Note that there are 2 error messages when the copy finishes, indicating that 2 sym links could not be copied. Just ignore the message, these sym links are not necessary to be copied. - Type **apt-get install lilo**. You can later uninstall lilo after having installed the MBR to the stick. - Type **lilo -M /dev/sdb** to install a bootable MBR - Reboot your computer and set your system BIOS to allow booting from USB devices. Also set the boot priority if necessary. Leave the stick in the USB port to boot from the stick. If everything has gone as it should, you should now be able to boot Ubuntu from the USB flash device and it should save your changes, restoring them on boot. ==== Setup Windows XP ==== - When the USB stick is inserted in your computer, start the Device Manager in the Control Panel and find the USB drive - Select tab Policies in Properties and select "Optimize for performance". This is necessary to allow the partition to be formatted with the NTFS file system. - Go to My Computer, right-click the drive icon of your USB stick, select Format and format the stick with NTFS file system (if the partition is smaller than 4GB you can also choose FAT32 as file system, but NTFS is recommended unless you need to access the stick from Windows 95/98/ME) - Install TrueCrypt 4.3a or a later version to your computer (you find the latest version at http://www.truecrypt.org) - Copy the files //TrueCrypt.exe// and //truecrypt.sys// from the installed directory (usually C:\Program Files\TrueCrypt) to the directory \TrueCrypt on your stick - Download the custom {{comp:autorun.zip|autorun.zip}} and extract to the root of the USB stick. Change the content if you choose different file names from the proposed installation. - Start TrueCrypt on your computer and create your truecrypt container on the USB stick. Name the container "usb-xp.tc" to match the settings in the autorun.inf file. __Note__: this setup only allows to open the truecrypt container on the stick. If you need the full functionality of truecrypt when working on a different client machine where truecrypt is not installed, then you need to copy all the files from the installed directory. When opening the container on a different client machine, nothing will be installed to that client, but you need to have administrator privileges to be able to open the container.