xref: /freebsd/sys/contrib/openzfs/man/man8/zfs-create.8 (revision cfd6422a5217410fbd66f7a7a8a64d9d85e61229)
1.\"
2.\" CDDL HEADER START
3.\"
4.\" The contents of this file are subject to the terms of the
5.\" Common Development and Distribution License (the "License").
6.\" You may not use this file except in compliance with the License.
7.\"
8.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9.\" or http://www.opensolaris.org/os/licensing.
10.\" See the License for the specific language governing permissions
11.\" and limitations under the License.
12.\"
13.\" When distributing Covered Code, include this CDDL HEADER in each
14.\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15.\" If applicable, add the following below this CDDL HEADER, with the
16.\" fields enclosed by brackets "[]" replaced with your own identifying
17.\" information: Portions Copyright [yyyy] [name of copyright owner]
18.\"
19.\" CDDL HEADER END
20.\"
21.\"
22.\" Copyright (c) 2009 Sun Microsystems, Inc. All Rights Reserved.
23.\" Copyright 2011 Joshua M. Clulow <josh@sysmgr.org>
24.\" Copyright (c) 2011, 2019 by Delphix. All rights reserved.
25.\" Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
26.\" Copyright (c) 2014, Joyent, Inc. All rights reserved.
27.\" Copyright (c) 2014 by Adam Stevko. All rights reserved.
28.\" Copyright (c) 2014 Integros [integros.com]
29.\" Copyright 2019 Richard Laager. All rights reserved.
30.\" Copyright 2018 Nexenta Systems, Inc.
31.\" Copyright 2019 Joyent, Inc.
32.\"
33.Dd December 1, 2020
34.Dt ZFS-CREATE 8
35.Os
36.Sh NAME
37.Nm zfs-create
38.Nd Creates a new ZFS file system.
39.Sh SYNOPSIS
40.Nm zfs
41.Cm create
42.Op Fl Pnpuv
43.Oo Fl o Ar property Ns = Ns Ar value Oc Ns ...
44.Ar filesystem
45.Nm zfs
46.Cm create
47.Op Fl ps
48.Op Fl b Ar blocksize
49.Oo Fl o Ar property Ns = Ns Ar value Oc Ns ...
50.Fl V Ar size Ar volume
51.Sh DESCRIPTION
52.Bl -tag -width ""
53.It Xo
54.Nm zfs
55.Cm create
56.Op Fl Pnpuv
57.Oo Fl o Ar property Ns = Ns Ar value Oc Ns ...
58.Ar filesystem
59.Xc
60Creates a new ZFS file system.
61The file system is automatically mounted according to the
62.Sy mountpoint
63property inherited from the parent, unless the
64.Fl u
65option is used.
66.Bl -tag -width "-o"
67.It Fl o Ar property Ns = Ns Ar value
68Sets the specified property as if the command
69.Nm zfs Cm set Ar property Ns = Ns Ar value
70was invoked at the same time the dataset was created.
71Any editable ZFS property can also be set at creation time.
72Multiple
73.Fl o
74options can be specified.
75An error results if the same property is specified in multiple
76.Fl o
77options.
78.It Fl p
79Creates all the non-existing parent datasets.
80Datasets created in this manner are automatically mounted according to the
81.Sy mountpoint
82property inherited from their parent.
83Any property specified on the command line using the
84.Fl o
85option is ignored.
86If the target filesystem already exists, the operation completes successfully.
87.It Fl n
88Do a dry-run
89.Pq Qq No-op
90creation.
91No datasets will be created.
92This is useful in conjunction with the
93.Fl v
94or
95.Fl P
96flags to validate properties that are passed via
97.Fl o
98options and those implied by other options.
99The actual dataset creation can still fail due to insufficient privileges or
100available capacity.
101.It Fl P
102Print machine-parsable verbose information about the created dataset.
103Each line of output contains a key and one or two values, all separated by tabs.
104The
105.Sy create_ancestors
106and
107.Sy create
108keys have
109.Em filesystem
110as their only value.
111The
112.Sy create_ancestors
113key only appears if the
114.Fl p
115option is used.
116The
117.Sy property
118key has two values, a property name that property's value.
119The
120.Sy property
121key may appear zero or more times, once for each property that will be set local
122to
123.Em filesystem
124due to the use of the
125.Fl o
126option.
127.It Fl u
128Do not mount the newly created file system.
129.It Fl v
130Print verbose information about the created dataset.
131.El
132.It Xo
133.Nm zfs
134.Cm create
135.Op Fl ps
136.Op Fl b Ar blocksize
137.Oo Fl o Ar property Ns = Ns Ar value Oc Ns ...
138.Fl V Ar size Ar volume
139.Xc
140Creates a volume of the given size.
141The volume is exported as a block device in
142.Pa /dev/zvol/path ,
143where
144.Em path
145is the name of the volume in the ZFS namespace.
146The size represents the logical size as exported by the device.
147By default, a reservation of equal size is created.
148.Pp
149.Ar size
150is automatically rounded up to the nearest multiple of the
151.Sy blocksize .
152.Bl -tag -width "-b"
153.It Fl b Ar blocksize
154Equivalent to
155.Fl o Sy volblocksize Ns = Ns Ar blocksize .
156If this option is specified in conjunction with
157.Fl o Sy volblocksize ,
158the resulting behavior is undefined.
159.It Fl o Ar property Ns = Ns Ar value
160Sets the specified property as if the
161.Nm zfs Cm set Ar property Ns = Ns Ar value
162command was invoked at the same time the dataset was created.
163Any editable ZFS property can also be set at creation time.
164Multiple
165.Fl o
166options can be specified.
167An error results if the same property is specified in multiple
168.Fl o
169options.
170.It Fl p
171Creates all the non-existing parent datasets.
172Datasets created in this manner are automatically mounted according to the
173.Sy mountpoint
174property inherited from their parent.
175Any property specified on the command line using the
176.Fl o
177option is ignored.
178If the target filesystem already exists, the operation completes successfully.
179.It Fl s
180Creates a sparse volume with no reservation.
181See
182.Sy volsize
183in the
184.Em Native Properties
185section of
186.Xr zfsprops 8
187for more information about sparse volumes.
188.It Fl n
189Do a dry-run
190.Pq Qq No-op
191creation.
192No datasets will be created.
193This is useful in conjunction with the
194.Fl v
195or
196.Fl P
197flags to validate properties that are passed via
198.Fl o
199options and those implied by other options.
200The actual dataset creation can still fail due to insufficient privileges or
201available capacity.
202.It Fl P
203Print machine-parsable verbose information about the created dataset.
204Each line of output contains a key and one or two values, all separated by tabs.
205The
206.Sy create_ancestors
207and
208.Sy create
209keys have
210.Em volume
211as their only value.
212The
213.Sy create_ancestors
214key only appears if the
215.Fl p
216option is used.
217The
218.Sy property
219key has two values, a property name that property's value.
220The
221.Sy property
222key may appear zero or more times, once for each property that will be set local
223to
224.Em volume
225due to the use of the
226.Fl b
227or
228.Fl o
229options, as well as
230.Sy refreservation
231if the volume is not sparse.
232.It Fl v
233Print verbose information about the created dataset.
234.El
235.El
236.Ss ZFS Volumes as Swap
237ZFS volumes may be used as swap devices. After creating the volume with the
238.Nm zfs Cm create Fl V
239command set up and enable the swap area using the
240.Xr mkswap 8
241and
242.Xr swapon 8
243commands. Do not swap to a file on a ZFS file system. A ZFS swap file
244configuration is not supported.
245.Sh SEE ALSO
246.Xr zfs-destroy 8 ,
247.Xr zfs-list 8 ,
248.Xr zpool-create 8
249