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