1.\" Copyright (c) 2011-2014 The DragonFly Project.  All rights reserved.
2.\"
3.\" This code is derived from software contributed to The DragonFly Project
4.\" by Matthew Dillon <dillon@backplane.com>
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\"
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
15.\"    distribution.
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.
19.\"
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
31.\" SUCH DAMAGE.
32.\"
33.Dd November 29, 2020
34.Dt NEWFS_HAMMER2 8
35.Os
36.Sh NAME
37.Nm newfs_hammer2
38.Nd construct a new HAMMER2 file system
39.Sh SYNOPSIS
40.Nm
41.Op Fl b Ar bootsize
42.Op Fl r Ar auxsize
43.Op Fl V Ar version
44.Op Fl L Ar label ...
45.Ar special ...
46.Sh DESCRIPTION
47The
48.Nm
49utility prepares a
50.Nm HAMMER2
51volume on the specified block device.
52.Nm HAMMER2
53volumes can contain any number of named PFSs (Pseudo FileSystems).
54Each named PFS can operate independently or be a constituent of
55a larger cluster.
56Regardless, you must still format each block device separately using
57this command.
58.Pp
59The
60.Nm
61program always creates a PFS called "LOCAL" which may be used for
62device-specific configuration.  This PFS should never be used for generic
63data.
64.Pp
65If no
66.Fl L
67option is specified,
68.Nm
69will use the partition id to create a default label for you.
70.Bl -tag -width indent
71.It partition 'a'
72"BOOT" is created.
73.It partition 'd'
74"ROOT" is created.
75.It otherwise
76"DATA" is created.
77.El
78.Pp
79You can override the default PFS name by specifying one or more
80.Fl L
81options.
82By default these PFSs all represent unclustered mount points.
83.Pp
84You can specify
85.Fl L Ar none
86if you do not want
87.Nm
88to create any PFSs other than "LOCAL".
89.Pp
90Generally speaking this command is not used to create clusters.  It is used
91to format volumes which are then made available for additional clustering
92commands.
93Once formatted the device@LOCAL volume can be mounted in order to make it
94and all other PFSs created on the volume available to the cluster.
95.Pp
96You can use
97.Xr hammer2 8
98directives to construct your cluster, including the creation of additional
99PFSs within various volumes.
100If you are managing several machines, or a large number of machines,
101.Fl L Ar none
102is typically specified to reduce clutter.
103.Pp
104.Nm HAMMER2
105file systems are sector-size agnostic, however the
106.Dx
107implementation requires the sector size to be no larger than 16K.
108.Nm HAMMER2
109file systems start at a relative offset of 0 and leave no room for
110in-band disklabels (old, traditional BSD labels).
111They may only be created using out-of-band disk labels, which is the
112default on
113.Dx
114via
115.Po
116.Xr disklabel 5
117or
118.Xr gpt 8
119labels
120.Pc ,
121or with
122old style disklabels as long as
123the partition does not overlap the label area (have a starting sector
124greater than 16).
125.Pp
126.Nm HAMMER2
127file systems are designed for large storage systems, up to 1 Exabyte, and
128may not operate efficiently on small storage systems.
129The minimum recommended file system size is 50GB.
130In addition,
131.Nm HAMMER2
132file systems operating normally, with automatic snapshots, do not
133immediately reclaim space when files are deleted.
134A regular system maintenance job runs once a day by
135.Xr periodic 8
136to handle reclamation.
137.Pp
138.Nm HAMMER2
139works best when the machine's normal workload would not otherwise fill
140the file system up in the course of 60 days of operation.
141.Pp
142The options are as follows:
143.Bl -tag -width indent
144.It Fl b Ar bootsize
145Specify a fixed area in which a boot related kernel and data can be stored.
146The
147.Ar bootsize
148is specified in bytes.
149By default a boot area of approximately 64MB will be created.
150This area is not currently used for booting and may be repurposed in the
151future.
152.It Fl r Ar auxsize
153Specify a fixed area in which an aux related kernel and data can be stored.
154The
155.Ar auxsize
156is specified in bytes.
157By default an aux area of approximately 256MB will be created.
158This area is not currently used and may be repurposed in the
159future.
160.It Fl V Ar version
161Specify the
162.Nm HAMMER2
163file system version to format.
164By default
165.Nm
166formats the file system using the highest production version number
167supported by the
168.Nm HAMMER2
169VFS by checking the
170.Va vfs.hammer2.supported_version
171sysctl.
172If you need to maintain compatibility with an older version of
173.Nm HAMMER2
174you may specify the version with this option.
175.It Fl L Ar label
176By default
177.Nm
178always creates a local master PFSs on the new volume called "LOCAL",
179and will conditionally also create "BOOT", "ROOT", or "DATA" depending
180on the partition ('b' creates "BOOT", 'd' creates "ROOT", and any other
181partition creates "DATA").
182.Pp
183If you specify one or more label options to create your own named local
184PFSs,
185.Nm
186will not create any conditional PFSs.
187However, "LOCAL" is still always created and should not be
188specified with this option.
189If you don't want any PFSs to be created (other than "LOCAL"), use
190.Fl L Ar none .
191.Pp
192Typically simple HAMMER2 filesystems just use the defaults and
193.Fl L Ar none
194is used for more complex filesystem, followed by mounting device@LOCAL
195and using
196.Nm hammer2
197directives to create the desired cluster.
198.El
199.Pp
200The
201.Ar bootsize
202and
203.Ar auxsize
204must be given with a suffix of
205.Cm K , M , G
206or
207.Cm T
208meaning kilobyte, megabyte, gigabyte and terabyte.
209Lower case can also be used for suffix.
210These options create reserved blocks of space on the target volume
211but are not currently used by the filesystem for anything.
212.Sh EXIT STATUS
213.Ex -std
214.Sh EXAMPLES
215.Bd -literal -offset indent
216newfs_hammer2 -L SATURN-HOME /dev/ad0s1d
217.Ed
218.Pp
219Create a file system named
220.Sq SATURN-HOME
221on
222.Pa /dev/ad0s1d .
223.Sh SEE ALSO
224.Xr disklabel32 5 ,
225.Xr disklabel64 5 ,
226.Xr fdisk 8 ,
227.Xr gpt 8 ,
228.Xr mount_hammer2 8 ,
229.Xr newfs 8
230.Sh HISTORY
231The
232.Nm
233utility first appeared in
234.Dx 3.1
235but was not enabled unconditionally until
236.Dx 4.9 .
237.Sh AUTHORS
238.An Matthew Dillon Aq Mt dillon@backplane.com
239