System Administration Guide: Devices and File Systems

Creating and Deleting UFS Snapshots

When you use the fssnap command to create a UFS snapshot, observe how much disk space the backing-store file consumes. The backing-store file uses no space, and then it grows quickly, especially on heavily used systems. Make sure that the backing-store file has enough space to expand. Or, limit its size with the -o maxsize=n [k,m,g] option, where n [k,m,g] is the maximum size of the backing-store file.


Caution – Caution –

If the backing-store file runs out of space, the snapshot might delete itself, which causes the backup to fail. Check the /var/adm/messages file for possible snapshot errors.


For more information, see the fssnap_ufs(1M) man page.

ProcedureHow to Create a UFS Snapshot

Steps
  1. Become superuser or assume an equivalent role.

  2. Make sure that the file system has enough disk space for the backing-store file.


    # df -k 
    
  3. Make sure that a backing-store file of the same name and location does not already exist.


    # ls /backing-store-file
    
  4. Create the UFS snapshot.


    # fssnap -F ufs -o bs=/backing-store-file /file-system
    

    Note –

    The backing-store file must reside on a different file system than the file system that is being captured using UFS snapshots.


  5. Verify that the snapshot has been created.


    # /usr/lib/fs/ufs/fssnap -i /file-system
    

Example 24–1 Creating a UFS Snapshot

The following example shows how to create a snapshot of the /usr file system. The backing-store file is /scratch/usr.back.file. The virtual device is /dev/fssnap/1.


# fssnap -F ufs -o bs=/scratch/usr.back.file /usr
/dev/fssnap/1

The following example shows how to limit the backing-store file to 500 Mbytes.


# fssnap -F ufs -o maxsize=500m,bs=/scratch/usr.back.file /export/home 
/dev/fssnap/1

ProcedureHow to Display UFS Snapshot Information

You can display the current snapshots on the system by using the fssnap -i option. If you specify a file system, you see detailed information about that snapshot. If you don't specify a file system, you see information about all of the current UFS snapshots and their corresponding virtual devices.


Note –

Use the UFS file system-specific fssnap command to view the extended snapshot information as shown in the following examples.


Steps
  1. Become superuser or assume an equivalent role.

  2. List all current snapshots:

    For example:


    # /usr/lib/fs/ufs/fssnap -i
    Snapshot number               : 0
    Block Device                  : /dev/fssnap/0
    Raw Device                    : /dev/rfssnap/0
    Mount point                   : /usr
    Device state                  : idle
    Backing store path            : /var/tmp/snapshot3
    Backing store size            : 256 KB
    Maximum backing store size    : Unlimited
    Snapshot create time          : Wed Oct 08 10:38:25 2003
    Copy-on-write granularity     : 32 KB
    Snapshot number               : 1
    Block Device                  : /dev/fssnap/1
    Raw Device                    : /dev/rfssnap/1
    Mount point                   : /
    Device state                  : idle
    Backing store path            : /tmp/bs.home
    Backing store size            : 448 KB
    Maximum backing store size    : Unlimited
    Snapshot create time          : Wed Oct 08 10:39:29 2003
    Copy-on-write granularity     : 32 KB
  3. Display detailed information about a specific snapshot:

    For example:


    # /usr/lib/fs/ufs/fssnap -i /usr
    Snapshot number               : 0
    Block Device                  : /dev/fssnap/0
    Raw Device                    : /dev/rfssnap/0
    Mount point                   : /usr
    Device state                  : idle
    Backing store path            : /var/tmp/snapshot3
    Backing store size            : 256 KB
    Maximum backing store size    : Unlimited
    Snapshot create time          : Wed Oct 08 10:38:25 2003
    Copy-on-write granularity     : 32 KB

Deleting a UFS Snapshot

When you create a UFS snapshot, you can specify that the backing-store file is unlinked. An unlinked backing-store file is removed after the snapshot is deleted. If you don't specify the -o unlink option when you create a UFS snapshot, you must delete the backing-store file manually.

The backing-store file occupies disk space until the snapshot is deleted, whether you use the -o unlink option to remove the backing-store file or you delete the file manually.

ProcedureHow to Delete a UFS Snapshot

You can delete a snapshot either by rebooting the system or by using the fssnap -d command. When you use this command, you must and specify the path of the file system that contains the UFS snapshot.

Steps
  1. Become superuser or assume an equivalent role.

  2. Identify the snapshot to be deleted.


    # /usr/lib/fs/ufs/fssnap -i
    
  3. Delete the snapshot.


    # fssnap -d /file-system
    Deleted snapshot 1.
  4. (Optional) If you did not use the -o unlink option when you created the snapshot, manually delete the backing-store file.


    # rm /file-system/backing-store-file
    

Example 24–2 Deleting a UFS Snapshot

The following example shows how to delete a snapshot and assumes that the -o unlink option was not used.


# fssnap -i
    0    /    1    /usr
# fssnap -d /usr
 Deleted snapshot 1.
# rm /scratch/usr.back.file