xref: /freebsd/sys/contrib/openzfs/man/man8/zfs-create.8 (revision 4e8d558c9d1cf3e7e424e3fb123b01979c3d57f2)
1eda14cbcSMatt Macy.\"
2eda14cbcSMatt Macy.\" CDDL HEADER START
3eda14cbcSMatt Macy.\"
4eda14cbcSMatt Macy.\" The contents of this file are subject to the terms of the
5eda14cbcSMatt Macy.\" Common Development and Distribution License (the "License").
6eda14cbcSMatt Macy.\" You may not use this file except in compliance with the License.
7eda14cbcSMatt Macy.\"
8eda14cbcSMatt Macy.\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9271171e0SMartin Matuska.\" or https://opensource.org/licenses/CDDL-1.0.
10eda14cbcSMatt Macy.\" See the License for the specific language governing permissions
11eda14cbcSMatt Macy.\" and limitations under the License.
12eda14cbcSMatt Macy.\"
13eda14cbcSMatt Macy.\" When distributing Covered Code, include this CDDL HEADER in each
14eda14cbcSMatt Macy.\" file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15eda14cbcSMatt Macy.\" If applicable, add the following below this CDDL HEADER, with the
16eda14cbcSMatt Macy.\" fields enclosed by brackets "[]" replaced with your own identifying
17eda14cbcSMatt Macy.\" information: Portions Copyright [yyyy] [name of copyright owner]
18eda14cbcSMatt Macy.\"
19eda14cbcSMatt Macy.\" CDDL HEADER END
20eda14cbcSMatt Macy.\"
21eda14cbcSMatt Macy.\" Copyright (c) 2009 Sun Microsystems, Inc. All Rights Reserved.
22eda14cbcSMatt Macy.\" Copyright 2011 Joshua M. Clulow <josh@sysmgr.org>
23eda14cbcSMatt Macy.\" Copyright (c) 2011, 2019 by Delphix. All rights reserved.
24eda14cbcSMatt Macy.\" Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
25eda14cbcSMatt Macy.\" Copyright (c) 2014, Joyent, Inc. All rights reserved.
26eda14cbcSMatt Macy.\" Copyright (c) 2014 by Adam Stevko. All rights reserved.
27eda14cbcSMatt Macy.\" Copyright (c) 2014 Integros [integros.com]
28eda14cbcSMatt Macy.\" Copyright 2019 Richard Laager. All rights reserved.
29eda14cbcSMatt Macy.\" Copyright 2018 Nexenta Systems, Inc.
30eda14cbcSMatt Macy.\" Copyright 2019 Joyent, Inc.
31eda14cbcSMatt Macy.\"
32da5137abSMartin Matuska.Dd March 16, 2022
33eda14cbcSMatt Macy.Dt ZFS-CREATE 8
34eda14cbcSMatt Macy.Os
3516038816SMartin Matuska.
36eda14cbcSMatt Macy.Sh NAME
377877fdebSMatt Macy.Nm zfs-create
3816038816SMartin Matuska.Nd create ZFS dataset
39eda14cbcSMatt Macy.Sh SYNOPSIS
40eda14cbcSMatt Macy.Nm zfs
41eda14cbcSMatt Macy.Cm create
427877fdebSMatt Macy.Op Fl Pnpuv
4316038816SMartin Matuska.Oo Fl o Ar property Ns = Ns Ar value Oc Ns …
44eda14cbcSMatt Macy.Ar filesystem
457877fdebSMatt Macy.Nm zfs
46eda14cbcSMatt Macy.Cm create
47eda14cbcSMatt Macy.Op Fl ps
48eda14cbcSMatt Macy.Op Fl b Ar blocksize
4916038816SMartin Matuska.Oo Fl o Ar property Ns = Ns Ar value Oc Ns …
50eda14cbcSMatt Macy.Fl V Ar size Ar volume
5116038816SMartin Matuska.
52eda14cbcSMatt Macy.Sh DESCRIPTION
53eda14cbcSMatt Macy.Bl -tag -width ""
54eda14cbcSMatt Macy.It Xo
557877fdebSMatt Macy.Nm zfs
56eda14cbcSMatt Macy.Cm create
577877fdebSMatt Macy.Op Fl Pnpuv
5816038816SMartin Matuska.Oo Fl o Ar property Ns = Ns Ar value Oc Ns …
59eda14cbcSMatt Macy.Ar filesystem
60eda14cbcSMatt Macy.Xc
61eda14cbcSMatt MacyCreates a new ZFS file system.
62eda14cbcSMatt MacyThe file system is automatically mounted according to the
63eda14cbcSMatt Macy.Sy mountpoint
647877fdebSMatt Macyproperty inherited from the parent, unless the
657877fdebSMatt Macy.Fl u
667877fdebSMatt Macyoption is used.
67eda14cbcSMatt Macy.Bl -tag -width "-o"
68eda14cbcSMatt Macy.It Fl o Ar property Ns = Ns Ar value
69eda14cbcSMatt MacySets the specified property as if the command
70eda14cbcSMatt Macy.Nm zfs Cm set Ar property Ns = Ns Ar value
71eda14cbcSMatt Macywas invoked at the same time the dataset was created.
72eda14cbcSMatt MacyAny editable ZFS property can also be set at creation time.
73eda14cbcSMatt MacyMultiple
74eda14cbcSMatt Macy.Fl o
75eda14cbcSMatt Macyoptions can be specified.
76eda14cbcSMatt MacyAn error results if the same property is specified in multiple
77eda14cbcSMatt Macy.Fl o
78eda14cbcSMatt Macyoptions.
79eda14cbcSMatt Macy.It Fl p
80eda14cbcSMatt MacyCreates all the non-existing parent datasets.
81eda14cbcSMatt MacyDatasets created in this manner are automatically mounted according to the
82eda14cbcSMatt Macy.Sy mountpoint
83eda14cbcSMatt Macyproperty inherited from their parent.
84eda14cbcSMatt MacyAny property specified on the command line using the
85eda14cbcSMatt Macy.Fl o
86eda14cbcSMatt Macyoption is ignored.
87eda14cbcSMatt MacyIf the target filesystem already exists, the operation completes successfully.
88eda14cbcSMatt Macy.It Fl n
89eda14cbcSMatt MacyDo a dry-run
90eda14cbcSMatt Macy.Pq Qq No-op
91eda14cbcSMatt Macycreation.
92eda14cbcSMatt MacyNo datasets will be created.
93eda14cbcSMatt MacyThis is useful in conjunction with the
94eda14cbcSMatt Macy.Fl v
95eda14cbcSMatt Macyor
96eda14cbcSMatt Macy.Fl P
97eda14cbcSMatt Macyflags to validate properties that are passed via
98eda14cbcSMatt Macy.Fl o
99eda14cbcSMatt Macyoptions and those implied by other options.
100eda14cbcSMatt MacyThe actual dataset creation can still fail due to insufficient privileges or
101eda14cbcSMatt Macyavailable capacity.
102eda14cbcSMatt Macy.It Fl P
103eda14cbcSMatt MacyPrint machine-parsable verbose information about the created dataset.
104eda14cbcSMatt MacyEach line of output contains a key and one or two values, all separated by tabs.
105eda14cbcSMatt MacyThe
106eda14cbcSMatt Macy.Sy create_ancestors
107eda14cbcSMatt Macyand
108eda14cbcSMatt Macy.Sy create
109eda14cbcSMatt Macykeys have
110eda14cbcSMatt Macy.Em filesystem
111eda14cbcSMatt Macyas their only value.
112eda14cbcSMatt MacyThe
113eda14cbcSMatt Macy.Sy create_ancestors
114eda14cbcSMatt Macykey only appears if the
115eda14cbcSMatt Macy.Fl p
116eda14cbcSMatt Macyoption is used.
117eda14cbcSMatt MacyThe
118eda14cbcSMatt Macy.Sy property
119eda14cbcSMatt Macykey has two values, a property name that property's value.
120eda14cbcSMatt MacyThe
121eda14cbcSMatt Macy.Sy property
122eda14cbcSMatt Macykey may appear zero or more times, once for each property that will be set local
123eda14cbcSMatt Macyto
124eda14cbcSMatt Macy.Em filesystem
125eda14cbcSMatt Macydue to the use of the
126eda14cbcSMatt Macy.Fl o
127eda14cbcSMatt Macyoption.
1287877fdebSMatt Macy.It Fl u
1297877fdebSMatt MacyDo not mount the newly created file system.
130eda14cbcSMatt Macy.It Fl v
131eda14cbcSMatt MacyPrint verbose information about the created dataset.
132eda14cbcSMatt Macy.El
133eda14cbcSMatt Macy.It Xo
1347877fdebSMatt Macy.Nm zfs
135eda14cbcSMatt Macy.Cm create
136eda14cbcSMatt Macy.Op Fl ps
137eda14cbcSMatt Macy.Op Fl b Ar blocksize
13816038816SMartin Matuska.Oo Fl o Ar property Ns = Ns Ar value Oc Ns …
139eda14cbcSMatt Macy.Fl V Ar size Ar volume
140eda14cbcSMatt Macy.Xc
141eda14cbcSMatt MacyCreates a volume of the given size.
142eda14cbcSMatt MacyThe volume is exported as a block device in
143eda14cbcSMatt Macy.Pa /dev/zvol/path ,
144eda14cbcSMatt Macywhere
145eda14cbcSMatt Macy.Em path
146eda14cbcSMatt Macyis the name of the volume in the ZFS namespace.
147eda14cbcSMatt MacyThe size represents the logical size as exported by the device.
148eda14cbcSMatt MacyBy default, a reservation of equal size is created.
149eda14cbcSMatt Macy.Pp
150eda14cbcSMatt Macy.Ar size
151eda14cbcSMatt Macyis automatically rounded up to the nearest multiple of the
152eda14cbcSMatt Macy.Sy blocksize .
153eda14cbcSMatt Macy.Bl -tag -width "-b"
154eda14cbcSMatt Macy.It Fl b Ar blocksize
155eda14cbcSMatt MacyEquivalent to
156eda14cbcSMatt Macy.Fl o Sy volblocksize Ns = Ns Ar blocksize .
157eda14cbcSMatt MacyIf this option is specified in conjunction with
158eda14cbcSMatt Macy.Fl o Sy volblocksize ,
159eda14cbcSMatt Macythe resulting behavior is undefined.
160eda14cbcSMatt Macy.It Fl o Ar property Ns = Ns Ar value
161eda14cbcSMatt MacySets the specified property as if the
162eda14cbcSMatt Macy.Nm zfs Cm set Ar property Ns = Ns Ar value
163eda14cbcSMatt Macycommand was invoked at the same time the dataset was created.
164eda14cbcSMatt MacyAny editable ZFS property can also be set at creation time.
165eda14cbcSMatt MacyMultiple
166eda14cbcSMatt Macy.Fl o
167eda14cbcSMatt Macyoptions can be specified.
168eda14cbcSMatt MacyAn error results if the same property is specified in multiple
169eda14cbcSMatt Macy.Fl o
170eda14cbcSMatt Macyoptions.
171eda14cbcSMatt Macy.It Fl p
172eda14cbcSMatt MacyCreates all the non-existing parent datasets.
173eda14cbcSMatt MacyDatasets created in this manner are automatically mounted according to the
174eda14cbcSMatt Macy.Sy mountpoint
175eda14cbcSMatt Macyproperty inherited from their parent.
176eda14cbcSMatt MacyAny property specified on the command line using the
177eda14cbcSMatt Macy.Fl o
178eda14cbcSMatt Macyoption is ignored.
179eda14cbcSMatt MacyIf the target filesystem already exists, the operation completes successfully.
180eda14cbcSMatt Macy.It Fl s
181eda14cbcSMatt MacyCreates a sparse volume with no reservation.
182eda14cbcSMatt MacySee
183eda14cbcSMatt Macy.Sy volsize
184eda14cbcSMatt Macyin the
185eda14cbcSMatt Macy.Em Native Properties
186eda14cbcSMatt Macysection of
1873ff01b23SMartin Matuska.Xr zfsprops 7
188eda14cbcSMatt Macyfor more information about sparse volumes.
189eda14cbcSMatt Macy.It Fl n
190eda14cbcSMatt MacyDo a dry-run
191eda14cbcSMatt Macy.Pq Qq No-op
192eda14cbcSMatt Macycreation.
193eda14cbcSMatt MacyNo datasets will be created.
194eda14cbcSMatt MacyThis is useful in conjunction with the
195eda14cbcSMatt Macy.Fl v
196eda14cbcSMatt Macyor
197eda14cbcSMatt Macy.Fl P
198eda14cbcSMatt Macyflags to validate properties that are passed via
199eda14cbcSMatt Macy.Fl o
200eda14cbcSMatt Macyoptions and those implied by other options.
201eda14cbcSMatt MacyThe actual dataset creation can still fail due to insufficient privileges or
202eda14cbcSMatt Macyavailable capacity.
203eda14cbcSMatt Macy.It Fl P
204eda14cbcSMatt MacyPrint machine-parsable verbose information about the created dataset.
205eda14cbcSMatt MacyEach line of output contains a key and one or two values, all separated by tabs.
206eda14cbcSMatt MacyThe
207eda14cbcSMatt Macy.Sy create_ancestors
208eda14cbcSMatt Macyand
209eda14cbcSMatt Macy.Sy create
210eda14cbcSMatt Macykeys have
211eda14cbcSMatt Macy.Em volume
212eda14cbcSMatt Macyas their only value.
213eda14cbcSMatt MacyThe
214eda14cbcSMatt Macy.Sy create_ancestors
215eda14cbcSMatt Macykey only appears if the
216eda14cbcSMatt Macy.Fl p
217eda14cbcSMatt Macyoption is used.
218eda14cbcSMatt MacyThe
219eda14cbcSMatt Macy.Sy property
220eda14cbcSMatt Macykey has two values, a property name that property's value.
221eda14cbcSMatt MacyThe
222eda14cbcSMatt Macy.Sy property
223eda14cbcSMatt Macykey may appear zero or more times, once for each property that will be set local
224eda14cbcSMatt Macyto
225eda14cbcSMatt Macy.Em volume
226eda14cbcSMatt Macydue to the use of the
227eda14cbcSMatt Macy.Fl b
228eda14cbcSMatt Macyor
229eda14cbcSMatt Macy.Fl o
230eda14cbcSMatt Macyoptions, as well as
231eda14cbcSMatt Macy.Sy refreservation
232eda14cbcSMatt Macyif the volume is not sparse.
233eda14cbcSMatt Macy.It Fl v
234eda14cbcSMatt MacyPrint verbose information about the created dataset.
235eda14cbcSMatt Macy.El
236eda14cbcSMatt Macy.El
237*4e8d558cSMartin Matuska.Ss ZFS for Swap
238*4e8d558cSMartin MatuskaSwapping to a ZFS volume is prone to deadlock and not recommended.
239*4e8d558cSMartin MatuskaSee OpenZFS FAQ.
240*4e8d558cSMartin Matuska.Pp
241*4e8d558cSMartin MatuskaSwapping to a file on a ZFS filesystem is not supported.
24216038816SMartin Matuska.
243da5137abSMartin Matuska.Sh EXAMPLES
244da5137abSMartin Matuska.\" These are, respectively, examples 1, 10 from zfs.8
245da5137abSMartin Matuska.\" Make sure to update them bidirectionally
246da5137abSMartin Matuska.Ss Example 1 : No Creating a ZFS File System Hierarchy
247da5137abSMartin MatuskaThe following commands create a file system named
248da5137abSMartin Matuska.Ar pool/home
249da5137abSMartin Matuskaand a file system named
250da5137abSMartin Matuska.Ar pool/home/bob .
251da5137abSMartin MatuskaThe mount point
252da5137abSMartin Matuska.Pa /export/home
253da5137abSMartin Matuskais set for the parent file system, and is automatically inherited by the child
254da5137abSMartin Matuskafile system.
255da5137abSMartin Matuska.Dl # Nm zfs Cm create Ar pool/home
256da5137abSMartin Matuska.Dl # Nm zfs Cm set Sy mountpoint Ns = Ns Ar /export/home pool/home
257da5137abSMartin Matuska.Dl # Nm zfs Cm create Ar pool/home/bob
258da5137abSMartin Matuska.
259da5137abSMartin Matuska.Ss Example 2 : No Promoting a ZFS Clone
260da5137abSMartin MatuskaThe following commands illustrate how to test out changes to a file system, and
261da5137abSMartin Matuskathen replace the original file system with the changed one, using clones, clone
262da5137abSMartin Matuskapromotion, and renaming:
263da5137abSMartin Matuska.Bd -literal -compact -offset Ds
264da5137abSMartin Matuska.No # Nm zfs Cm create Ar pool/project/production
265da5137abSMartin Matuska  populate /pool/project/production with data
266da5137abSMartin Matuska.No # Nm zfs Cm snapshot Ar pool/project/production Ns @ Ns Ar today
267da5137abSMartin Matuska.No # Nm zfs Cm clone Ar pool/project/production@today pool/project/beta
268da5137abSMartin Matuska  make changes to /pool/project/beta and test them
269da5137abSMartin Matuska.No # Nm zfs Cm promote Ar pool/project/beta
270da5137abSMartin Matuska.No # Nm zfs Cm rename Ar pool/project/production pool/project/legacy
271da5137abSMartin Matuska.No # Nm zfs Cm rename Ar pool/project/beta pool/project/production
272da5137abSMartin Matuska  once the legacy version is no longer needed, it can be destroyed
273da5137abSMartin Matuska.No # Nm zfs Cm destroy Ar pool/project/legacy
274da5137abSMartin Matuska.Ed
275da5137abSMartin Matuska.
276eda14cbcSMatt Macy.Sh SEE ALSO
277eda14cbcSMatt Macy.Xr zfs-destroy 8 ,
278eda14cbcSMatt Macy.Xr zfs-list 8 ,
279eda14cbcSMatt Macy.Xr zpool-create 8
280