What is a casper rw loop file and why do I need it to make saving persistent on a USB flash drive?

l245c4l picture l245c4l · Apr 2, 2010 · Viewed 48.4k times · Source

Suppose I've installed Linux on my flash drive. Why do I need something like the casper loop file to make saving persistent? So files are being erased? Isn't the flash drive the same as actual hard disk drive? I'm a Linux noob so be patient.

Or it is because Linux on a flash drive is actually like live CD on a flash drive? Can it be installed just like it is installed on a hard disk drive?

Answer

Fordi picture Fordi · Oct 19, 2012

Live Linux off a USB stick is done by embedding a bootable, read-only filesystem image as a file on a USB stick and booting from that. This is done for a couple of reasons, the largest of which being that the stick remain readable / usable on other systems, but also because it means you can use the same stack of files to make a Live CD as a USB stick.

Normally when this is done, the RW portion is done via a ramdisk, however with a USB stick, you have the opportunity to store the mutable portion of the live system on the stick.

You may think, "well, why not just do it as a directory on the stick?" The reason for this is that a FAT32 filesystem doesn't have all the metadata that a Unix environment needs. You need to use something like ext2.

So what is a casper file? It's a file that has been treated like it's a hard drive partition. That's it. Instead of pointing mkfs.ext2 or mount at /dev/sda3 (a partition), you've pointed it at /mnt/sda3/casper-rw (a file).