1 .\" Copyright (c) 2007 The DragonFly Project. All rights reserved.
3 .\" This code is derived from software contributed to The DragonFly Project
4 .\" by Matthew Dillon <dillon@backplane.com>
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
10 .\" 1. Redistributions of source code must retain the above copyright
11 .\" notice, this list of conditions and the following disclaimer.
12 .\" 2. Redistributions in binary form must reproduce the above copyright
13 .\" notice, this list of conditions and the following disclaimer in
14 .\" the documentation and/or other materials provided with the
16 .\" 3. Neither the name of The DragonFly Project nor the names of its
17 .\" contributors may be used to endorse or promote products derived
18 .\" from this software without specific, prior written permission.
20 .\" THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 .\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 .\" LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23 .\" FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24 .\" COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25 .\" INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
26 .\" BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
28 .\" AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
29 .\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
30 .\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
38 .Nd HAMMER file system utility
45 .Op Fl C Ar cachesize Ns Op Ns Cm \&: Ns Ar readahead
46 .Op Fl R Ar restrictcmd
47 .Op Fl T Ar restrictpath
49 .Op Fl e Ar scoreboardfile
51 .\" .Op Fl s Ar linkpath
60 This manual page documents the
62 utility which provides miscellaneous functions related to managing a
65 For a general introduction to the
67 file system, its features, and
68 examples on how to set up and maintain one, see
71 The options are as follows:
72 .Bl -tag -width indent
74 Tell the mirror commands to use a 2-way protocol, which allows
75 automatic negotiation of transaction id ranges.
76 This option is automatically enabled by the
80 Make per PFS commands perform on all PFSs if possible.
81 If the command supports this option, it targets all PFSs of the
85 argument (of that command) belongs to.
94 commands support this option.
95 If the command does not support this option, it does nothing.
99 will not attempt to break-up large initial bulk transfers into smaller
101 This can save time but if the link is lost in the middle of the
102 initial bulk transfer you will have to start over from scratch.
103 For more information see the
106 .It Fl b Ar bandwidth
107 Specify a bandwidth limit in bytes per second for mirroring streams.
108 This option is typically used to prevent batch mirroring operations from
109 loading down the machine.
110 The bandwidth may be suffixed with
114 to specify values in kilobytes, megabytes, and gigabytes per second.
115 If no suffix is specified, bytes per second is assumed.
117 Unfortunately this is only applicable to the pre-compression bandwidth
118 when compression is used, so a better solution would probably be to
124 .It Fl C Ar cachesize Ns Op Ns Cm \&: Ns Ar readahead
125 Set the memory cache size for any raw
132 for megabytes is allowed,
133 else the cache size is specified in bytes.
135 The read-behind/read-ahead defaults to 4
139 This option is typically only used with diagnostic commands
140 as kernel-supported commands will use the kernel's buffer cache.
141 .It Fl R Ar restrictcmd
142 This option is used by hammer ssh-remote to restrict the command later
143 on in the argument list. Multiple commands may be specified, separated
144 by a comma (all one argument).
145 .It Fl T Ar restrictpath
146 This option is used by hammer ssh-remote to restrict the filesystem path
147 specified later on in the argument list.
148 .It Fl c Ar cyclefile
149 When pruning, rebalancing or reblocking you can tell the utility
150 to start at the object id stored in the specified file.
151 If the file does not exist
153 will start at the beginning.
156 is told to run for a specific period of time
158 and is unable to complete the operation it will write out
159 the current object id so the next run can pick up where it left off.
162 runs to completion it will delete
164 .It Fl e Ar scoreboardfile
165 Update scoreboard file with progress, primarily used by mirror-stream.
170 will not check that time period has elapsed if this option is given.
172 Specify the volumes making up a
176 is a colon-separated list of devices, each specifying a
182 Specify delay in seconds for
183 .Cm mirror-read-stream .
184 When maintaining a streaming mirroring this option specifies the
185 minimum delay after a batch ends before the next batch is allowed
187 The default is five seconds.
189 Specify the maximum amount of memory
191 will allocate during a dedup pass.
192 Specify a suffix 'm', 'g', or 't' for megabytes, gigabytes, or terabytes.
195 will allocate up to 1G of ram to hold CRC/SHA tables while running dedup.
196 When the limit is reached the dedup code restricts the range of CRCs to
197 keep memory use within bounds and runs multiple passes as necessary until
198 the entire filesystem has been deduped.
205 specification for the source and/or destination.
207 Decrease verboseness.
208 May be specified multiple times.
210 Specify recursion for those commands which support it.
211 .It Fl S Ar splitsize
212 Specify the bulk splitup size in bytes for mirroring streams.
217 will do an initial run-through of the data to calculate good
218 transaction ids to cut up the bulk transfers, creating
219 restart points in case the stream is interrupted.
220 If we don't do this and the stream is interrupted it might
221 have to start all over again.
226 At the moment the run-through is disk-bandwidth-heavy but some
227 future version will limit the run-through to just the B-Tree
228 records and not the record data.
230 The splitsize may be suffixed with
234 to specify values in kilobytes, megabytes, or gigabytes.
235 If no suffix is specified, bytes is assumed.
237 When mirroring very large filesystems the minimum recommended
239 A small split size may wind up generating a great deal of overhead
240 but very little actual incremental data and is not recommended.
242 Specify timeout in seconds.
243 When pruning, rebalancing, reblocking or mirror-reading
244 you can tell the utility to stop after a certain period of time.
245 A value of 0 means unlimited.
246 This option is used along with the
248 option to prune, rebalance or reblock incrementally.
250 Increase verboseness.
251 May be specified multiple times.
253 Enable compression for any remote ssh specifications.
254 This option is typically used with the mirroring directives.
258 for interactive questions.
261 The commands are as follows:
262 .Bl -tag -width indent
263 .\" ==== synctid ====
264 .It Cm synctid Ar filesystem Op Cm quick
265 Generate a guaranteed, formal 64-bit transaction id representing the
266 current state of the specified
269 The file system will be synced to the media.
273 keyword is specified the file system will be soft-synced, meaning that a
274 crash might still undo the state of the file system as of the transaction
275 id returned but any new modifications will occur after the returned
276 transaction id as expected.
278 This operation does not create a snapshot.
279 It is meant to be used
280 to track temporary fine-grained changes to a subset of files and
281 will only remain valid for
283 access purposes for the
285 period configured for the PFS.
286 If you desire a real snapshot then the
288 directive may be what you are looking for.
290 .It Cm bstats Op Ar interval
293 B-Tree statistics until interrupted.
296 seconds between each display.
297 The default interval is one second.
298 .\" ==== iostats ====
299 .It Cm iostats Op Ar interval
303 statistics until interrupted.
306 seconds between each display.
307 The default interval is one second.
308 .\" ==== history ====
309 .It Cm history Ns Oo Cm @ Ns Ar offset Ns Oo Cm \&, Ns Ar length Oc Oc Ar path ...
310 Show the modification history for inode and data of
315 is given history is shown for data block at given offset,
316 otherwise history is shown for inode.
321 data bytes at given offset are dumped for each version,
326 this directive shows object id and sync status,
327 and for each object version it shows transaction id and time stamp.
328 Files has to exist for this directive to be applicable,
329 to track inodes which has been deleted or renamed see
331 .\" ==== blockmap ====
333 Dump the blockmap for the file system.
336 blockmap is two-layer
337 blockmap representing the maximum possible file system size of 1 Exabyte.
338 Needless to say the second layer is only present for blocks which exist.
340 blockmap represents 8-Megabyte blocks, called big-blocks.
341 Each big-block has an append
342 point, a free byte count, and a typed zone id which allows content to be
343 reverse engineered to some degree.
347 allocations are essentially appended to a selected big-block using
348 the append offset and deducted from the free byte count.
349 When space is freed the free byte count is adjusted but
351 does not track holes in big-blocks for reallocation.
352 A big-block must be completely freed, either
353 through normal file system operations or through reblocking, before
356 Data blocks can be shared by deducting the space used from the free byte
357 count for each shared references.
358 This means the free byte count can legally go negative.
360 This command needs the
363 .\" ==== checkmap ====
365 Check the blockmap allocation count.
367 will scan the B-Tree, collect allocation information, and
368 construct a blockmap in-memory.
369 It will then check that blockmap against the on-disk blockmap.
371 This command needs the
375 .It Cm show Op Ar localization Ns Op Cm \&: Ns Ar object_id
377 By default this command will validate all B-Tree
378 linkages and CRCs, including data CRCs, and will report the most verbose
379 information it can dig up.
380 Any errors will show up with a
382 in column 1 along with various
388 .Ar localization Ns Cm \&: Ns Ar object_id
390 search for the key printing nodes as it recurses down, and then
391 will iterate forwards.
392 These fields are specified in HEX.
393 Note that the pfsid is the top 16 bits of the 32-bit localization
394 field so PFS #1 would be 00010000.
398 the command will report less information about the inode contents.
402 the command will not report the content of the inode or other typed
407 the command will not report volume header information, big-block fill
408 ratios, mirror transaction ids, or report or check data CRCs.
409 B-Tree CRCs and linkages are still checked.
411 This command needs the
414 .\" ==== show-undo ====
418 Dump the UNDO/REDO map.
420 This command needs the
424 .\" Dump the B-Tree, record, large-data, and small-data blockmaps, showing
425 .\" physical block assignments and free space percentages.
426 .\" ==== ssh-remote ====
427 .It Cm ssh-remote Ar command Ar targetdir
428 Used in a ssh authorized_keys line such as
429 command="/sbin/hammer ssh-remote mirror-read /fubarmount" ... to allow
430 mirror-read or mirror-write access to a particular subdirectory tree.
431 This way you do not have to give shell access to the remote box.
433 will obtain the original command line from the SSH_ORIGINAL_COMMAND
434 environment variable, validate it against the restriction, and then
435 re-exec hammer with the validated arguments.
437 The remote hammer command does not allow the
441 options to be passed in.
442 .\" ==== recover ====
443 .It Cm recover Ar targetdir
444 Recover data from a corrupted
447 This is a low level command which operates on the filesystem image and
448 attempts to locate and recover files from a corrupted filesystem.
449 The entire image is scanned linearly looking for B-Tree nodes.
451 found which passes its CRC test is scanned for file, inode, and directory
452 fragments and the target directory is populated with the resulting data.
453 files and directories in the target directory are initially named after
454 the object id and are renamed as fragmentary information is processed.
456 This command keeps track of filename/object_id translations and may eat a
457 considerably amount of memory while operating.
459 This command is literally the last line of defense when it comes to
460 recovering data from a dead filesystem.
462 This command needs the
465 .\" ==== namekey1 ====
466 .It Cm namekey1 Ar filename
469 64-bit directory hash for the specified file name, using
470 the original directory hash algorithm in version 1 of the file system.
471 The low 32 bits are used as an iterator for hash collisions and will be
473 .\" ==== namekey2 ====
474 .It Cm namekey2 Ar filename
477 64-bit directory hash for the specified file name, using
478 the new directory hash algorithm in version 2 of the file system.
479 The low 32 bits are still used as an iterator but will start out containing
480 part of the hash key.
481 .\" ==== namekey32 ====
482 .It Cm namekey32 Ar filename
483 Generate the top 32 bits of a
485 64 bit directory hash for the specified file name.
487 .It Cm info Ar dirpath ...
488 Show extended information about all
490 file systems mounted in the system or the one mounted in
492 when this argument is specified.
494 The information is divided into sections:
495 .Bl -tag -width indent
496 .It Volume identification
497 General information, like the label of the
499 filesystem, the number of volumes it contains, the FSID, and the
502 .It Big block information
503 Big block statistics, such as total, used, reserved and free big blocks.
504 .It Space information
505 Information about space used on the filesystem.
506 Currently total size, used, reserved and free space are displayed.
508 Basic information about the PFSs currently present on a
513 is the ID of the PFS, with 0 being the root PFS.
515 is the current snapshot count on the PFS.
517 displays the mount point of the PFS is currently mounted on (if any).
519 .\" ==== cleanup ====
520 .It Cm cleanup Op Ar filesystem ...
521 This is a meta-command which executes snapshot, prune, rebalance, dedup
522 and reblock commands on the specified
527 is specified this command will clean-up all
529 file systems in use, including PFS's.
530 To do this it will scan all
534 mounts, extract PFS id's, and clean-up each PFS found.
536 This command will access a snapshots
537 directory and a configuration file for each
539 creating them if necessary.
540 .Bl -tag -width indent
541 .It Nm HAMMER No version 2-
542 The configuration file is
544 in the snapshots directory which defaults to
545 .Pa <pfs>/snapshots .
546 .It Nm HAMMER No version 3+
547 The configuration file is saved in file system meta-data, see
550 The snapshots directory defaults to
551 .Pa /var/hammer/<pfs>
552 .Pa ( /var/hammer/root
556 The format of the configuration file is:
557 .Bd -literal -offset indent
558 snapshots <period> <retention-time> [any]
559 prune <period> <max-runtime>
560 rebalance <period> <max-runtime>
561 dedup <period> <max-runtime>
562 reblock <period> <max-runtime>
563 recopy <period> <max-runtime>
567 .Bd -literal -offset indent
568 snapshots 1d 60d # 0d 0d for PFS /tmp, /var/tmp, /usr/obj
576 Time is given with a suffix of
582 meaning day, hour, minute and second.
586 directive has a period of 0 and a retention time of 0
587 then snapshot generation is disabled, removal of old snapshots are
588 disabled, and prunes will use
589 .Cm prune-everything .
593 directive has a period of 0 but a non-zero retention time
594 then this command will not create any new snapshots but will remove old
595 snapshots it finds based on the retention time.
597 used on PFS masters where you are generating your own snapshot softlinks
598 manually and on PFS slaves when all you wish to do is prune away existing
599 snapshots inherited via the mirroring stream.
601 By default only snapshots in the form
602 .Ql snap- Ns Ar yyyymmdd Ns Op - Ns Ar HHMM
606 directive is specified as a third argument on the
608 config line then any softlink of the form
609 .Ql *- Ns Ar yyyymmdd Ns Op - Ns Ar HHMM
611 .Ql *. Ns Ar yyyymmdd Ns Op - Ns Ar HHMM
614 A period of 0 for prune, rebalance, dedup, reblock or recopy disables the directive.
615 A max-runtime of 0 means unlimited.
617 If period hasn't passed since the previous
620 For example a day has passed when midnight is passed (localtime).
623 flag is given the period is ignored.
631 The default configuration file will create a daily snapshot, do a daily
632 pruning, rebalancing, deduping and reblocking run and a monthly recopy run.
633 Reblocking is defragmentation with a level of 95%,
634 and recopy is full defragmentation.
636 By default prune, dedup and rebalance operations are time limited to 5 minutes,
637 and reblock operations to a bit over 5 minutes,
638 and recopy operations to a bit over 10 minutes.
639 Reblocking and recopy runs are each broken down into four separate functions:
640 btree, inodes, dirs and data.
641 Each function is time limited to the time given in the configuration file,
642 but the btree, inodes and dirs functions usually does not take very long time,
643 full defragmentation is always used for these three functions.
644 Also note that this directive will by default disable snapshots on
651 The defaults may be adjusted by modifying the configuration file.
652 The pruning and reblocking commands automatically maintain a cyclefile
653 for incremental operation.
654 If you interrupt (^C) the program the cyclefile will be updated,
656 may continue to run in the background for a few seconds until the
658 ioctl detects the interrupt.
661 PFS option can be set to use another location for the snapshots directory.
663 Work on this command is still in progress.
665 An ability to remove snapshots dynamically as the
666 file system becomes full.
668 .It Cm config Op Ar filesystem Op Ar configfile
671 Show or change configuration for
673 If zero or one arguments are specified this function dumps the current
674 configuration file to stdout.
675 Zero arguments specifies the PFS containing the current directory.
676 This configuration file is stored in file system meta-data.
677 If two arguments are specified this function installs a new config file.
681 versions less than 3 the configuration file is by default stored in
682 .Pa <pfs>/snapshots/config ,
683 but in all later versions the configuration file is stored in file system
685 .\" ==== viconfig ====
686 .It Cm viconfig Op Ar filesystem
689 Edit the configuration file and reinstall into file system meta-data when done.
690 Zero arguments specifies the PFS containing the current directory.
691 .\" ==== volume-add ====
692 .It Cm volume-add Ar device Ar filesystem
699 and add all of its space to
703 file system can use up to 256 volumes.
706 All existing data contained on
708 will be destroyed by this operation!
713 file system, formatting will be denied.
714 You can overcome this sanity check by using
716 to erase the beginning sectors of the device.
718 Remember that you have to specify
720 together with any other device that make up the file system,
727 is root file system, also remember to add
730 .Va vfs.root.mountfrom
732 .Pa /boot/loader.conf ,
735 .\" ==== volume-del ====
736 .It Cm volume-del Ar device Ar filesystem
742 Remember that you have to remove
744 from the colon-separated list in
750 is root file system, also remember to remove
753 .Va vfs.root.mountfrom
755 .Pa /boot/loader.conf ,
758 .\" ==== volume-list ====
759 .It Cm volume-list Ar filesystem
760 List the volumes that make up
762 .\" ==== snapshot ====
763 .It Cm snapshot Oo Ar filesystem Oc Ar snapshot-dir
764 .It Cm snapshot Ar filesystem Ar snapshot-dir Op Ar note
765 Take a snapshot of the file system either explicitly given by
767 or implicitly derived from the
769 argument and creates a symlink in the directory provided by
771 pointing to the snapshot.
774 is not a directory, it is assumed to be a format string passed to
776 with the current time as parameter.
779 refers to an existing directory, a default format string of
781 is assumed and used as name for the newly created symlink.
783 Snapshot is a per PFS operation, so each PFS in a
785 file system have to be snapshot separately.
787 Example, assuming that
795 are file systems on their own, the following invocations:
796 .Bd -literal -offset indent
797 hammer snapshot /mysnapshots
799 hammer snapshot /mysnapshots/%Y-%m-%d
801 hammer snapshot /obj /mysnapshots/obj-%Y-%m-%d
803 hammer snapshot /usr /my/snaps/usr "note"
806 Would create symlinks similar to:
807 .Bd -literal -offset indent
808 /mysnapshots/snap-20080627-1210 -> /@@0x10d2cd05b7270d16
810 /mysnapshots/2008-06-27 -> /@@0x10d2cd05b7270d16
812 /mysnapshots/obj-2008-06-27 -> /obj@@0x10d2cd05b7270d16
814 /my/snaps/usr/snap-20080627-1210 -> /usr@@0x10d2cd05b7270d16
819 version 3+ file system the snapshot is also recorded in file system meta-data
820 along with the optional
826 .It Cm snap Ar path Op Ar note
829 Create a snapshot for the PFS containing
831 and create a snapshot softlink.
832 If the path specified is a
833 directory a standard snapshot softlink will be created in the directory.
834 The snapshot softlink points to the base of the mounted PFS.
835 .It Cm snaplo Ar path Op Ar note
838 Create a snapshot for the PFS containing
840 and create a snapshot softlink.
841 If the path specified is a
842 directory a standard snapshot softlink will be created in the directory.
843 The snapshot softlink points into the directory it is contained in.
844 .It Cm snapq Ar dir Op Ar note
847 Create a snapshot for the PFS containing the specified directory but do
848 not create a softlink.
849 Instead output a path which can be used to access
850 the directory via the snapshot.
852 An absolute or relative path may be specified.
853 The path will be used as-is as a prefix in the path output to stdout.
855 snap and snapshot directives the snapshot transaction id will be registered
856 in the file system meta-data.
857 .It Cm snaprm Ar path Ar ...
858 .It Cm snaprm Ar transaction_id Ar ...
859 .It Cm snaprm Ar filesystem Ar transaction_id Ar ...
862 Remove a snapshot given its softlink or transaction id.
863 If specifying a transaction id
864 the snapshot is removed from file system meta-data but you are responsible
865 for removing any related softlinks.
867 If a softlink path is specified the filesystem and transaction id
868 is derived from the contents of the softlink.
869 If just a transaction id is specified it is assumed to be a snapshot in the
871 filesystem you are currently chdir'd into.
872 You can also specify the filesystem and transaction id explicitly.
873 .It Cm snapls Op Ar path ...
876 Dump the snapshot meta-data for PFSs containing each
878 listing all available snapshots and their notes.
879 If no arguments are specified snapshots for the PFS containing the
880 current directory are listed.
881 This is the definitive list of snapshots for the file system.
883 .It Cm prune Ar softlink-dir
884 Prune the file system based on previously created snapshot softlinks.
885 Pruning is the act of deleting file system history.
888 command will delete file system history such that
889 the file system state is retained for the given snapshots,
890 and all history after the latest snapshot.
891 By setting the per PFS parameter
893 history is guaranteed to be saved at least this time interval.
894 All other history is deleted.
896 The target directory is expected to contain softlinks pointing to
897 snapshots of the file systems you wish to retain.
898 The directory is scanned non-recursively and the mount points and
899 transaction ids stored in the softlinks are extracted and sorted.
900 The file system is then explicitly pruned according to what is found.
901 Cleaning out portions of the file system is as simple as removing a
902 snapshot softlink and then running the
906 As a safety measure pruning only occurs if one or more softlinks are found
909 snapshot id extension.
910 Currently the scanned softlink directory must contain softlinks pointing
914 The softlinks may specify absolute or relative paths.
915 Softlinks must use 20-character
917 transaction ids, as might be returned from
918 .Nm Cm synctid Ar filesystem .
920 Pruning is a per PFS operation, so each PFS in a
922 file system have to be pruned separately.
924 Note that pruning a file system may not immediately free-up space,
925 though typically some space will be freed if a large number of records are
927 The file system must be reblocked to completely recover all available space.
929 Example, lets say your that you didn't set
931 and snapshot directory contains the following links:
932 .Bd -literal -offset indent
933 lrwxr-xr-x 1 root wheel 29 May 31 17:57 snap1 ->
934 /usr/obj/@@0x10d2cd05b7270d16
936 lrwxr-xr-x 1 root wheel 29 May 31 17:58 snap2 ->
937 /usr/obj/@@0x10d2cd13f3fde98f
939 lrwxr-xr-x 1 root wheel 29 May 31 17:59 snap3 ->
940 /usr/obj/@@0x10d2cd222adee364
943 If you were to run the
945 command on this directory, then the
948 mount will be pruned to retain the above three snapshots.
949 In addition, history for modifications made to the file system older than
950 the oldest snapshot will be destroyed and history for potentially fine-grained
951 modifications made to the file system more recently than the most recent
952 snapshot will be retained.
954 If you then delete the
956 softlink and rerun the
959 history for modifications pertaining to that snapshot would be destroyed.
963 file system versions 3+ this command also scans the snapshots stored
964 in the file system meta-data and includes them in the prune.
965 .\" ==== prune-everything ====
966 .It Cm prune-everything Ar filesystem
967 Remove all historical records from
969 Use this directive with caution on PFSs where you intend to use history.
971 This command does not remove snapshot softlinks but will delete all
972 snapshots recorded in file system meta-data (for file system version 3+).
973 The user is responsible for deleting any softlinks.
975 Pruning is a per PFS operation, so each PFS in a
977 file system have to be pruned separately.
978 .\" ==== rebalance ====
979 .It Cm rebalance Ar filesystem Op Ar saturation_percentage
980 Rebalance the B-Tree, nodes with small number of
981 elements will be combined and element counts will be smoothed out
984 The saturation percentage is between 50% and 100%.
985 The default is 85% (the
987 suffix is not needed).
989 Rebalancing is a per PFS operation, so each PFS in a
991 file system have to be rebalanced separately.
993 .It Cm dedup Ar filesystem
996 Perform offline (post-process) deduplication.
997 Deduplication occurs at
998 the block level, currently only data blocks of the same size can be
999 deduped, metadata blocks can not.
1000 The hash function used for comparing
1001 data blocks is CRC-32 (CRCs are computed anyways as part of
1003 data integrity features, so there's no additional overhead).
1004 Since CRC is a weak hash function a byte-by-byte comparison is done
1005 before actual deduping.
1006 In case of a CRC collision (two data blocks have the same CRC
1007 but different contents) the checksum is upgraded to SHA-256.
1011 reblocker may partially blow up (re-expand) dedup (reblocker's normal
1012 operation is to reallocate every record, so it's possible for deduped
1013 blocks to be re-expanded back).
1015 Deduplication is a per PFS operation, so each PFS in a
1017 file system have to be deduped separately.
1019 means that if you have duplicated data in two different PFSs that data
1020 won't be deduped, however the addition of such feature is planned.
1024 option should be used to limit memory use during the dedup run if the
1025 default 1G limit is too much for the machine.
1026 .\" ==== dedup-simulate ====
1027 .It Cm dedup-simulate Ar filesystem
1028 Shows potential space savings (simulated dedup ratio) one can get after
1032 If the estimated dedup ratio is greater than 1.00 you will see
1033 dedup space savings.
1034 Remember that this is an estimated number, in
1035 practice real dedup ratio will be slightly smaller because of
1037 bigblock underflows, B-Tree locking issues and other factors.
1039 Note that deduplication currently works only on bulk data so if you
1044 commands on a PFS that contains metadata only (directory entries,
1045 softlinks) you will get a 0.00 dedup ratio.
1049 option should be used to limit memory use during the dedup run if the
1050 default 1G limit is too much for the machine.
1051 .\" ==== reblock* ====
1052 .It Cm reblock Ar filesystem Op Ar fill_percentage
1053 .It Cm reblock-btree Ar filesystem Op Ar fill_percentage
1054 .It Cm reblock-inodes Ar filesystem Op Ar fill_percentage
1055 .It Cm reblock-dirs Ar filesystem Op Ar fill_percentage
1056 .It Cm reblock-data Ar filesystem Op Ar fill_percentage
1057 Attempt to defragment and free space for reuse by reblocking a live
1060 Big-blocks cannot be reused by
1062 until they are completely free.
1063 This command also has the effect of reordering all elements, effectively
1064 defragmenting the file system.
1066 The default fill percentage is 100% and will cause the file system to be
1067 completely defragmented.
1068 All specified element types will be reallocated and rewritten.
1069 If you wish to quickly free up space instead try specifying
1070 a smaller fill percentage, such as 90% or 80% (the
1072 suffix is not needed).
1074 Since this command may rewrite the entire contents of the disk it is
1075 best to do it incrementally from a
1081 options to limit the run time.
1082 The file system would thus be defragmented over long period of time.
1084 It is recommended that separate invocations be used for each data type.
1085 B-Tree nodes, inodes, and directories are typically the most important
1086 elements needing defragmentation.
1087 Data can be defragmented over a longer period of time.
1089 Reblocking is a per PFS operation, so each PFS in a
1091 file system have to be reblocked separately.
1092 .\" ==== pfs-status ====
1093 .It Cm pfs-status Ar dirpath ...
1094 Retrieve the mirroring configuration parameters for the specified
1096 file systems or pseudo-filesystems (PFS's).
1097 .\" ==== pfs-master ====
1098 .It Cm pfs-master Ar dirpath Op Ar options
1099 Create a pseudo-filesystem (PFS) inside a
1102 Up to 65536 PFSs can be created.
1103 Each PFS uses an independent inode numbering space making it suitable
1108 directive creates a PFS that you can read, write, and use as a mirroring
1111 A PFS can only be truly destroyed with the
1114 Removing the softlink will not destroy the underlying PFS.
1116 A PFS can only be created in the root PFS (PFS# 0),
1117 not in a PFS created by
1123 It is recommended that
1129 directory at root of
1133 It is recommended to use a
1135 mount to access a PFS, except for root PFS, for more information see
1137 .\" ==== pfs-slave ====
1138 .It Cm pfs-slave Ar dirpath Op Ar options
1139 Create a pseudo-filesystem (PFS) inside a
1142 Up to 65536 PFSs can be created.
1143 Each PFS uses an independent inode numbering space making it suitable
1148 directive creates a PFS that you can use as a mirroring source or target.
1149 You will not be able to access a slave PFS until you have completed the
1150 first mirroring operation with it as the target (its root directory will
1151 not exist until then).
1153 Access to the pfs-slave via the special softlink, as described in the
1154 .Sx PSEUDO-FILESYSTEM (PFS) NOTES
1158 dynamically modify the snapshot transaction id by returning a dynamic result
1163 A PFS can only be truly destroyed with the
1166 Removing the softlink will not destroy the underlying PFS.
1168 A PFS can only be created in the root PFS (PFS# 0),
1169 not in a PFS created by
1175 It is recommended that
1181 directory at root of
1185 It is recommended to use a
1187 mount to access a PFS, except for root PFS, for more information see
1189 .\" ==== pfs-update ====
1190 .It Cm pfs-update Ar dirpath Op Ar options
1191 Update the configuration parameters for an existing
1193 file system or pseudo-filesystem.
1194 Options that may be specified:
1195 .Bl -tag -width indent
1196 .It Cm sync-beg-tid= Ns Ar 0x16llx
1197 This is the automatic snapshot access starting transaction id for
1199 This parameter is normally updated automatically by the
1203 It is important to note that accessing a mirroring slave
1204 with a transaction id greater than the last fully synchronized transaction
1205 id can result in an unreliable snapshot since you will be accessing
1206 data that is still undergoing synchronization.
1208 Manually modifying this field is dangerous and can result in a broken mirror.
1209 .It Cm sync-end-tid= Ns Ar 0x16llx
1210 This is the current synchronization point for mirroring slaves.
1211 This parameter is normally updated automatically by the
1215 Manually modifying this field is dangerous and can result in a broken mirror.
1216 .It Cm shared-uuid= Ns Ar uuid
1217 Set the shared UUID for this file system.
1218 All mirrors must have the same shared UUID.
1219 For safety purposes the
1221 directives will refuse to operate on a target with a different shared UUID.
1223 Changing the shared UUID on an existing, non-empty mirroring target,
1224 including an empty but not completely pruned target,
1225 can lead to corruption of the mirroring target.
1226 .It Cm unique-uuid= Ns Ar uuid
1227 Set the unique UUID for this file system.
1228 This UUID should not be used anywhere else,
1229 even on exact copies of the file system.
1230 .It Cm label= Ns Ar string
1231 Set a descriptive label for this file system.
1232 .It Cm snapshots= Ns Ar string
1233 Specify the snapshots directory which
1236 will use to manage this PFS.
1237 .Bl -tag -width indent
1238 .It Nm HAMMER No version 2-
1239 The snapshots directory does not need to be configured for
1240 PFS masters and will default to
1241 .Pa <pfs>/snapshots .
1243 PFS slaves are mirroring slaves so you cannot configure a snapshots
1244 directory on the slave itself to be managed by the slave's machine.
1245 In fact, the slave will likely have a
1247 sub-directory mirrored
1248 from the master, but that directory contains the configuration the master
1249 is using for its copy of the file system, not the configuration that we
1250 want to use for our slave.
1252 It is recommended that
1253 .Pa <fs>/var/slaves/<name>
1254 be configured for a PFS slave, where
1260 is an appropriate label.
1261 .It Nm HAMMER No version 3+
1262 The snapshots directory does not need to be configured for PFS masters or
1264 The snapshots directory defaults to
1265 .Pa /var/hammer/<pfs>
1266 .Pa ( /var/hammer/root
1270 You can control snapshot retention on your slave independent of the master.
1271 .It Cm snapshots-clear
1274 directory path for this PFS.
1275 .It Cm prune-min= Ns Ar N Ns Cm d
1276 .It Cm prune-min= Ns Oo Ar N Ns Cm d/ Oc Ns \
1277 Ar hh Ns Op Cm \&: Ns Ar mm Ns Op Cm \&: Ns Ar ss
1278 Set the minimum fine-grained data retention period.
1280 always retains fine-grained history up to the most recent snapshot.
1281 You can extend the retention period further by specifying a non-zero
1283 Any snapshot softlinks within the retention period are ignored
1284 for the purposes of pruning (i.e.\& the fine grained history is retained).
1285 Number of days, hours, minutes and seconds are given as
1290 Because the transaction id in the snapshot softlink cannot be used
1291 to calculate a timestamp,
1293 uses the earlier of the
1297 field of the softlink to
1298 determine which snapshots fall within the retention period.
1299 Users must be sure to retain one of these two fields when manipulating
1302 .\" ==== pfs-upgrade ====
1303 .It Cm pfs-upgrade Ar dirpath
1304 Upgrade a PFS from slave to master operation.
1305 The PFS will be rolled back to the current end synchronization transaction id
1306 (removing any partial synchronizations), and will then become writable.
1310 currently supports only single masters and using
1311 this command can easily result in file system corruption
1312 if you don't know what you are doing.
1314 This directive will refuse to run if any programs have open descriptors
1315 in the PFS, including programs chdir'd into the PFS.
1316 .\" ==== pfs-downgrade ====
1317 .It Cm pfs-downgrade Ar dirpath
1318 Downgrade a master PFS from master to slave operation.
1319 The PFS becomes read-only and access will be locked to its
1322 This directive will refuse to run if any programs have open descriptors
1323 in the PFS, including programs chdir'd into the PFS.
1324 .\" ==== pfs-destroy ====
1325 .It Cm pfs-destroy Ar dirpath
1326 This permanently destroys a PFS.
1328 This directive will refuse to run if any programs have open descriptors
1329 in the PFS, including programs chdir'd into the PFS.
1330 As safety measure the
1332 flag have no effect on this directive.
1333 .\" ==== mirror-read ====
1334 .It Cm mirror-read Ar filesystem Op Ar begin-tid
1335 Generate a mirroring stream to stdout.
1336 The stream ends when the transaction id space has been exhausted.
1338 may be a master or slave PFS.
1339 .\" ==== mirror-read-stream ====
1340 .It Cm mirror-read-stream Ar filesystem Op Ar begin-tid
1341 Generate a mirroring stream to stdout.
1342 Upon completion the stream is paused until new data is synced to the
1345 Operation continues until the pipe is broken.
1348 command for more details.
1349 .\" ==== mirror-write ====
1350 .It Cm mirror-write Ar filesystem
1351 Take a mirroring stream on stdin.
1353 must be a slave PFS.
1355 This command will fail if the
1357 configuration field for the two file systems do not match.
1360 command for more details.
1362 If the target PFS does not exist this command will ask you whether
1363 you want to create a compatible PFS slave for the target or not.
1364 .\" ==== mirror-dump ====
1365 .It Ar mirror-dump Ar [header]
1370 to dump an ASCII representation of the mirroring stream.
1373 is specified, only the header information is shown.
1374 .\" ==== mirror-copy ====
1375 .\".It Cm mirror-copy Ar [[user@]host:]filesystem [[user@]host:]filesystem
1376 .It Cm mirror-copy \
1377 Oo Oo Ar user Ns Cm @ Oc Ns Ar host Ns Cm \&: Oc Ns Ar filesystem \
1378 Oo Oo Ar user Ns Cm @ Oc Ns Ar host Ns Cm \&: Oc Ns Ar filesystem
1379 This is a shortcut which pipes a
1384 If a remote host specification is made the program forks a
1386 (or other program as specified by the
1388 environment variable) and execs the
1392 on the appropriate host.
1393 The source may be a master or slave PFS, and the target must be a slave PFS.
1395 This command also establishes full duplex communication and turns on
1396 the 2-way protocol feature
1398 which automatically negotiates transaction id
1399 ranges without having to use a cyclefile.
1400 If the operation completes successfully the target PFS's
1403 Note that you must re-chdir into the target PFS to see the updated information.
1404 If you do not you will still be in the previous snapshot.
1406 If the target PFS does not exist this command will ask you whether
1407 you want to create a compatible PFS slave for the target or not.
1408 .\" ==== mirror-stream ====
1409 .\".It Cm mirror-stream Ar [[user@]host:]filesystem [[user@]host:]filesystem
1410 .It Cm mirror-stream \
1411 Oo Oo Ar user Ns Cm @ Oc Ns Ar host Ns Cm \&: Oc Ns Ar filesystem \
1412 Oo Oo Ar user Ns Cm @ Oc Ns Ar host Ns Cm \&: Oc Ns Ar filesystem
1413 This is a shortcut which pipes a
1414 .Cm mirror-read-stream
1418 This command works similarly to
1420 but does not exit after the initial mirroring completes.
1421 The mirroring operation will resume as changes continue to be made to the
1423 The command is commonly used with
1427 options to keep the mirroring target in sync with the source on a continuing
1430 If the pipe is broken the command will automatically retry after sleeping
1432 The time slept will be 15 seconds plus the time given in the
1436 This command also detects the initial-mirroring case and spends some
1437 time scanning the B-Tree to find good break points, allowing the initial
1438 bulk mirroring operation to be broken down into 4GB pieces.
1439 This means that the user can kill and restart the operation and it will
1440 not have to start from scratch once it has gotten past the first chunk.
1443 option may be used to change the size of pieces and the
1445 option may be used to disable this feature and perform an initial bulk
1447 .\" ==== version ====
1448 .It Cm version Ar filesystem
1449 This command returns the
1451 file system version for the specified
1453 as well as the range of versions supported in the kernel.
1456 option may be used to remove the summary at the end.
1457 .\" ==== version-upgrade ====
1458 .It Cm version-upgrade Ar filesystem Ar version Op Cm force
1464 Once upgraded a file system may not be downgraded.
1465 If you wish to upgrade a file system to a version greater or equal to the
1466 work-in-progress (WIP) version number you must specify the
1469 Use of WIP versions should be relegated to testing and may require wiping
1470 the file system as development progresses, even though the WIP version might
1474 This command operates on the entire
1476 file system and is not a per PFS operation.
1477 All PFS's will be affected.
1478 .Bl -tag -width indent
1481 default version, first
1486 New directory entry layout.
1487 This version is using a new directory hash key.
1490 New snapshot management, using file system meta-data for saving
1491 configuration file and snapshots (transaction ids etc.).
1492 Also default snapshots directory has changed.
1496 New undo/redo/flush, giving
1498 a much faster sync and fsync.
1501 Deduplication support.
1504 Directory hash ALG1.
1505 Tends to maintain inode number / directory name entry ordering better
1506 for files after minor renaming.
1509 .Sh PSEUDO-FILESYSTEM (PFS) NOTES
1510 The root of a PFS is not hooked into the primary
1512 file system as a directory.
1515 creates a special softlink called
1517 (exactly 10 characters long) in the primary
1521 then modifies the contents of the softlink as read by
1523 and thus what you see with an
1525 command or if you were to
1528 If the PFS is a master the link reflects the current state of the PFS.
1529 If the PFS is a slave the link reflects the last completed snapshot, and the
1530 contents of the link will change when the next snapshot is completed, and
1535 utility employs numerous safeties to reduce user foot-shooting.
1538 directive requires that the target be configured as a slave and that the
1540 field of the mirroring source and target match.
1541 .Sh DOUBLE_BUFFER MODE
1542 There is a limit to the number of vnodes the kernel can cache, and because
1543 file buffers are associated with a vnode the related data cache can get
1544 blown away when operating on large numbers of files even if the system has
1545 sufficient memory to hold the file data.
1549 double buffer mode by setting the
1552 .Va vfs.hammer.double_buffer
1555 will cache file data via the block device and copy it into the per-file
1556 buffers as needed. The data will be double-cached at least until the
1557 buffer cache throws away the file buffer.
1558 This mode is typically used in conjunction with
1561 .Va vm.swapcache.data_enable
1562 is turned on in order to prevent unnecessary re-caching of file data
1563 due to vnode recycling.
1564 The swapcache will save the cached VM pages related to
1567 device (which doesn't recycle unless you umount the filesystem) instead
1568 of the cached VM pages backing the file vnodes.
1570 .\"Double buffering should also be turned on if live dedup is enabled via
1571 .\"Va vfs.hammer.live_dedup .
1572 .\"This is because the live dedup must validate the contents of a potential
1573 .\"duplicate file block and it must run through the block device to do that
1574 .\"and not the file vnode.
1575 .\"If double buffering is not enabled then live dedup will create extra disk
1576 .\"reads to validate potential data duplicates.
1577 .Sh UPGRADE INSTRUCTIONS HAMMER V1 TO V2
1578 This upgrade changes the way directory entries are stored.
1579 It is possible to upgrade a V1 file system to V2 in place, but
1580 directories created prior to the upgrade will continue to use
1583 Note that the slave mirroring code in the target kernel had bugs in
1584 V1 which can create an incompatible root directory on the slave.
1587 master created after the upgrade with a
1589 slave created prior to the upgrade.
1591 Any directories created after upgrading will use a new layout.
1592 .Sh UPGRADE INSTRUCTIONS HAMMER V2 TO V3
1593 This upgrade adds meta-data elements to the B-Tree.
1594 It is possible to upgrade a V2 file system to V3 in place.
1595 After issuing the upgrade be sure to run a
1598 to perform post-upgrade tasks.
1600 After making this upgrade running a
1605 directory for each PFS mount into
1606 .Pa /var/hammer/<pfs> .
1609 root mount will migrate
1612 .Pa /var/hammer/root .
1613 Migration occurs only once and only if you have not specified
1614 a snapshots directory in the PFS configuration.
1615 If you have specified a snapshots directory in the PFS configuration no
1616 automatic migration will occur.
1618 For slaves, if you desire, you can migrate your snapshots
1619 config to the new location manually and then clear the
1620 snapshot directory configuration in the slave PFS.
1621 The new snapshots hierarchy is designed to work with
1622 both master and slave PFSs equally well.
1624 In addition, the old config file will be moved to file system meta-data,
1625 editable via the new
1629 The old config file will be deleted.
1630 Migration occurs only once.
1632 The V3 file system has new
1634 directives for creating snapshots.
1635 All snapshot directives, including the original, will create
1636 meta-data entries for the snapshots and the pruning code will
1637 automatically incorporate these entries into its list and
1638 expire them the same way it expires softlinks.
1639 If you by accident blow away your snapshot softlinks you can use the
1641 directive to get a definitive list from the file system meta-data and
1642 regenerate them from that list.
1647 to backup file systems your scripts may be using the
1649 directive to generate transaction ids.
1650 This directive does not create a snapshot.
1651 You will have to modify your scripts to use the
1653 directive to generate the linkbuf for the softlink you create, or
1654 use one of the other
1659 directive will continue to work as expected and in V3 it will also
1660 record the snapshot transaction id in file system meta-data.
1661 You may also want to make use of the new
1663 tag for the meta-data.
1666 If you used to remove snapshot softlinks with
1668 you should probably start using the
1670 directive instead to also remove the related meta-data.
1671 The pruning code scans the meta-data so just removing the
1672 softlink is not sufficient.
1673 .Sh UPGRADE INSTRUCTIONS HAMMER V3 TO V4
1674 This upgrade changes undo/flush, giving faster sync.
1675 It is possible to upgrade a V3 file system to V4 in place.
1676 This upgrade reformats the UNDO/REDO FIFO (typically 1GB),
1677 so upgrade might take a minute or two depending.
1679 Version 4 allows the UNDO/REDO FIFO to be flushed without also having
1680 to flush the volume header, removing 2 of the 4 disk syncs typically
1683 and removing 1 of the 2 disk syncs typically
1684 required for a flush sequence.
1685 Version 4 also implements the REDO log (see
1686 .Sx FSYNC FLUSH MODES
1687 below) which is capable
1688 of fsync()ing with either one disk flush or zero disk flushes.
1689 .Sh UPGRADE INSTRUCTIONS HAMMER V4 TO V5
1690 This upgrade brings in deduplication support.
1691 It is possible to upgrade a V4 file system to V5 in place.
1692 Technically it makes the layer2
1694 field a signed value instead of unsigned, allowing it to go negative.
1695 A version 5 filesystem is required for dedup operation.
1696 .Sh UPGRADE INSTRUCTIONS HAMMER V5 TO V6
1697 It is possible to upgrade a V5 file system to V6 in place.
1698 .Sh FSYNC FLUSH MODES
1700 implements five different fsync flush modes via the
1701 .Va vfs.hammer.fsync_mode
1704 version 4+ file systems.
1708 fsync mode 3 is set by default.
1709 REDO operation and recovery is enabled by default.
1710 .Bl -tag -width indent
1712 Full synchronous fsync semantics without REDO.
1715 will not generate REDOs.
1718 will completely sync
1719 the data and meta-data and double-flush the FIFO, including
1720 issuing two disk synchronization commands.
1721 The data is guaranteed
1722 to be on the media as of when
1725 Needless to say, this is slow.
1727 Relaxed asynchronous fsync semantics without REDO.
1729 This mode works the same as mode 0 except the last disk synchronization
1730 command is not issued.
1731 It is faster than mode 0 but not even remotely
1732 close to the speed you get with mode 2 or mode 3.
1734 Note that there is no chance of meta-data corruption when using this
1735 mode, it simply means that the data you wrote and then
1737 might not have made it to the media if the storage system crashes at a bad
1740 Full synchronous fsync semantics using REDO.
1741 NOTE: If not running a
1743 version 4 filesystem or later mode 0 is silently used.
1746 will generate REDOs in the UNDO/REDO FIFO based on a heuristic.
1747 If this is sufficient to satisfy the
1749 operation the blocks will be written out and
1751 will wait for the I/Os to complete,
1752 and then followup with a disk sync command to guarantee the data
1753 is on the media before returning.
1754 This is slower than mode 3 and can result in significant disk or
1755 SSDs overheads, though not as bad as mode 0 or mode 1.
1757 Relaxed asynchronous fsync semantics using REDO.
1758 NOTE: If not running a
1760 version 4 filesystem or later mode 1 is silently used.
1763 will generate REDOs in the UNDO/REDO FIFO based on a heuristic.
1764 If this is sufficient to satisfy the
1766 operation the blocks
1767 will be written out and
1769 will wait for the I/Os to complete,
1772 issue a disk synchronization command.
1774 Note that there is no chance of meta-data corruption when using this
1775 mode, it simply means that the data you wrote and then
1778 not have made it to the media if the storage system crashes at a bad
1781 This mode is the fastest production fsyncing mode available.
1782 This mode is equivalent to how the UFS fsync in the
1791 This mode is primarily designed
1792 for testing and should not be used on a production system.
1794 .Sh RESTORING FROM A SNAPSHOT BACKUP
1795 You restore a snapshot by copying it over to live, but there is a caveat.
1796 The mtime and atime fields for files accessed via a snapshot is locked
1797 to the ctime in order to keep the snapshot consistent, because neither
1798 mtime nor atime changes roll any history.
1800 In order to avoid unnecessary copying it is recommended that you use
1804 when doing the copyback.
1805 Also make sure you traverse the snapshot softlink by appending a ".",
1806 as in "<snapshotpath>/.", and you match up the directory properly.
1807 .Sh RESTORING A PFS FROM A MIRROR
1808 A PFS can be restored from a mirror with
1811 data must be copied separately.
1812 At last the PFS can be upgraded to master using
1815 It is not possible to restore the root PFS (PFS# 0) by using mirroring,
1816 as the root PFS is always a master PFS.
1817 A normal copy (e.g.\& using
1819 must be done, ignoring history.
1820 If history is important, old root PFS can me restored to a new PFS, and
1821 important directories/files can be
1823 mounted to the new PFS.
1825 The following environment variables affect the execution of
1827 .Bl -tag -width ".Ev EDITOR"
1829 The editor program specified in the variable
1831 will be invoked instead of the default editor, which is
1834 The command specified in the variable
1836 will be used to initiate remote operations for the mirror-copy and
1837 mirror-stream commands instead of the default command, which is
1839 The program will be invoked via
1844 .Cm -l user host <remote-command>
1852 .Bl -tag -width ".It Pa <fs>/var/slaves/<name>" -compact
1853 .It Pa <pfs>/snapshots
1854 default per PFS snapshots directory
1857 .It Pa /var/hammer/<pfs>
1858 default per PFS snapshots directory (not root)
1861 .It Pa /var/hammer/root
1862 default snapshots directory for root directory
1865 .It Pa <snapshots>/config
1872 .It Pa <fs>/var/slaves/<name>
1873 recommended slave PFS snapshots directory
1877 recommended PFS directory
1885 .Xr periodic.conf 5 ,
1887 .Xr mount_hammer 8 ,
1889 .Xr newfs_hammer 8 ,
1895 utility first appeared in
1898 .An Matthew Dillon Aq Mt dillon@backplane.com