Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I want to install Ubuntu to a USB hard drive so that it will run on all systems, that can run the LiveCD and store persistent data on a regular ext4 partition rather than a casper-rw file. In every other way it should behave like a regular Ubuntu installation.

The problem

With Startup Disk Creator one is able to put the LiveCD image on a USB-device. Changes can be made persistent but are stored in a file that is limited to a few GB in size. Said persistent file (additionally to being size restricted) has the problem that it isn't readable like data on a normal partition.*

My question

So how do I get the LiveCD on a USB disk in such a way that the changes are stored in a normal partition rather than a persistence file? Also the persistent changes shouldn't be restricted to a few GB in size but use whole partition of many 100 GB if need be.

I suspect there is a tutorial out there for this, but my google-fu is just not good enough to find it.

tl;dr:

Sytem should run on all hardware configurations, have full functionality of the LiveCD and be stored on a regular ext4 partiton without using ramdisks and casper-rw. FU casper-rw.


*I know one could mount the casper-rw file from another OS and get to the data this way but that's a hassle.

share|improve this question
    
Why not install to the USB stick the regular way? Run a live CD and set that as your root partition. (More hassle than a live-CD setup, to be sure, but easy enough.) –  jpaugh May 17 '12 at 12:27
    
Because the version on the live-CD is not hardware-specific and most of all it has the option to install ubuntu to another device. –  con-f-use May 17 '12 at 13:11
    
Additional questions: How do I make changes to the fstab persistent? The answer in askubuntu.com/q/56719/17789 seems to be outdated. –  con-f-use Aug 28 '12 at 12:00
add comment

2 Answers

up vote 9 down vote accepted
+100

This is very easy to do, although the "casper-rw" name will still show up once :)

  1. Your target USB disk must have at least two partitions; I recommend using Gparted to create a new partition table.

    • The first partition must be vfat/FAT32, minimum size 750 MB (or more if you are using a LiveDVD image).
    • The second partition should be ext4, sized to whatever you want your persistent storage to be (no limits), but it must be labeled casper-rw (all lower case, no quotes)

    enter image description here

    • You can, of course, add third, fourth, extended/logical partitions, etc. if you would like to.

    Note: I prefer to use Unetbootin because it makes editing the syslinux config easy. You can use your own USB creator, but should then modify the below steps appropriately.

  2. Use Unetbootin to write your chosen LiveCD ISO to the first (vfat) USB partition.

    • Put a tiny size for Unetbootin's persistence option (say, 10 MB) to make life easier; don't worry, we won't actually be using this casper-rw file.

    enter image description here

  3. Once everything is done, the final step is to delete the small casper-rw file created on the vfat partition you installed the LiveCD on, so that the large ext4 casper-rw partition is used instead. Mount this partition (here, sdb1), and delete /casper-rw.

  4. Persistence (via the persistent kernel option) should already be set up if you used Unetbootin, so safely eject the USB and you're ready to go!

share|improve this answer
    
Thanks alot, I will try when I have the chance to and then reward you the bounty if all worked fine. –  con-f-use Aug 27 '12 at 17:20
    
No hurry, please take your own time and test this out. And let me know if you have any problems/questions in the comments :) –  izx Aug 27 '12 at 17:23
    
Is there any reason not to make those partitions extended? –  con-f-use Aug 27 '12 at 17:29
    
I thank you very much, it did work. Any idea if it works with ntfs/fat32-partitions as casper-rw as well? I suppose not... –  con-f-use Aug 27 '12 at 18:54
1  
No, the partition must be ext2/ext3/ext4...you can however have additional NTFS partitions that will let you boot WinPE, etc. –  izx Aug 27 '12 at 21:17
show 1 more comment

For what it is worth the following is how I make a Persistent flash drive:

Boot Live CD or Live USB. Plug in flash drive. Start gparted.

Create 2 GB FAT32 partition, (on the left side of the bar). (size is optional, extra space can be used for file storage and transfer to Windows machines).

Create a 4 GB ext2 partition to the right of this, labeled it "casper-rw". (ext3 and ext4 also work).

Create a partition in the remaining space and label it "home-rw". (optional, creates a separate home partition).

Close gparted. Un-mount and re-mount flash drive. Start "Create a live usb startup disk", (usb-creator). Select "Discard on shutdown". Press "Make Startup Disk. When usb-creator finishes, Go to the root folder of your Live USB Enter the syslinux directory, (or for UNetbootin the root directory). Make the syslinux.cfg file writeable Replace the contents of the file syslinux.cfg with:

default persistent
label persistent
  say Booting a persistent Ubuntu session...
  kernel /casper/vmlinuz
  append  file=/cdrom/preseed/ubuntu.seed boot=casper persistent initrd=/casper/initrd.lz quiet splash noprompt --

Shutdown, remove CD, reboot.

First time booting go to users and groups and create an account with yourself up as an Administrator, with password if desired.

Note: The above code will bypass the Try/Install and Language screens.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.