I have been enjoying my Ubuntu 7.10 Live Persistent USB for many months now. I use it to quickly and easily install Ubuntu on desktops, we also sell them at TheLinuxStore.ca. But it seems persistence was broken in 8.04. Turns out to be a simply mistake, but there are many steps to fix it. I have seen many people asking about this so I thought I would write a how to. This post will start from the beginning and explain how to make an Ubuntu 8.04 Bootable Live USB from scratch.
Assumptions:
You have at least a 1GB USB thumb drive
You have the ubuntu-8.04-desktop-i386.iso file handy
You are running Ubuntu on your desktop
Reconstructing the Ubuntu Live CD for USB
Step One - Make a directory to store the restructured CD
cd /home/ryan/
mkdir hardy-usb
Step Two - Mount the Ubuntu iso and copy required files
Create a mount point and mount the ubuntu iso. The copy the required files.
sudo mkdir /mnt/iso
sudo mount -o loop ubuntu-8.04-desktop-i386.iso /mnt/iso
cd /mnt/iso
cp -rf casper dists install pics pool preseed .disk isolinux/* md5sum.txt README.diskdefines casper/vmlinuz casper/initrd.gz install/mt86plus /home/ryan/hardy-usb/
Step Three - Rename and modify isolinux.cfg
cd /home/ryan/hardy-usb/
mv isolinux.cfg syslinux.cfg
sudo gedit syslinux.cfg
Copy and paste the following into you syslinux.cfg file:
DEFAULT usblive GFXBOOT bootlogo APPEND file=/preseed/ubuntu.seed boot=casper initrd=initrd.gz quiet splash -- LABEL usblive menu label ^Start Ubuntu and save changes to USB kernel vmlinuz append file=/preseed/ubuntu.seed boot=casper persistent initrd=initrd.gz quiet splash -- LABEL live menu label ^Try Ubuntu without any change to your computer kernel vmlinuz append file=/preseed/ubuntu.seed boot=casper initrd=initrd.gz quiet splash -- LABEL live-install menu label ^Install Ubuntu kernel vmlinuz append file=/preseed/ubuntu.seed boot=casper only-ubiquity initrd=initrd.gz quiet splash -- LABEL memtest menu label Test ^memory 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
Step Four- Time to fix the initrd filesystem
There is a simple error with the casper script in the initrd filesystem. We will need to extract, edit the casper script and re-pack the initrd.gz.
cd /home/ryan/hardy-usb/
mkdir initrd_old
cd initrd_old
gunzip < ../initrd.gz | cpio -i --make-directories
cd scripts
gedit casper
Now, search for "mount ${cowdevice} -t ${cow_fstype} -o rw,noatime,mode=755 /cow". Remove "mode=755". So the line should look like this:
mount ${cowdevice} -t ${cow_fstype} -o rw,noatime /cow || panic "Can not mount $cowdevice on /cow"
After your have modified and saved the casper script, we need to repack the initrd file system.
cd ..
find ./ | cpio -H newc -o > ../initrdnew
cd ..
rm initrd.gz
mv initrdnew initrd
gzip initrd
Now the new initrd.gz is modified and ready to go. Time to prepare the USB.
Preparing and installing onto the USB
Step One - Find the USB device
Plug in your USB thumb drive. Once your USB has been mounted, type mount on the command-line to determine what device your USB drive is. It will likely be on the bottom of the list. For example:
/dev/sdb1 on /media/KINGSTON type vfat (rw,nosuid,nodev,uhelper=hal,shortname=mixed,uid=1000,utf8,umask=077,flush)
This shows that my USB drive is /dev/sdb. Once you know your USB drives device make a note of it, we will need it for the rest of this how-to.
Now, unmount the device, we need to partition the drive.
sudo umount /media/KINGSTON
Step Two - Re-partition the USB drive.
Now we need to re-partition the USB drive so one partition has the Live system and one partition will contain the read/write partition.
sudo fdisk /dev/sdb
Before we make any changes, you can double check that you are modifying the correct device. Type 'p'. This will show you the current partition table. My fresh 4.0GB Kingston drive show the following:
Command (m for help): p
Disk /dev/sdb: 4045 MB, 4045930496 bytes
120 heads, 55 sectors/track, 1197 cylinders
Units = cylinders of 6600 * 512 = 3379200 bytes
Disk identifier: 0x04030201
Device Boot Start End Blocks Id System
/dev/sdb1 1 1198 3951100 b W95 FAT32
You can see that fdisk tells me the drive is 4045MB in size. That is correct so I can carry on. If you see a size you not expecting, type 'q' to quit without saving changes.
Now that we have double checked we are modifying the correct device, lets delete the current partitions and create the partitions we need.
Type the following commands info fdisk.
d < deletes the current partition
n < create new partition
p < create a primary partition
1 < partition number of 1
enter < start at first cylinder
+770M < make it 770MB in size
a < make partition bootable
1 < specify partition
t < change partition type
6 < to FAT16
n < new partition
p < primary
2 < partition #2
enter < accept default
enter < use all remain space
p < review the partition changes
Here is what mine look like:
Command (m for help): p
Disk /dev/sdb: 4045 MB, 4045930496 bytes
120 heads, 55 sectors/track, 1197 cylinders
Units = cylinders of 6600 * 512 = 3379200 bytes
Disk identifier: 0x04030201
Device Boot Start End Blocks Id System
/dev/sdb1 * 1 229 755672+ 6 FAT16
/dev/sdb2 230 1197 3194400 83 Linux
w < write changes to disk
Step Three - Format filesystems
Sometimes after leaving fdisk the USB remounts itself, if this happens, unmount it. Now, lets format the partitions.
sudo mkfs.vfat -F 16 -n UbuntuLive /dev/sdb1
sudo mkfs.ext2 -b 4096 -L casper-rw /dev/sdb2
Step Four - Copy the Live USB filesystem to USB
We need to mount the FAT16 filesystem and copy the USB files.
sudo mount /dev/sdb1 /mnt/usb
cd /home/ryan/hardy-usb/
sudo cp -rf .disk * /mnt/usb
sudo umount /mnt/usb
Ignore the 2 "cannot create symbolic link" errors.
Step Five - Install Syslinux and make USB bootable
sudo syslinux -f /dev/sdb1
If you get a command not found, you probably need to install syslinux, if so enter the following command to get it installed, sudo apt-get install syslinux mtools
That's it! Reboot and test it. Hope this helps. If you have any issues, leave a comment.

44 Comments Received
wouhouuu !!!
You saved my life !!
Great page, I’ve tried since yesterday evening to get this version work on my USB hard drive, but I was only able to boot in a live non-persistent mode…
I tweak the initrd.gz as you mentionned (by removing the “mode=775″ part, which was “mode=755″ in mine…) Anyway it worked and I’m so pleased now !
Thanks thanks thanks !!!
Now I’ve just one last thing to get rid of the language selection at the boot (I want it in french by default, I’ve added the string “locale=fr_FR bootkbd=fr console-setup/layoutcode=fr” after the “GFXBOOT bootlogo” and the first “APPEND ” in the /syslinux.cfg file, but it did’nt helped. If anyone knows??
Please excuse my poor english…
Very nice. Easy to follow and it works.
Only issue is that it’s booting to a prompt (all you have to do is hit enter) rather than the syslinux.cfg menu. I’m not getting the language selection menu either, which is good.
hey, im sorry but i dont understand the step where you ask to Copy and paste the following into you syslinux.cfg file:
code-code–code
do i have to DELETE the previous text in the file, or just ADD it
at the end???
—-
You need to replace the content of the file with the code shown.
Do you think I would be able to do this with the mac ppc verion of the hardy heron iso?
And then boot from the usb drive onto an oldworld powerbook g3 wallstreet?
(many sincere thanks in advance for your help)
—
I am not sure. I don’t see any reason why not. But I am also not too familiar with Macs.
thanks for the help dude, now I have another problem, can i do this same steps in a mp4 player? it also works as a usb stick, but it has 4gb, I’ve tried, but it just wont boot, i think its because of the firmware :s any ideas ?
—
Sorry man, no ideas. Probably a firmware issue.
Thanks…this works like a charm..
Great guide - thanks… but I have a problem… I have followed the guide pretty exactly, but I have been unable to actually make it work. Every computer I have tried fails to boot from my USB drive. One of the computers I have tested it with says something like “No operating system found on pendrive. Remove pendrive and reboot.” All others never even recognize its presence, even though I am quite sure they support booting from USB. They are all x86 and all, so I can’t see what I’ve done wrong. Thanks in advance for any help you can give me!
—
Try “lilo -M /dev/sdx”. That will write a new boot record the that device. Also, make sure you format and copied to the correct device.
Excellent! Thank you!
Can I put grub on the stick and have both the i386 and amd64 liveCD images bootable from the same stick?
–
I do not see why not. If I ever make a USB or bootable disc like that, I will be sure to post a how-to.
Worked great after an initial glitch: On my thumb drive, the geometry is such that 770M only yields 752336 blocks for the FAT16 partition, and that wasn’t quite enough to store everything. I bumped it until it was larger than your value (755672 above) and then everything installed fine. BTW, the “mode” value I removed was also 755, not 775.
Thanks for the excellent instructions. I’ve got you bookmarked!
Two points:
1) In the “gedit syslinux.cfg” step, save was not enabled on this file. I did a “chmod +w syslinux.cfg” and then edited and saved it. Is this right?
2) In “sudo cp -rf .disk * /mnt/usb” I get the following:
bruno@bruno-pc:~/hardy-usb$ sudo cp -rf .disk * /mnt/usb
cp: cannot create symbolic link `/mnt/usb/dists/unstable’: Operation not permitted
cp: cannot create symbolic link `/mnt/usb/dists/stable’: Operation not permitted
Is this normal?
Great tutorial anyway.
One more I forgot:
In “syslinux -f /dev/sdb1″ I get a Permission Denied, so I did a “sudo syslinux -f /dev/sdb1″. Is it ok to do that? I’m kind of a newbie when it comes to linux…
Thanks again
–
Noted and how-to updated. Thanks.
Can the UbuntuLive be /dev/sdc2 and casper-rw be /dev/sdc3, with /dev/sdc1 being a FAT32 partition for files?
I’d like to use a 8GB Kingston as a bootable persistent ubuntu, but also use it for files in windows. As Windows only sees the first partition of a usb drive that would be a simple solution.
So the drive would be:
/dev/sdc1 5GB FAT32 Files
/dev/sdc2 770MB FAT16 UbuntuLive
/dev/sdc3 1.2GB ext2
Any ideia with that could work? Any extra steps?
Thanks
Thanks for the great tutorial, almost there although i have probably made a mistake somewhere. My USB Boots and runs the Live CD. However when i run keeping the changes to the USB (Persistent mode?) i t stops booting and drops to the command line while trying to set up the RAM Disk. Any Ideas?
Thanks Again
I’m far afield with only my mac and trying to build a hardy live stick from my mac, which is a PPC (no boot camp)
I think I got most of this to work from a PPC Mac with OS X 10.5 (specifically an iBook G4). There are significant nomenclature differences all along the way and I’m still not sure it works because I haven’t figured out how to run syslinux.
*instead of mounting the .iso, I used hdid
*instead of gedit I used TextWrangler and vi.
*the fdisk nomenclature is fairly different, the interactive mode seems to ask questions in a different order, and doesn’t support byte-sector-chs conversions so I had to calculate them, which got a bit confusing for a while, e.g., the fdisk command assigned an arbitrary cylinder-head-sector geometry?!
*OS X uses newfs which replaces mkfs in newer BSD systems; newfs has an entirely different syntax and must be preceded by disklabel. The newfs command is apparently built on top of mkfs, but don’t get your hopes up, you can’t call mkfs directly.
*Finally, again, I haven’t figured out how to run syslinux from this PPC mac. syslinux isn’t available for mac as far as I can tell, even in Fink. I downloaded the package and the readme says it builds in Linux using nasm. If I was running an intel laptop I’d even install hardy on my laptop, but making U-boot for my PPC is, at least for now, a bridge too far. Any suggestions?
Also, correct me if I’m wrong, but I’m pretty sure the initrd_old directory can be removed, as can the unused .tr and .hlp files, yes?
I get an initramfs prompt upon boot… am I missing something? I am using a xubuntu distro but the procedure should be the same right?
Ryan
A big thank you for you detailed teaching that even a n00b like me can understand and follow through. You have single handedly elevated my Linux skill through the use of CLI like “gunzip” “cpio” etc. Your unselfish share has made the Linux community very solid.
Just a suggestion to n00b like me at every step if you will either do a “ls” or “pwd” to confirm the directory you are supposed to be at. Especially after such “cd ..” command then there won’t be any problem.
As for the dreaded LOOP_SET_FD error just change the directory of the 8.04iso image to somewhere other than where it was then the -o loop command should be dandy.
I have even managed to put a partition on my macbook pro as a persistence and have been enjoying it without having to use another CD. I will try to post the method if anyone is interested. Macintosh are notorious for it EFI being intolerant to other OS.
Thank you again Bryan.
One more question: I seem to be killing thumbdrive filesystems on shutdown. When you shutdown UbuntuLive and it says remove the disk from the tray and press enter, should I remove the thumbdrive and press enter? or leave it in? Any other suggestions?
Hi Ryan,
thanks for the helpful description. I combined it with the tutorial at
https://help.ubuntu.com/community/LiveCDCustomization
to get other important packages in. Especially I wanted to have an encrypted casper-rw, which didn’t work out (I gave up). But I stumbled over another problem: having installed cryptsetup, generated a new initrd which is needed while cryptsetup changes init-files everything worked fine until I encrypted the third partition, which is just a spare one, on the thumb. When there exists an encrypted partition, booting will end up in a busybox.
Would be very nice, if you had an idea….
but thanks anyway for the tut!!
Alex
Thanks for the tute mate. Just a couple of questions - would this work for the DVD ISO also? And how do we make a USB drive that boots both 32 and 64 bit versions of the kernel?
Keep it rollin’
Martin
Hello,
I followed the instructions, but when I boot the USB flash drive I got Grub error Stage 1.5.
I read some suggestion to install grub.
If so, can I just add grub or should I install grub first and then repeat the whole installation process ?
Regards,
I dont like using grub. When I goto a computer that has a diff SATA hard drive setup than mine it wont boot, gives grub errors because of device naming I assume. What do I need to do to use syslinux as the bootloader? Until then looks like the guys over at https://launchpad.net/liveusb are getting close to making it easy. Thanx
Very great tutorial.
Would you agree me to translate it in french? I would, of course, put a link to your post and clearly explain i just translated it.
I’ve tried installing Ubuntu 8.04 to a persistent USB a few of different ways and each time my laptop boots to a single cursor in the upper left hand corner and which blinks, but nothing other than a reboot will work afterwards.
I’ve successfully booted other linux distros off of the USB drive with this laptop, so I know that isn’t the problem. I would really love to use Ubuntu, though. Should I just try version 7 instead or am I missing something?
I think I’m on attempt number six or seven by now. Partitions look fine and all of the files are copied over. I’ve tried this way, doing it from a LiveCD, doing it from windows. I’m running out of option and all give the same result so far.
Hi Ryan,
I have another problem regarding installing Ubuntu 8.04 to an external usb hdd. I was wondering if you could help me. Tell me how to contact you so I can explain my problem.
Many thanx already
Pavan
thanks!
learned a lot.
got stuck in grub on error 21 though. (can’t find grub.conf or even the /boot). makes me feel quite stupid…
i’m trying to do this with xubuntu.
thanks alot
Your guide is wonderful for setting this up, but realizing I have another 6-7gb of space on my thumb drive I was wondering if it would be possible to combine several live distro’s into one menu/thumbdrive.
I have separately gotten all three(backtrack3usb, partmagic, ubuntu8.04) to work with syslinux off the thumbdrive, but looking at the individual syslinux.cfg file’s for each I cannot really see much consistency between them aside from file names. This is fairly offtopic for your post so I will understand if you would rather not dip too deeply into my question.
I got it to work with Mint 5 Elysa.
My syslinux.cfg is:
default vesamenu.c32
timeout 100
menu background splash.jpg
menu title Welcome to Linux Mint 5 Elyssa
menu color border 0 #112da323 #00000000
menu color sel 7 #ffffffff #332da323
menu color title 0 #ff2da323 #00000000
menu color tabmsg 0 #ff2da323 #00000000
menu color unsel 0 #ff2da323 #00000000
menu color hotsel 0 #ff000000 #ffffffff
menu color hotkey 7 #ffffffff #ff000000
menu color timeout_msg 0 #ffffffff #00000000
menu color timeout 0 #ffffffff #00000000
menu color cmdline 0 #ffffffff #00000000
menu hidden
menu hiddenrow 5
label live
menu label Start Linux Mint Persistent
kernel vmlinuz
append file=/preseed/mint.seed boot=casper persistent initrd=initrd.gz quiet splash –
menu default
label xforcevesa
menu label Start Linux Mint in compatibility mode
kernel vmlinuz
append file=/preseed/mint.seed boot=casper xforcevesa persistent initrd=initrd.gz ramdisk_size=1048576 root=/dev/ram rw noapic noapci nosplash irqpoll –
label memtest
menu label Memory Test
kernel memtest
label local
menu label Boot from local drive
localboot 0×80
The only problems I have so far:
1) The install icon reappears every restart. I deleted it every time.
2) The time never stays in the correct timezone after restart.
3) Cannot get the EnyNG program to install the ATI drivers.
Thanks,
Paul
i followed all of the instruction
when i booting i got error message like
“Boot error”
i don’t know what is going on ?
i always entry BusyBox. Why?
Great tutorial Ryan!
I have one question though: I would like to install Ubuntu on a usb key but on the second partition.
In fact the first partition would be use as a normal usb key (to store data readable by Windows).
Is it possible to do that and is there any limitations?
I heard the boot sector should be in the first 1024 cylinders of the disk. Is that true?
cheers!
Nice guide. Thanks much. I’m actually writing this comment from the Hardy Live USB Install. Confirmed definitely working on Acer Aspire 3680, Atheros wireless and all.
The great tutorial…….
Very nice. Easy to follow and it works….
GOOooooooooo……D
Ryan,
you forgot the MBR.
I tried this a couple of times and couldn’t get past a GRUB error on booting. From pendrivelinux.com I found that the drive needs an MBR to boot, which can be done with “lilo -M /dev/sdX”.
thanks, Mike
I followed your howto, and my 8gb thumbdrive would not create the partitions. Instead of /dev/sdb1 and /dev/sdb2, it only showed /dev/sdb1p1 and /dev/sdb1p2. I was not able to target these devices when trying to make filesystems. I tried my 4gb drive and it worked like a charm. I am wondering if anyone else came across this and what did you do to get around it? I sure would love to use my 8gb drive as an all around rescue drive, 4gb would not be enough.
Thanks for the how to though, i was about to give up.
Sean
Hi, thanks for the info. It worked with my 8GB Nexus thumbdrive, but it ran VERY slow, about 1 hour to load. It works normally after “syslinux -sf /dev/sdb1″; added using option -s for older/stupid bios.
I followed the tutorial to the letter but when i get to the last few steps i get these errors and do not know how to fix them.
mills@mills-laptop:~/hardy-usb$ sudo mount /dev/sdb1 /mnt/usb
mount: mount point /mnt/usb does not exist
Any help would be awesome. Thanks in advance.
Aesop
—
The mount point does not exist. Use the following command to create a mount point:
sudo mkdir /mnt/usb
Using syslinux (via dd if=path/to/mbr.bin of=/def/device) to set the MBR is much more efficient and reliable than using: lilo -M /dev/sdx
The GUFI installer uses it for both flash and hard drive installs instead of lilo, which is then not even required to be installed:
http://webpath.net/gufi/support/index.php?wiki=RestoreDisc_Install
Pingback & Trackback
Leave A Reply