Back to the main page

UFS snapshot

Basically, a snapshot is read-only copy of a file system (for the purpose of backup). 

The command fssnap creates snapshot of the UFS file system. 

More precisely, fssnap creates virtual device and backing-store file. 
Virtual device acts like real device and can be backed up. 
Backing-store file contains copies of pre-snapshot data (files) that have been changed since snapshot creation. 

So now for example, when you have virtual device (created while snapshot was taken), you can use say ufsdump command to backup FS. 
Before fssnap was invented, you had to bring system in the single user mode and then use ufsdump. 
Now when you have snapshot, you can back it up, while FS is mounted and do its work. 

Tips:

1. UFS snapshot isn't persistent across reboots (but virtual device and backing-store are still in the system, except they are not specified as unlinked)
2. During snapshot creation, system performance (write, not read) can be degraded. 
3. Initially backing-store file is zero and grows when FS data is changing. 
4. Backing-store file must be located out of FS that is being snapshoot. 

First always check if any snapshot exist and its state. Below command list all snapshots that exist in the system. 
# fssnap -i (no snapshot for now)

# fssnap -F ufs -o bs=/backing-store-.0 /.0
/dev/fssnap/0

# fssnap -i
0	/.0
Not much info with this fssnap command. # which fssnap /usr/sbin/fssnap Let's use UFS specific fssnap command (gives info we want to see). # diff /usr/lib/fs/ufs/fssnap /usr/sbin/fssnap Binary files /usr/lib/fs/ufs/fssnap and /usr/sbin/fssnap differ
# /usr/lib/fs/ufs/fssnap -i /.0
Snapshot number               : 0
Block Device                  : /dev/fssnap/0
Raw Device                    : /dev/rfssnap/0
Mount point                   : /.0
Device state                  : idle
Backing store path            : /backing-store-.0
Backing store size            : 0 KB (initially zero, but grows when /.0 is changing)
Maximum backing store size    : Unlimited
Snapshot create time          : Thu Nov 19 16:18:44 2009
Copy-on-write granularity     : 32 KB
Let's check snapshot persistence across reboot. Reboot the system.
# fssnap -i
# fssnap -i /.0
Shows nothing, but backing-store file is still here (unlink option hasn't been used).
# fssnap -F ufs -o bs=/backing-store-.0 /.0
fssnap: Fatal: /backing-store-.0 already exists.

# rm /backing-store-.0

# fssnap -F ufs -o bs=/backing-store-.0 /.0
/dev/fssnap/0

# /usr/lib/fs/ufs/fssnap -i
Snapshot number               : 0
Block Device                  : /dev/fssnap/0
Raw Device                    : /dev/rfssnap/0
Mount point                   : /.0
Device state                  : idle
Backing store path            : /backing-store-.0
Backing store size            : 0 KB
Maximum backing store size    : Unlimited
Snapshot create time          : Thu Nov 19 16:49:08 2009
Copy-on-write granularity     : 32 KB
As I said, fssnap creates virtual block device /dev/fssnap/0. This can be also mounted as read-only FS and later backup if needed. # mount -o ro /dev/fssnap/0 /my-snapshot Deleting UFS snapshot In previous examples I didn't specified that backing-store file is unlinked, so after deleting snapshot, the file still exists and should be removed manually.
# fssnap -i
   0    /.0

# fssnap -d /.0
Deleted snapshot 0.

# rm /backing-store-.0
Let's do quick example how to create unlinked ufs snapshot. Note that in this case backup-store file is hidden.
# fssnap -F ufs -o bs=/backup-store-.0,unlink /.0
/dev/fssnap/0

# /usr/lib/fs/ufs/fssnap -i
Snapshot number               : 0
Block Device                  : /dev/fssnap/0
Raw Device                    : /dev/rfssnap/0
Mount point                   : /.0
Device state                  : idle
Backing store path            : /backup-store-.0 <UNLINKED>
Backing store size            : 256 KB
Maximum backing store size    : Unlimited
Snapshot create time          : Fri Nov 20 09:56:48 2009
Copy-on-write granularity     : 32 KB
Now when snapshot is deleted, backup-store file is also gone.
# fssnap -d /.0
Deleted snapshot 0.
Back to the main page