LinuxCommandLibrary

casper-snapshot

Create live system snapshots

SYNOPSIS

casper-snapshot [target_directory]

PARAMETERS

target_directory
    The optional directory where the SquashFS snapshot of the live session's changes will be saved. For example, if you want to save it to a USB drive mounted at /media/usb, you might specify /media/usb/casper-rw or /media/usb/changes.squashfs (the tool typically creates a .squashfs file inside this directory). If not specified, the command might use a default location, typically within the live environment's temporary storage, or behave differently depending on the casper version and configuration, sometimes requiring manual setup or erroring out if no suitable default is found.

DESCRIPTION

casper-snapshot is a utility included in the casper package, primarily used in Ubuntu-based live environments. Its main function is to capture and save the changes made to the filesystem of a running live session. These changes, which occur in a union filesystem (like overlayfs), are consolidated into a SquashFS image. This snapshot can then be utilized for several purposes: to maintain persistence across reboots in a live USB, or to create a customized live ISO containing the modifications. It essentially allows users to preserve their work and configurations from a volatile live session, transforming temporary changes into a persistent state.

CAVEATS

Caveats and Limitations:
Requires a running casper live session environment to function correctly.
Only captures changes made on top of the base read-only filesystem, not the entire system.
The size of the generated snapshot depends on the volume of changes; ensure sufficient free space in the target_directory.
The generated snapshot file (.squashfs) does not automatically enable persistence; it must be correctly configured with boot options (e.g., 'persistent' or 'casper-rw') for the live system to load it on subsequent boots.
Directly saving to a FAT32 filesystem may cause issues with large files (>4GB) or proper file permissions due to FAT32 limitations. Consider using ext2/3/4 filesystems for the target.

OUTPUT FILE

The command typically creates a SquashFS file (e.g., casper-rw or changes.squashfs) within the specified target_directory. This file contains the compressed filesystem changes. The exact filename might vary depending on the casper configuration or the specific method of invocation.

INTERNAL MECHANISM

casper-snapshot works by identifying and packaging the differences between the current live filesystem (which uses a union mount to combine a read-only base with a writable overlay) and the original read-only base. It leverages tools like mksquashfs internally to compress these changes into a single, efficient SquashFS image.

HISTORY

The casper-snapshot command, along with the broader casper framework, was developed as a crucial component of Ubuntu's efforts to create robust and user-friendly live CD/USB environments. Its primary goal was to address the challenge of persistence in live sessions, allowing users to save their work and configurations without having to install the operating system. It has been a staple tool for 'remastering' custom Ubuntu ISOs and enabling persistent live USB drives since the early days of Ubuntu.

SEE ALSO

casper(7), mksquashfs(1), unsquashfs(1)

Copied to clipboard