Bug 30139

Summary: snapshots mount option not documented in mount(8)
Product: Base System Reporter: David O'Brien <obrien>
Component: binAssignee: Tom Rhodes <trhodes>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 5.0-CURRENT   
Hardware: Any   
OS: Any   

Description David O'Brien 2001-08-27 21:40:00 UTC
	The snapshot option was added to src/sbin/mount/mount_ufs.c rev 1.17.
	But it is not documented any where that I can find.

How-To-Repeat: 	man 8 mount
Comment 1 Chris Knight 2002-06-19 12:33:11 UTC
Howdy,

Here's a diff to the mount man page including the snapshot support.
I shamelessly cut'n'pasted from Kirk's README.snapshot file and made
some minor edits.
Apologies if I've got some of the manpage formatting wrong - it was a
5 minute crash course on mdoc to do this.

Regards,
Chris Knight

--- src/sbin/mount/mount.8.old	Tue May 21 10:50:17 2002
+++ src/sbin/mount/mount.8	Wed Jun 19 21:19:34 2002
@@ -181,6 +181,62 @@
 All
 .Tn I/O
 to the filesystem should be done synchronously.
+.It Cm snapshot
+This option allows a snapshot of the specified filesystem to be taken. The
+.Fl u
+flag is required with this option. Note that snapshot files must be created in
+the filesystem that is being snapshotted. You may create up to 20 snapshots per
+filesystem. Active snapshots are recorded in the superblock, so they persist
+across unmount and remount operations and across system reboots. When you are
+done with a snapshot, it can be removed with the
+.Xr rm
+command. Snapshots may be removed in any order, however you may not get back all
+the space contained in the snapshot as another snapshot may claim some of the
+blocks that it is releasing. Note that the schg flag is set on snapshots to
+ensure that not even the root user can write to them. The unlink command makes
+an exception for snapshot files in that it allows them to be removed even though
+they have the schg flag set, so it is not necessary to clear the schg flag
+before removing a snapshot file.
+.Pp
+Once you have taken a snapshot, there are three interesting things that you can 
+do with it:
+.Pp
+.Bl -enum -compact
+.It
+Run fsck on the snapshot file. Assuming that the filesystem was clean when it
+was mounted, you should always get a clean (and unchanging) result from running 
+fsck on the snapshot. This is essentially what the background fsck process does.
+.Pp
+.It
+Run dump on the snapshot. You will get a dump that is consistent with the
+filesystem as of the timestamp of the snapshot. Note that
+.Xr dump
+has not yet been changed to set the dumpdates file correctly, so do not use this
+feature in production until that fix is made.
+.Pp
+.It
+Mount the snapshot as a frozen image of the filesystem. To mount the snapshot
+.Pa /var/snapshot/snap1 :
+.Bd -literal
+mdconfig -a -t vnode -f /var/snapshot/snap1 -u 4
+mount -r /dev/md4 /mnt
+.Ed
+.Pp
+You can now cruise around your frozen
+.Pa /var
+filesystem at
+.Pa /mnt .
+Everything will be in the same state that it was at the time the snapshot was
+taken. The one exception is that any earlier snapshots will appear as zero
+length files. When you are done with the mounted snapshot:
+.Bd -literal
+umount /mnt
+mdconfig -d -u 4
+.Ed
+.Pp
+Further details can be found in the file at
+.Pa /usr/src/sys/ufs/ffs/README.snapshot .
+.El
 .It Cm suiddir
 A directory on the mounted filesystem will respond to the SUID bit
 being set, by setting the owner of any new files to be the same
Comment 2 David E. O'Brien freebsd_committer freebsd_triage 2002-06-19 18:01:23 UTC
On Wed, Jun 19, 2002 at 09:33:11PM +1000, Chris Knight wrote:
> Here's a diff to the mount man page including the snapshot support.
> I shamelessly cut'n'pasted from Kirk's README.snapshot file and made
> some minor edits.

This is a good patch and having snapshots better documented is a big help
to all.

Could you make one more pass over your patch and change one thing.
All sentances should end at the end of a line.
Maybe comma's too,
I don't remember too much about them.

What I wrote above is an example of what I mean.  There are no sentances
like the previous one to this that don't end at the end of a line.


+.It Cm snapshot
+This option allows a snapshot of the specified filesystem to be taken.
+The
+.Fl u
+flag is required with this option.
+Note that snapshot files must be created in the filesystem that is being
+snapshotted.
+You may create up to 20 snapshots per filesystem.
+Active snapshots are recorded in the superblock,
+so they persist across unmount and remount operations and across system
+reboots.
Comment 3 Chris Knight 2002-06-23 08:09:25 UTC
Howdy,

OK, here's an updated patch. The rest of the mount manpage suggests that line
breaks after commas is not necessary. Thanks for the feedback.
Sorry about the e-mail address. I must remember to regen my sendmail.cf file
after upgrading.

Regards,
Chris Knight

--- mount.8.orig	Tue May 21 10:50:17 2002
+++ mount.8	Sun Jun 23 16:58:22 2002
@@ -181,6 +181,73 @@
 All
 .Tn I/O
 to the filesystem should be done synchronously.
+.It Cm snapshot
+This option allows a snapshot of the specified filesystem to be taken.
+The
+.Fl u
+flag is required with this option.
+Note that snapshot files must be created in the filesystem that is being
+snapshotted.
+You may create up to 20 snapshots per filesystem.
+Active snapshots are recorded in the superblock, so they persist across unmount
+and remount operations and across system reboots.
+When you are done with a snapshot, it can be removed with the
+.Xr rm
+command.
+Snapshots may be removed in any order, however you may not get back all the
+space contained in the snapshot as another snapshot may claim some of the blocks
+that it is releasing.
+Note that the schg flag is set on snapshots to ensure that not even the root
+user can write to them.
+The unlink command makes an exception for snapshot files in that it allows them
+to be removed even though they have the schg flag set, so it is not necessary to
+clear the schg flag before removing a snapshot file.
+.Pp
+Once you have taken a snapshot, there are three interesting things that you can 
+do with it:
+.Pp
+.Bl -enum -compact
+.It
+Run fsck on the snapshot file.
+Assuming that the filesystem was clean when it was mounted, you should always
+get a clean (and unchanging) result from running fsck on the snapshot.
+This is essentially what the background fsck process does.
+.Pp
+.It
+Run dump on the snapshot.
+You will get a dump that is consistent with the filesystem as of the timestamp
+of the snapshot.
+Note that
+.Xr dump
+has not yet been changed to set the dumpdates file correctly, so do not use this
+feature in production until that fix is made.
+.Pp
+.It
+Mount the snapshot as a frozen image of the filesystem.
+To mount the snapshot
+.Pa /var/snapshot/snap1 :
+.Bd -literal
+mdconfig -a -t vnode -f /var/snapshot/snap1 -u 4
+mount -r /dev/md4 /mnt
+.Ed
+.Pp
+You can now cruise around your frozen
+.Pa /var
+filesystem at
+.Pa /mnt .
+Everything will be in the same state that it was at the time the snapshot was
+taken.
+The one exception is that any earlier snapshots will appear as zero length
+files.
+When you are done with the mounted snapshot:
+.Bd -literal
+umount /mnt
+mdconfig -d -u 4
+.Ed
+.Pp
+Further details can be found in the file at
+.Pa /usr/src/sys/ufs/ffs/README.snapshot .
+.El
 .It Cm suiddir
 A directory on the mounted filesystem will respond to the SUID bit
 being set, by setting the owner of any new files to be the same
Comment 4 Tom Rhodes freebsd_committer freebsd_triage 2002-07-11 22:13:02 UTC
State Changed
From-To: open->patched

I have applied this change and will see to the MFC.  Thanks for the submission! 


Comment 5 Tom Rhodes freebsd_committer freebsd_triage 2002-07-11 22:13:02 UTC
Responsible Changed
From-To: freebsd-bugs->trhodes

I have applied this change and will see to the MFC.  Thanks for the submission!
Comment 6 Tom Rhodes freebsd_committer freebsd_triage 2002-07-15 16:30:46 UTC
State Changed
From-To: patched->closed

Patched and closed.  This was not MFC'ed as snapshots are not supported in 
-STABLE.