xref: /freebsd/sys/contrib/openzfs/man/man8/zfs-create.8 (revision 59c8e88e72633afbc47a4ace0d2170d00d51f7dc)
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 https://opensource.org/licenses/CDDL-1.0.
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.\" Copyright (c) 2009 Sun Microsystems, Inc. All Rights Reserved.
22.\" Copyright 2011 Joshua M. Clulow <josh@sysmgr.org>
23.\" Copyright (c) 2011, 2019 by Delphix. All rights reserved.
24.\" Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
25.\" Copyright (c) 2014, Joyent, Inc. All rights reserved.
26.\" Copyright (c) 2014 by Adam Stevko. All rights reserved.
27.\" Copyright (c) 2014 Integros [integros.com]
28.\" Copyright 2019 Richard Laager. All rights reserved.
29.\" Copyright 2018 Nexenta Systems, Inc.
30.\" Copyright 2019 Joyent, Inc.
31.\"
32.Dd March 16, 2022
33.Dt ZFS-CREATE 8
34.Os
35.
36.Sh NAME
37.Nm zfs-create
38.Nd create ZFS dataset
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.
52.Sh DESCRIPTION
53.Bl -tag -width ""
54.It Xo
55.Nm zfs
56.Cm create
57.Op Fl Pnpuv
58.Oo Fl o Ar property Ns = Ns Ar value Oc Ns …
59.Ar filesystem
60.Xc
61Creates a new ZFS file system.
62The file system is automatically mounted according to the
63.Sy mountpoint
64property inherited from the parent, unless the
65.Fl u
66option is used.
67.Bl -tag -width "-o"
68.It Fl o Ar property Ns = Ns Ar value
69Sets the specified property as if the command
70.Nm zfs Cm set Ar property Ns = Ns Ar value
71was invoked at the same time the dataset was created.
72Any editable ZFS property can also be set at creation time.
73Multiple
74.Fl o
75options can be specified.
76An error results if the same property is specified in multiple
77.Fl o
78options.
79.It Fl p
80Creates all the non-existing parent datasets.
81Datasets created in this manner are automatically mounted according to the
82.Sy mountpoint
83property inherited from their parent.
84Any property specified on the command line using the
85.Fl o
86option is ignored.
87If the target filesystem already exists, the operation completes successfully.
88.It Fl n
89Do a dry-run
90.Pq Qq No-op
91creation.
92No datasets will be created.
93This is useful in conjunction with the
94.Fl v
95or
96.Fl P
97flags to validate properties that are passed via
98.Fl o
99options and those implied by other options.
100The actual dataset creation can still fail due to insufficient privileges or
101available capacity.
102.It Fl P
103Print machine-parsable verbose information about the created dataset.
104Each line of output contains a key and one or two values, all separated by tabs.
105The
106.Sy create_ancestors
107and
108.Sy create
109keys have
110.Em filesystem
111as their only value.
112The
113.Sy create_ancestors
114key only appears if the
115.Fl p
116option is used.
117The
118.Sy property
119key has two values, a property name that property's value.
120The
121.Sy property
122key may appear zero or more times, once for each property that will be set local
123to
124.Em filesystem
125due to the use of the
126.Fl o
127option.
128.It Fl u
129Do not mount the newly created file system.
130.It Fl v
131Print verbose information about the created dataset.
132.El
133.It Xo
134.Nm zfs
135.Cm create
136.Op Fl ps
137.Op Fl b Ar blocksize
138.Oo Fl o Ar property Ns = Ns Ar value Oc Ns …
139.Fl V Ar size Ar volume
140.Xc
141Creates a volume of the given size.
142The volume is exported as a block device in
143.Pa /dev/zvol/path ,
144where
145.Em path
146is the name of the volume in the ZFS namespace.
147The size represents the logical size as exported by the device.
148By default, a reservation of equal size is created.
149.Pp
150.Ar size
151is automatically rounded up to the nearest multiple of the
152.Sy blocksize .
153.Bl -tag -width "-b"
154.It Fl b Ar blocksize
155Equivalent to
156.Fl o Sy volblocksize Ns = Ns Ar blocksize .
157If this option is specified in conjunction with
158.Fl o Sy volblocksize ,
159the resulting behavior is undefined.
160.It Fl o Ar property Ns = Ns Ar value
161Sets the specified property as if the
162.Nm zfs Cm set Ar property Ns = Ns Ar value
163command was invoked at the same time the dataset was created.
164Any editable ZFS property can also be set at creation time.
165Multiple
166.Fl o
167options can be specified.
168An error results if the same property is specified in multiple
169.Fl o
170options.
171.It Fl p
172Creates all the non-existing parent datasets.
173Datasets created in this manner are automatically mounted according to the
174.Sy mountpoint
175property inherited from their parent.
176Any property specified on the command line using the
177.Fl o
178option is ignored.
179If the target filesystem already exists, the operation completes successfully.
180.It Fl s
181Creates a sparse volume with no reservation.
182See
183.Sy volsize
184in the
185.Em Native Properties
186section of
187.Xr zfsprops 7
188for more information about sparse volumes.
189.It Fl n
190Do a dry-run
191.Pq Qq No-op
192creation.
193No datasets will be created.
194This is useful in conjunction with the
195.Fl v
196or
197.Fl P
198flags to validate properties that are passed via
199.Fl o
200options and those implied by other options.
201The actual dataset creation can still fail due to insufficient privileges or
202available capacity.
203.It Fl P
204Print machine-parsable verbose information about the created dataset.
205Each line of output contains a key and one or two values, all separated by tabs.
206The
207.Sy create_ancestors
208and
209.Sy create
210keys have
211.Em volume
212as their only value.
213The
214.Sy create_ancestors
215key only appears if the
216.Fl p
217option is used.
218The
219.Sy property
220key has two values, a property name that property's value.
221The
222.Sy property
223key may appear zero or more times, once for each property that will be set local
224to
225.Em volume
226due to the use of the
227.Fl b
228or
229.Fl o
230options, as well as
231.Sy refreservation
232if the volume is not sparse.
233.It Fl v
234Print verbose information about the created dataset.
235.El
236.El
237.Ss ZFS for Swap
238Swapping to a ZFS volume is prone to deadlock and not recommended.
239See OpenZFS FAQ.
240.Pp
241Swapping to a file on a ZFS filesystem is not supported.
242.
243.Sh EXAMPLES
244.\" These are, respectively, examples 1, 10 from zfs.8
245.\" Make sure to update them bidirectionally
246.Ss Example 1 : No Creating a ZFS File System Hierarchy
247The following commands create a file system named
248.Ar pool/home
249and a file system named
250.Ar pool/home/bob .
251The mount point
252.Pa /export/home
253is set for the parent file system, and is automatically inherited by the child
254file system.
255.Dl # Nm zfs Cm create Ar pool/home
256.Dl # Nm zfs Cm set Sy mountpoint Ns = Ns Ar /export/home pool/home
257.Dl # Nm zfs Cm create Ar pool/home/bob
258.
259.Ss Example 2 : No Promoting a ZFS Clone
260The following commands illustrate how to test out changes to a file system, and
261then replace the original file system with the changed one, using clones, clone
262promotion, and renaming:
263.Bd -literal -compact -offset Ds
264.No # Nm zfs Cm create Ar pool/project/production
265  populate /pool/project/production with data
266.No # Nm zfs Cm snapshot Ar pool/project/production Ns @ Ns Ar today
267.No # Nm zfs Cm clone Ar pool/project/production@today pool/project/beta
268  make changes to /pool/project/beta and test them
269.No # Nm zfs Cm promote Ar pool/project/beta
270.No # Nm zfs Cm rename Ar pool/project/production pool/project/legacy
271.No # Nm zfs Cm rename Ar pool/project/beta pool/project/production
272  once the legacy version is no longer needed, it can be destroyed
273.No # Nm zfs Cm destroy Ar pool/project/legacy
274.Ed
275.
276.Sh SEE ALSO
277.Xr zfs-destroy 8 ,
278.Xr zfs-list 8 ,
279.Xr zpool-create 8
280