Create a larger casper-rw loop file in Linux

The following tutorial explains how to create a larger casper-rw loop file (or writable file) for your Ubuntu based flash drive install. For example on: Ubuntu, Xubuntu, Kubuntu, Lubuntu, Crunchbang or Linux Mint. A larger casper-rw loop file is particularly useful for those who have performed a Linux install to a large thumb drive using a Windows USB tutorial and need more persistent storage space for saving changes. The default casper-rw loop file we used in the Windows USB installation tutorials is only 1GB.

You will need to perform the following steps from a booted Linux system other than the USB Linux installation. Or simply boot your USB with persistence disabled by removing the persistent boot parameter.

Important: For Ubuntu based distributions from version 20.04 onward, use writable in place of casper-rw throughout this tutorial.

Note: Persistent file size (count) must be less than =< 4096 MB on a fat32 formatted flash drive due to the 4GB file size limitation of a fat32 partition.

Creating a NEW larger casper-rw overlay file

The following method will create a NEW casper-rw file that will replace the old one. If you want to resize an existing image see the next section.

  1. After your up and running in Linux, insert the flash drive that contains your casper-rw loop file
  2. Open a terminal
  3. Type the following into the terminal window and press enter
    dd if=/dev/zero of=casper-rw bs=1M count=4096

    (replacing 4096 with the "size in MB" you wish to use for saving changes persistently)

  4. Type the following into the terminal and press enter
    mkfs.ext3 -F casper-rw
  5. Copy the new casper-rw or writable file to your USB flash drive
  6. Restart your computer, booting from the USB flash drive and enjoy using the larger casper-rw loop block file you have just created.

Resize an existing casper-rw overlay file

The following method will allow you to resize your existing casper-rw image (expand casper-rw). You should create a backup just in case before proceeding.

  1. After your up and running in Linux, insert the flash drive that contains your casper-rw loop file
  2. Open a terminal and change directory (CD) to the location of your casper-rw file
  3. Type the following into the terminal window and press enter
    dd if=/dev/zero bs=1M count=4096 >> casper-rw

    (replacing 4096 with the size in MB you wish to increase the original size by)

  4. Type the following into the terminal window and press enter
    resize2fs casper-rw

If all goes well, you should now have a larger casper-rw overlay loop file to use for saving your persistent changes.