LiveUsbPendrivePersistent
Introduction
It is possible to have Ubuntu or Kubuntu on a USB pendrive or USB hard disk drive with persistent mode. This means that you can boot from a USB pendrive and keep customisations such as keyboard layout, numlock, preferences, additional packages saved on the pendrive. This can be done using linux or windows. You will need a USB pendrive of 1 GB or more. This page is written after having tested the instructions on a Peak III 1 GB pendrive. The preparation of the pendrive is explained using 'fdisk' because I had errors with 'gparted' and i could not give the partitions a volume name. I used Ubuntu to make the pendrive. In Kubuntu it is more or less the same. Where you see 'ubuntu' replace it by 'kubuntu'. I will mark the other differences.
Installing Ubuntu on USB pendrive using Linux
Preparing the USB pendrive
Making partitions
The preparation of the pendrive is explained using 'fdisk'. You could use 'gparted' or 'qtparted' as well. However I had errors with 'gparted' and I could not give the partitions a volume name. I tested 'qtparted' as well and it worked fine. You can install 'qtparted' under Ubuntu through synaptic although it is native to Kubuntu. Another issue in my case was that 'fdisk' recognised a fat32 filesystem as linux. So I checked it with gparted and it was OK.
Plug in the pendrive and check its device name :
sudo fdisk -l
We are going to suppose that its name is /dev/sdX where X is the disk device such as /dev/sda or /dev/sdc. Please be sure to use the correct number for X which matches the name you find for your pen drive. Double check it ! [Note: on newer computers, which use serial ATA disks, /dev/sda is typically the main hard drive; do not overwrite this!]
Now we are going to create 2 partitions : 1 partition of 700 MB with a fat32 filesystem and 1 partition with the rest of the pendrive space with volume name "casper-rw" and ext2 filesystem. The first partition will be made active.
Go in terminal and unmount the drive :
sudo umount /dev/sdX1
Fire up fdisk for the pendrive :
sudo fdisk /dev/sdX
This will give you the fdisk prompt. Look to what you have on the pendrive. Check if you have to backup the data you have on it. 'p' will print the content of /dev/sdX. If you have partitions on it remove them ('d', 'partition number'). Make partition 1 : 'n' for new partition, 'p' to make it a primary partition, '1' to call it partition number 1, then just press enter to accept the proposed starting cylinder, '+700M' to make its size 700 MB. Then 'a' to make it the active partition. Set the file system of partition 1 to FAT: 't', then '1', then '6'. Make partition 2 : 'n' for new partition, 'p' to make it a primary partition, '2' to call it partition 2, then just press enter to accept the proposed starting cylinder, then press enter to accept the proposed ending cylinder. Save and quit fdisk with 'w' to write the new settings. Check the result : sudo fdisk -l You should see the 2 partitions with the first marked with a * because it is active.
If ubuntu mounted the partitions again you should unmount them: sudo umount /dev/sdX1
sudo umount /dev/sdX2
for me +700M wasn't enough, i needed +750M, also make sure (via fdisk -l) you created a w95/fat and not a linux partition, otherwise i was unable to boot from it !! (i had to use gparted to achieve this) - bernstein
Formatting the partitions
We will now format the partitions by putting a filesystem on and giving them the name 'edgy' (or any other name you want) and 'casper-rw' (this name is MANDATORY, do not change other names and do not use capital letters) :
sudo mkfs.vfat -F 32 -n edgy /dev/sdX1 sudo mkfs.ext2 -b 4096 -L casper-rw /dev/sdX2
Mount the partitions on the pendrive. Take out the pendrive and put it back. Ubuntu Dapper or Edgy will mount the pendrive automatically if you have checked this option under System -->Preferences--> Removable media. Otherwise use 'mount' :
sudo mount /dev/sdX1 /media/mountpointyouhave1 sudo mount /dev/sdX2 /media/mountpointyouhave2
Installing Dapper or Edgy on the USB pendrive
Download the dapper or edgy image (ubuntu-6.06-desktop-i386.iso or ubuntu-6.10-desktop-i386.iso) or put in the install CD if you have it. If you use the downloaded image you can access it as follows (supposing that the image is in the path you are working in; use 6.06 for dapper or 6.10 for edgy):
mkdir ubuntuCD sudo mount ubuntu-6.06-desktop-i386.iso ubuntuCD -o loop
Now put in the CD or open the 'ubuntuCD' and make sure that you see the hidden files too. (verify if View-->Show Hidden Files is checked).
Copy the following folders and files to the 1st partition of your USB pendrive :
Folders : 'casper', 'disctree', 'dists', 'install', 'pics', 'pool', 'preseed', '.disk'
Files : all files from the folder 'isolinux', 'md5sum.txt', 'README.diskdefines', 'ubuntu.ico'
So you do not copy the folder 'isolinux' on the pendrive but only its contents directly in the root of the first partition of the pendrive.
Copy 'casper/vmlinuz', 'casper/initrd.gz', 'install/mt86plus'. So you will have these files double on the pendrive : once in the root '/' of the partition and once in the folder 'casper' or 'install'.
Rename the file 'isolinux.cfg' to 'syslinux.cfg' either by right clicking on it and selecting 'rename' or in terminal :
Replace /media/edgy to /media/whatmountpointyouhave1 if it's different
We are going to install the linux bootloader 'syslinux'. This bootloader needs a configuration file which is 'syslinux.cfg'. This is the file we just made by renaming 'isolinux.cfg' from the installCD. However we have to modify this file. Open the file 'syslinux.cfg' from the pendrive with your favorite texteditor. For instance : Adapt the content until you get this : The menu choice called 'Custom' was made the default so that when booting up you can just hit Enter to start your customized session. The essential difference is that the kernels and initrds have been moved out of the casper directory. Thus 'casper/initrd.gz' becomes 'initrd.gz'. Likewise for 'vmlinuz'. You can also copy and paste this text as making a new file 'syslinux.cfg'. Kubuntu difference : text editor 'kwrite' instead of 'gedit'. Kubuntu difference : replace 'preseed/ltsp.seed' by 'preseed/kubuntu.seed'. Edgy difference: replace 'preseed/ltsp.seed' by 'preseed/ubuntu.seed'. The last thing to do is installing the bootloader. Check if you have the 'syslinux' and 'mtools' package installed. If not install it ('sudo synaptic' and select from the package list or use 'apt-get'). First you need to unmount your usb stick : This command will install the bootloader on your pendrive : If you get the error: then you will need to install the mtools package. Reboot on the pendrive, change some settings, reboot again and check if the changes are kept (persistence check). So that is it. Do not forget to check if the computer you are going to use the pendrive on boots USB devices first (look in BIOS settings). Enjoy (k)ubuntu whereever you go.
Download a copy of the [http://h18000.www1.hp.com/support/files/serveroptions/us/download/23839.html HP format utility] for USB drives, this utility makes it as easy to format USB pen drives as it is to format floppies. Plug in your USB pen drive and use the HP format utility to format it with a FAT32 filesystem. Using a partitioning tool, create two partitions. The first is formatted with a FAT32 filesystem and needs to be about 650 MB. The second should occupy the remaining free space and should be formatted with the ext2 filesystem and is given the name "casper-rw". Note! Most DOS partitioning tools will create the partition name in uppercase (CASPER-RW). Since Linux is case-sensitive you need to do the formatting of the second partition in Linux. The persistent feature will not work if the partition name is in uppercase. See the Wiki for details. https://help.ubuntu.com/community/LiveCDPersistence
This is the same as described in the Linux section except for accessing the downloaded image. The way to do this is to mount the iso image file and copy the files that way. You can do this with NERO or [http://download.microsoft.com/download/7/b/6/7b6abd84-7841-4978-96f5-bd58df02efa2/winxpvirtualcdcontrolpanel_21.exe Windows VirtualCD]. You might want to do it this way if you don't want to burn a CD.
Go to http://syslinux.zytor.com/iso.php and download a copy of syslinux-3.11.zip for Windows. Extract the zip file contents and move the extracted folder to your favorite location on your hard drive. Open WordPad and edit the file syslinux.cfg as described in the Linux section. Open a command prompt and change directory to the location of the syslinux folder. For example, if you placed the folder on your desktop then: cd C:\Documents and Settings\(your user name)\Desktop\syslinux-3.11\win32 (by the way you DO know that command prompt has command completion just like in Linux (start entering characters and then press the TAB key to complete the entry)). Next write the bootsectors to the flash drive by entering the following command: syslinux -f X: --> where X: is replaced by the drive letter of your USB key. Be careful to pick the correct drive letter!
If you want to install the test releases of Edgy Eft, you might want to look at CustomizedInitrd. As syslinux does not support the "GFXBOOT" command the boot menu will lack some features, e.g. you cannot change the language before booting. You can specify a language and keyboard layout via kernel parameters, though. To boot into a German LiveCD environment, you would add the following to your "APPEND" lines in syslinux.cfg: Some USB keys don't have a master boot record. In these cases, the problem can usually be fixed by running Alternatively, if you haven't got lilo installed, use the 'install-mbr' command from the 'mbr' package: This may be my fault, but I created a Persistent pen drive from Ubuntu using these instructions and it worked perfectly, but I had installed an Edgy Beta, when I decided to update it to the final only a windows machine was available, follwing the windows instructions ( minus partitioning as that was still there from the previous install ) I do not get the normall Ubuntu prompt with a "custom" option at the top like before, instead I get a prompt with "Boot:" and I have to enter vmlinuz to boot, if I just hit return Ubuntu boots but something fails and it drops into a recovery console. Could somebody confirm that the windows directions are correct ( my suspicion is that it is because in Ubuntu you are using Ubuntu's custom version of syslinux while in windows you are using the "vanilla" version ) Also, the direction on where to find syslinux could be clearer, I found them at http://www.kernel.org/pub/linux/utils/boot/syslinux/ with no indication that the .zip file was indeed for windows, I tried the newest version at that time: http://www.kernel.org/pub/linux/utils/boot/syslinux/syslinux-3.31.zip and the exact version mentioned in the instructions http://www.kernel.org/pub/linux/utils/boot/syslinux/Old/syslinux-3.11.zip both gave the same result -Jordan U I successfully installed Edgy (final) to an USB drive, following the linux instructions but using syslinux-3.20 for Windows. Afterwards I installed GRUB in the MBR which also works fine. -JanSchlüter In my installation I can still use GRUB to load syslinux. Syslinux displays the ubuntu logo and a command prompt. I can enter memtest to boot Memtest86+ or press return to boot the ubuntu live environment. I didn't use the windows version of syslinux only, though - I tried ubuntu's version first which failed to create LDLINUX.SYS, then I tried the windows version. I (successfully) made a USB boot drive using these instruction and later saved the working partitions because I needed the drive for another purpose - on restoring the partitions and running syslinux again I couldn't get my drive to boot - after many hours of head-scratching and re-installing I found that the boot flag wasn't set! Just be aware that sometimes simple things can trip you up.. David C. cd ubuntuCD
cp -rf casper /media/edgy
cp -rf disctree /media/edgy
cp -rf dists /media/edgy
cp -rf install /media/edgy
cp -rf pics /media/edgy
cp -rf pool /media/edgy
cp -rf preseed /media/edgy
cp -rf .disk /media/edgy
cp isolinux/* /media/edgy
cp md5sum.txt /media/edgy
cp README.diskdefines /media/edgy
cp ubuntu.ico /media/edgy
cp casper/vmlinuz /media/edgy
cp casper/initrd.gz /media/edgy
cp install/mt86plus /media/edgy
cd /media/edgy
mv isolinux.cfg syslinux.cfg
You don't need to copy the symlinked folders over (/dists/stable, /dists/unstable, /ubuntu) - bernstein Making the pendrive bootable
gedit syslinux.cfg
DEFAULT custom
GFXBOOT bootlogo
APPEND preseed/file=preseed/ltsp.seed boot=casper initrd=initrd.gz ramdisk_size=1048576 root=/dev/ram rw quiet splash --
LABEL custom
menu label ^Start Ubuntu in persistent mode
kernel vmlinuz
append preseed/file=preseed/ltsp.seed boot=casper persistent initrd=initrd.gz ramdisk_size=1048576 root=/dev/ram rw quiet splash --
LABEL live
menu label ^Start or install Ubuntu
kernel vmlinuz
append preseed/file=preseed/ltsp.seed boot=casper initrd=initrd.gz ramdisk_size=1048576 root=/dev/ram rw quiet splash --
LABEL xforcevesa
menu label Start Ubuntu in safe ^graphics mode
kernel vmlinuz
append preseed/file=preseed/ltsp.seed boot=casper xforcevesa initrd=initrd.gz ramdisk_size=1048576 root=/dev/ram rw quiet splash --
LABEL check
menu label ^Check CD for defects
kernel vmlinuz
append boot=casper integrity-check initrd=initrd.gz ramdisk_size=1048576 root=/dev/ram rw quiet splash --
LABEL memtest
menu label ^Memory test
kernel mt86plus
append -
LABEL hd
menu label ^Boot from first hard disk
localboot 0x80
append -
DISPLAY isolinux.txt
TIMEOUT 300
PROMPT 1
F1 f1.txt
F2 f2.txt
F3 f3.txt
F4 f4.txt
F5 f5.txt
F6 f6.txt
F7 f7.txt
F8 f8.txt
F9 f9.txt
F0 f10.txt
cd ~
sudo umount /dev/sdX1
syslinux /dev/sdX1
don't know why, but i had to use the -f switch (syslinux -f /dev/sda1) - bernstein syslinux complained it couldn't create LDLINUX.SYS, but it worked in the Windows version (see below) - JanSchlüter sh: mcopy: command not found
syslinux: failed to create ldlinux.sys
Installing Ubuntu on USB pendrive using Windows
Preparing the USB pendrive
Installing Dapper or Edgy on the USB pendrive
Making the pendrive bootable
Comments
Maybe it only works in combination... -JanSchlüter locale=de_DE bootkbd=de console-setup/layoutcode=de console-setup/variantcode=nodeadkeys
lilo -M /dev/sdX
sudo apt-get install mbr
sudo install-mbr /dev/sdX