28

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.

4
  • 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, 2012 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, 2012 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, 2012 at 12:00
  • Nowadays syslinux, (6.03), will install to NTFS so there is no more 4GB FAT32 size limit. See YUMI Aug 15, 2017 at 20:34

3 Answers 3

28
+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, and minimum size 750 MB (or more if you are using a live DVD 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 configuration easy. You can use your own USB creator, but you should then modify the below steps appropriately. Also note that GParted 0.18.0 seems to have problems partitioning the USB stick. So if you have the issue then use live GParted CD for partitioning.

  2. Use UNetbootin to write your chosen live CD 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 live CD 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!

PS: If you don't want to use UNetbootin and you are using the "Startup disk creator" in Ubuntu then you need to do some edits to your syslinux/txt.cfg file as follows:

default live
label live
  menu label ^Try Ubuntu without installing
  kernel /casper/vmlinuz.efi
  append  file=/cdrom/preseed/ubuntu.seed boot=casper cdrom-detect/try-usb=true persistent noprompt floppy.allowed_drive_mask=0 ignore_uuid initrd=/casper/initrd.lz quiet splash --
label live-install
  menu label ^Install Ubuntu
  kernel /casper/vmlinuz.efi
  append  file=/cdrom/preseed/ubuntu.seed boot=casper only-ubiquity cdrom-detect/try-usb=true persistent noprompt floppy.allowed_drive_mask=0 ignore_uuid initrd=/casper/initrd.lz quiet splash --
label check
  menu label ^Check disc for defects
  kernel /casper/vmlinuz.efi
  append  boot=casper integrity-check cdrom-detect/try-usb=true persistent noprompt floppy.allowed_drive_mask=0 ignore_uuid initrd=/casper/initrd.lz quiet splash --
label memtest
  menu label Test ^memory
  kernel /install/mt86plus
label hd
  menu label ^Boot from first hard disk
  localboot 0x80
8
  • No hurry, please take your own time and test this out. And let me know if you have any problems/questions in the comments :)
    – ish
    Aug 27, 2012 at 17:23
  • Is there any reason not to make those partitions extended?
    – con-f-use
    Aug 27, 2012 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, 2012 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.
    – ish
    Aug 27, 2012 at 21:17
  • 3
    this solution didn't work while installing LXLE via Unetbootin. It gets stuck in a screen that says Busybox and a pront with (initramfs) Sep 27, 2015 at 19:55
3

Persistent partitions have not worked with syslinux type installs such as SDC, UNetbootin, Rufus, etc since 14.04, (unless the partition is located on a separate drive). An attempt boot will end with BusyBox.

Syslinux 6.03 offers full support for NTFS, (and many other fs), so there is no longer a 4GB persistent file size limit required to satisfy FAT32. YUMI uses Syslinux 6.03 as does RUFUS.

https://www.pendrivelinux.com/yumi-multiboot-usb-creator/

https://rufus.akeo.ie/

Mkusb is a grub2 type bootable flash drive maker that uses a FAT32 partition for boot, a write only ISO9660 partition for the OS, a ext4 casper-rw partition for persistence and a NTFS data partition accessible to both Linux and Windows.

https://help.ubuntu.com/community/mkusb

It should satisfy your specification.

0
0

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.

2
  • this solution didn't work while installing LXLE via Unetbootin. It gets stuck in a screen that says Busybox and a pront with (initramfs) Sep 27, 2015 at 20:22
  • @luisgonzalez Since 14.04 persistent partitions have not worked with syslinux type installs, (SDC, UNetbootin,Universal), persistent partitions do work with grub2 type installs, (mkusb). Using mkusb is much easier than any of the answers above. Nov 29, 2016 at 7:01

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .