.TH "mkfs.ocfs2" "8" "January 2012" "Version @VERSION@" "OCFS2 Manual Pages"
.SH "NAME"
mkfs.ocfs2 \- Creates an \fIOCFS2\fR file system.
.SH "SYNOPSIS"
\fBmkfs.ocfs2\fR [\fB\-b\fR \fIblock\-size\fR] [\fB\-C\fR \fIcluster\-size\fR] [\fB\-L\fR \fIvolume\-label\fR] [\fB\-M\fR \fImount-type\fR] [\fB\-N\fR \fInumber\-of\-nodes\fR] [\fB\-J\fR \fIjournal\-options\fR] [\fB\-\-fs\-features=\fR\fI[no]sparse...\fR] [\fB\-\-fs\-feature\-level=\fR\fIfeature\-level\fR] [\fB\-T\fR \fIfilesystem\-type\fR] [\fB\-\-cluster\-stack=\fR\fIstackname\fR] [\fB\-\-cluster\-name=\fR\fIclustername\fR] [\fB\-\-global\-heartbeat\fR] [\fB\-\-discard | \-\-nodiscard\fR] [\fB\-FqvV\fR] \fIdevice\fR [\fIblocks-count\fI]
.SH "DESCRIPTION"
.PP
\fBmkfs.ocfs2\fR is used to create an \fIOCFS2\fR file system on a \fIdevice\fR,
usually a partition on a shared disk. In order to prevent data loss,
\fBmkfs.ocfs2\fR will not format an existing \fIOCFS2\fR volume if it
detects that it is mounted on another node in the cluster. This tool
requires the cluster service to be online.

.SH "OPTIONS"
.TP
\fB\-b, \-\-block\-size\fR \fIblock\-size\fR
Valid block size values are 512, 1K, 2K and 4K bytes per block. If
omitted, a value will be heuristically determined based on the
expected usage of the file system (see the \fB\-T\fR option). A block
size of 512 bytes is never recommended. Choose 1K, 2K or 4K.

.TP
\fB\-C, \-\-cluster\-size\fR \fIcluster\-size\fR
Valid cluster size values are 4K, 8K, 16K, 32K, 64K, 128K, 256K, 512K
and 1M. If omitted, a value will be heuristically determined based on
the expected usage of the file system (see the \fB\-T\fR option). For
volumes expected to store large files, like database files, while a
cluster size of 128K or more is recommended, one can opt for a smaller
size as long as that value is not smaller than the database block size.
For others, use 4K.

.TP
\fB\-F, \-\-force\fR
For existing \fIOCFS2\fR volumes, \fImkfs.ocfs2\fR ensures the volume
is not mounted on any node in the cluster before formatting. For that to
work, \fImkfs.ocfs2\fR expects the cluster service to be online.
Specify this option to disable this check.

.TP
\fB\-J, \-\-journal-options\fR \fIoptions\fR
Create the journal using options specified on the command\-line. Journal
options are comma separated, and may take an argument using the equals
('=') sign. The following options are supported:

.RS
.TP
\fBsize\fR=\fIjournal\-size\fR
Create a journal of size \fIjournal\-size\fR. Minimum size is 4M.
If omitted, a value is heuristically determined based upon the file system size.

.TP
\fBblock32\fR
Use a standard 32bit journal.  The journal will be able to access up to
2^32-1 blocks.  This is the default.  It has been the journal format for
\fIOCFS2\fR volumes since the beginning.  The journal is compatible with
all versions of \fIOCFS2\fR.  Prepending \fBno\fR is equivalent to the
\fBblock64\fR journal option.

.TP
\fBblock64\fR
Use a 64bit journal.  The journal will be able to access up to 2^64-1
blocks.  This allows large filesystems that can extend to the
theoretical limits of \fIOCFS2\fR.  It requires a new-enough filesystem
driver that uses the new journalled block device, \fBJBD2\fR. Prepending
\fBno\fR is equivalent to the \fBblock32\fR journal option.
.RE

.TP
\fB\-L, \-\-label\fR \fIvolume\-label\fR
Set the volume label for the file system. This is
useful for mounting\-by\-label. Limit the label to under 64 bytes.

.TP
\fB\-M, \-\-mount\fR \fImount\-type\fR
Valid types are \fIlocal\fR and \fIcluster\fR. Local mount allows users
to mount the volume without the cluster overhead and works only with \fIOCFS2\fR
bundled with Linux kernels 2.6.20 or later. Defaults to \fIcluster\fR.

.TP
\fB\-N, \-\-node\-slots\fR \fInumber\-of\-node\-slots\fR
Valid number ranges from 1 to 255. This number specifies the maximum
number of nodes that can concurrently mount the partition. If omitted,
the number depends on volume size, for volume size < 2G, it's 2, for
2G <= size < 10G, it's 4, for 10G <= size < 1T, it's 8, for other size,
it's 16. The number of slots can be later tuned up or down using \fItunefs.ocfs2\fR.

.TP
\fB\-T\fR \fIfilesystem\-type\fR
Specify how the filesystem is going to be used, so that \fImkfs.ocfs2\fR can
chose optimal filesystem parameters for that use. The supported
filesystem types are:

.RS
.TP
\fBmail\fR
Appropriate for file systems that will host lots of small files.

.TP
\fBdatafiles\fR
Appropriate for file systems that will host a relatively small number
of very large files.

.TP
\fBvmstore\fR
Appropriate for file systems that will host Virtual machine images.
.RE

.TP
\fB\-\-fs\-features=\fR\fR\fI[no]sparse...\fR
Turn specific file system features on or off. A comma separated list of feature flags can be provided, and \fImkfs.ocfs2\fR will try to create the file system with those features set according to the list. To turn a feature on, include it in the list. To turn a feature off, prepend \fBno\fR to the name. Choices here will override individual features set via the \fB\-\-fs\-feature\-level\fR option. \fBRefer to the section titled feature compatibility before selecting specific features.\fR The following flags are supported:

.RS
.TP
\fBbackup-super\fR
\fImkfs.ocfs2\fR, by default, makes up to 6 backup copies of the super block at offsets 1G, 4G, 16G, 64G, 256G and 1T depending on the size of the volume.  This can be useful in disaster recovery. This feature is fully compatible with all versions of the file system and generally should not be disabled.

.TP
\fBlocal\fR
Create the file system as a local mount, so that it can be mounted without a cluster stack.

.TP
\fBsparse\fR
Enable support for sparse files. With this, \fIOCFS2\fR can avoid allocating (and zeroing) data to fill holes. Turn this feature on if you can, otherwise extends and some writes might be less performant.

.TP
\fBunwritten\fR
Enable unwritten extents support. With this turned on, an application can request that a range of clusters be pre-allocated within a file. \fIOCFS2\fR will mark those extents with a special flag so that expensive data zeroing doesn't have to be performed. Reads and writes to a pre-allocated region act as reads and writes to a hole, except a write will not fail due to lack of data allocation. This feature requires \fBsparse\fR file support to be turned on.

.TP
\fBinline-data\fR
Enable inline-data support. If this feature is turned on, \fIOCFS2\fR will store small files and directories inside the inode block. Data is transparently moved out to an extent when it no longer fits inside the inode block. In some cases, this can also make a positive impact on cold-cache directory and file operations.

.TP
\fBextended-slotmap\fR
The slot-map is a hidden file on an \fIOCFS2\fR fs which is used to map mounted nodes to system file resources. The extended slot map allows a larger range of possible node numbers, which is useful for userspace cluster stacks. If required, this feature is automatically turned on by \fImkfs.ocfs2\fR.

.TP
\fBmetaecc\fR
Enables metadata checksums. With this enabled, the file system computes and stores the checksums in all metadata blocks. It also computes and stores an error correction code capable of fixing single bit errors.

.TP
\fBrefcount\fR
Enables creation of reference counted trees. With this enabled, the file system allows users to create inode-based snapshots and clones known as \fBreflinks\fR.

.TP
\fBxattr\fR
Enable extended attributes support. With this enabled, users can attach name:value pairs to objects
within the file system. In \fIOCFS2\fR, the names can be up to 255 bytes in length, terminated by the first
NUL byte. While it is not required, printable names (ASCII) are recommended. The values can be up to 64KB of
arbitrary binary data. Attributes can be attached to all types of inodes: regular files, directories,
symbolic links, device nodes, etc. This feature is required for users wanting to use extended security
facilities like POSIX ACLs or SELinux.

.TP
\fBusrquota\fR
Enable user quota support. With this feature enabled, filesystem will track amount of space
and number of inodes (files, directories, symbolic links) each user owns. It is then possible
to limit the maximum amount of space or inodes user can have. See a documentation of
quota-tools package for more details.

.TP
\fBgrpquota\fR
Enable group quota support. With this feature enabled, filesystem will track amount of space
and number of inodes (files, directories, symbolic links) each group owns. It is then possible
to limit the maximum amount of space or inodes user can have. See a documentation of
quota-tools package for more details.

.TP
\fBindexed-dirs\fR
Enable directory indexing support. With this feature enabled, the file system creates indexed tree for non-inline directory entries. For large scale directories, directory entry lookup performance from the indexed tree is faster then from the legacy directory blocks.

.TP
\fBdiscontig-bg\fR
Enables discontiguous block groups. With this feature enabled, the file system is able to grow
the inode and the extent allocators even when there is no contiguous free chunk available. It
allows the file system to grow the allocators in smaller (discontiguous) chunks.

.TP
\fBclusterinfo\fR
Enables storing the cluster stack information in the superblock. This feature is needed
to support userspace cluster stacks and the global heartbeat mode in the \fBo2cb\fR
cluster stack. If needed, this feature is automatically turned on by \fImkfs.ocfs2\fR.
.RE

.TP
\fB\-\-fs\-feature\-level=\fR\fR\fIfeature\-level\fR
Choose from a set of pre-determined file-system features. This option is designed to allow users to conveniently choose a set of file system features which fits their needs. There is no downside to trying a set of features which your module might not support - if it won't mount the new file system simply reformat at a lower level. Feature levels can be fine-tuned via the \fB\-\-fs\-features\fR option. Currently, there are 3 types of feature levels:

.RS
.TP
\fBmax-compat\fR
Chooses fewer features but ensures that the file system can be mounted from older versions of the \fIOCFS2\fR module.

.TP
\fBdefault\fR
The default feature set tries to strike a balance between providing new features and maintaining
compatibility with relatively recent versions of \fIOCFS2\fR. It currently enables \fBsparse\fR,
\fBunwritten\fR, \fBinline-data\fR, \fBxattr\fR, \fBindexed-dirs\fR, \fBdiscontig-bg\fR, \fBrefcount\fR,
\fBextended-slotmap\fR and \fBclusterinfo\fR.

.TP
\fBmax-features\fR
Choose the maximum amount of features available. This will typically provide the best performance from \fIOCFS2\fR at the expense of creating a file system that is only compatible with very recent versions of the \fIOCFS2\fR kernel module.
.RE

.TP
\fB\-\-cluster\-stack\fR
Specify the cluster stack. This option is normally not required as \fImkfs.ocfs2\fR
chooses the currently active cluster stack. It is required only if the cluster stack
is not online and the user wishes to use a stack other than the default,
\fBo2cb\fR. Other supported cluster stacks are \fBpcmk\fR (Pacemaker) and \fBcman\fR
(rgmanager). Once set, \fIOCFS2\fR will only allow mounting the volume if the active
cluster stack and cluster name matches the one specified on-disk.

.TP
\fB\-\-cluster\-name\fR
Specify the name of the cluster. This option is mandatory if the user has specified
a \fIcluster\-stack\fR. This name is restricted to a max of 16 characters. Additionally,
the \fBo2cb\fR cluster stack allows only alpha-numeric characters.

.TP
\fB\-\-global\-heartbeat\fR
Enable the global heartbeat mode of the \fBo2cb\fR cluster stack. This option is not
required if the \fBo2cb\fR cluster stack with global heartbeat is online as \fImkfs.ocfs2\fR
will detect the active stack. However, if the cluster stack is not up, then this option
is required alongwith \fIcluster\-stack\fR and \fIcluster\-name\fR.  For more, refer to
\fBo2cb(7)\fR.

.TP
\fB\-\-discard\fR
Attempt to discard blocks at mkfs time (discarding blocks initially is useful
on solid state devices and sparse / thin-provisioned storage). When the device
advertises that discard also zeroes data (any subsequent read after the discard
and before write returns zero), then mark all not-yet-zeroed blocks as
zeroed. This significantly speeds up filesystem initialization. This is set
as default.

.TP
\fB\-\-nodiscard\fR
Do not attempt to discard blocks at mkfs time.

.TP
\fB\-\-no-backup-super\fR
This option is deprecated, please use \fB--fs-features=nobackup-super\fR instead.

.TP
\fB\-n, --dry-run\fR
Display the heuristically determined values without overwriting the existing file system.

.TP
\fB\-q, \-\-quiet\fR
Quiet mode.

.TP
\fB\-U\fR \fIuuid\fR
Specify a custom UUID in the plain (2A4D1C581FAA42A1A41D26EFC90C1315) or
traditional (2a4d1c58-1faa-42a1-a41d-26efc90c1315) format. This option in
\fBnot\fR recommended because the file system uses the UUID to uniquely identify
a file system. \fBIf more than one file system were to have the same UUID, one
is very likely to encounter erratic behavior, if not, outright file system
corruption.\fR

.TP
\fB\-v, \-\-verbose\fR
Verbose mode.

.TP
\fB\-V, \-\-version\fR
Print version and exit.

.TP
\fIblocks-count\fR
Usually \fBmkfs.ocfs2\fR automatically determines the size of the given device
and creates a file system that uses all of the available space on the
device.  This optional argument specifies that the file system should only
consume the given number of file system blocks (see \fB-b\fR) on the device.

.SH "FEATURE COMPATIBILITY"
This section lists the file system features that have been added to the \fIOCFS2\fR
file system and the version that it first appeared in. The table below lists the versions
of the mainline Linux kernel and ocfs2-tools. Users should use this information to
enable only those features that are available in the file system that they are using.
Before enabling new features, users are advised to review to the section titled
\fBfeature values\fR.

.TS
CENTER ALLBOX;
LB LB LB
LI C C.
Feature	Kernel Version	Tools Version
local	Linux 2.6.20	ocfs2-tools 1.2
sparse	Linux 2.6.22	ocfs2-tools 1.4
unwritten	Linux 2.6.23	ocfs2-tools 1.4
inline-data	Linux 2.6.24	ocfs2-tools 1.4
extended-slotmap	Linux 2.6.27	ocfs2-tools 1.6
metaecc	Linux 2.6.29	ocfs2-tools 1.6
grpquota	Linux 2.6.29	ocfs2-tools 1.6
usrquota	Linux 2.6.29	ocfs2-tools 1.6
xattr	Linux 2.6.29	ocfs2-tools 1.6
indexed-dirs	Linux 2.6.30	ocfs2-tools 1.6
refcount	Linux 2.6.32	ocfs2-tools 1.6
discontig-bg	Linux 2.6.35	ocfs2-tools 1.6
clusterinfo	Linux 2.6.37	ocfs2-tools 1.8
.TE

.TS
;
L.
Users can query the features enabled in the file system as follows:
.TE

.nf
.ft 6
# tunefs.ocfs2 -Q "Label: %V\\nFeatures: %H %O\\n" /dev/sdg1
Label: apache_files_10
Features: sparse inline-data unwritten
.ft
.fi

.SH "FEATURE VALUES"
This section lists the hex values that are associated with the file system features.
This information is useful when debugging mount failures that are due to feature
incompatibility. When a user attempts to mount an \fBOCFS2\fR volume that has features
enabled that are not supported by the running file system software, it will fail
with an error like:

.nf
.ps 9
.ft 6
ERROR: couldn't mount because of unsupported optional features (200).
.ft
.ps
.fi

By referring to the table below, it becomes apparent that the user attempted to mount
a volume with the \fIxattr\fR (extended attributes) feature enabled with a version of
the file system software that did not support it. At this stage, the user has the option
of either upgrading the file system software, or, disabling that on-disk feature using
\fBtunefs.ocfs2\fR.

Some features allow the file system to be mounted with an older version of the software
provided the mount is read-only. If a user attempts to mount such a volume in a read-write
mode, it will fail with an error like:

.nf
.ps 9
.ft 6
ERROR: couldn't mount RDWR because of unsupported optional features (1).
.ft
.ps
.fi

This error indicates that the volume had the \fIunwritten\fR RO compat feature enabled.
This volume can be mounted by an older file system software only in the read-only mode.
In this case, the user has the option of either mounting the volume with the \fIro\fR
mount option, or, disabling that on-disk feature using \fBtunefs.ocfs2\fR.

.TS
CENTER ALLBOX;
LI LI LI
LI C C.
Feature	Category	Hex value
local	Incompat	8
sparse	Incompat	10
inline-data	Incompat	40
extended-slotmap	Incompat	100
xattr	Incompat	200
indexed-dirs	Incompat	400
metaecc	Incompat	800
refcount	Incompat	1000
discontig-bg	Incompat	2000
clusterinfo	Incompat	4000
unwritten	RO Compat	1
usrquota	RO Compat	2
grpquota	RO Compat	4
.TE


.SH "SEE ALSO"
.BR debugfs.ocfs2(8)
.BR fsck.ocfs2(8)
.BR mount.ocfs2(8)
.BR mounted.ocfs2(8)
.BR o2cb(7)
.BR o2cluster(8)
.BR o2image(8)
.BR o2info(1)
.BR tunefs.ocfs2(8)

.SH "AUTHORS"
Oracle Corporation

.SH "COPYRIGHT"
Copyright \(co 2004, 2012 Oracle. All rights reserved.
