mkfs Command

Purpose

Makes a file system.

Syntax

mkfs [ -b Boot ] [ -l Label ] [ -i i-Nodes ] [ -o Options ] [ -p Prototype ] [ -s Size ] [ -v VolumeLabel ] [ -V VfsName ] Device

Description

The mkfs command makes a new file system on a specified device. The mkfs command initializes the volume label, file system label, and startup block.

The Device parameter specifies a block device name, raw device name, or file system name. If the parameter specifies a file system name, the mkfs command uses this name to obtain the following parameters from the applicable stanza in the /etc/filesystems file, unless these parameters are entered with the mkfs command:

Item Description
dev Device name
vol Volume ID
size File system size
boot Program to be installed in the startup block
vfs Definition of the virtual file system
options File-system implementation-specific options of the form Keyword, Keyword=Value
Note:
  1. The file system is created with the setgid (set group ID) bit enabled. The setgid bit determines the default group permissions. All directories created under the new file system have the same default group permissions.
  2. The mkfs command does not alter anything in a mounted file system, including the file system label. The file system label changes when you change the mount point, unless the file system is mounted.
  3. For information about creating a file system on a striped logical volume, refer to File Systems on Striped Logical Volumes the mklv documentation.
  4. To create a JFS2 file system on a logical volume, the minor number of the logical volume must be greater than 3071.

Flags

Item Description
-b Boot Names the program to be installed in block 0 of the new file system.
-i i-Nodes Specifies the initial number of i-nodes on the file system. This flag is ignored when creating a journaled file system.
-l Label Specifies the file system label for the new file system.
-o Options Specifies a comma-separated list of virtual file system implementation-specific options.

The following options are specific to the Journaled File System (JFS):

Item Description
-o ag={ 8 | 16 | 32 | 64 } Specifies the allocation group size in megabytes. An allocation group is a grouping of i-nodes and disk blocks similar to BSD cylinder groups. The default ag value is 8.
-o bf={ true | false } Specifies a large file enabled file system. See JFS and large files for more information. If you do not need a large file enabled file system, set this option to false; this is the default. Specifying bf=true requires a fragment size of 4096 and compress=no.
-o frag={ 512 | 1024 | 2048 | 4096 } Specifies the JFS fragment size in bytes. A file system fragment is the smallest unit of disk storage that can be allocated to a file. The default fragment size is 4096 bytes.
-o compress={ no | LZ } Specifies data compression. If you do not want data to be compressed, set this option to no. Selecting compression requires a fragment size of 2048 or less.
-o nbpi={ 512 | 1024 | 2048 | 4096 |8192 | 16384 | 32768 | 65536 | 131072 } Specifies the number of bytes per i-node (nbpi). The nbpi is the ratio of file system size in bytes to the total number of i-nodes. The default nbpi value is 4096 bytes.
Notes:
  • The ag, bf, compress, frag, and nbpi attributes are set at file system creation and cannot be changed after the file system is successfully created. The size attribute defines the minimum file system size, and you cannot decrease it after the file system is created.
  • The root file system ( / ) cannot be compressed.
  • Some nbpi values and allocation group sizes are mutually exclusive. See "Understanding JFS Size Limitations" for information.

The following options are specific to the Enhanced Journaled File System:

Item Description
-o agblksize={ 512 | 1024 | 2048 | 4096 } Specifies the Enhanced Journaled File System (JFS2) block size in bytes. A file system block is the smallest unit of disk storage that can be allocated to a file. The default block size is 4096 bytes.
-o isnapshot={yes|no} Specifies whether the file system can support internal snapshots. Specifying yes enables the file system to support internal snapshots and v2 extended attributes. The resulting file system is not compatible with releases earlier than AIX® 6.1.
-o name=mountpoint Specifies the mount point for the file system.
-o log=LVName Specifies the log logical volume name. The specified logical volume is the logging device for the new JFS2.
-o log=INLINE

Specifies to place the log in the logical volume with the JFS2 file system. The INLINE log will default to .4% of the logical volume size if logsize is not specified.

-o logsize=Value Specifies the size for an INLINE log in MBytes. Ignored if INLINE log not being used. Cannot be greater than 2047 MBytes and cannot be greater than 10% of the size of the file system.
-o ea={v1 | v2} Specifies the format to be used to store named extended attributes in the JFS2 file system. The v2 format provides support for scalable named extended attributes as well as support for NFS4 ACLs. The v1 format is compatible with prior releases of AIX. The default format is v1.
-o efs={yes|no}

Specifies encryption. Specifying yes enables encryption for the JFS2 file system.

  • If the efs attribute is set to yes, the mkfs command automatically creates the JFS2 file system with the extended attribute format set to v2. The ea attribute is not required.
  • If the efs attribute is set to no, the mkfs command creates a file system that is not encrypted.
-o vix={yes|no}
Specifies whether the file system can allocate i-node extents smaller than the default of 16 KB, if there are no contiguous 16 KB extents free in the file system. After a file system is enabled for small free extents, the file system cannot be accessed on AIX 5.1 or earlier releases.
yes
The file system can allocate variable-length i-node extents. This is the default value beginning with AIX 6.1.
no
The file system must use the default size of 16 KB for i-node extents. This has no effect if the file system already contains variable-length i-node extents.
-o maxext=Value Specifies the maximum size of a file extent in file system blocks. A zero value implies that the JFS2 default maximum should be used. Values less than 0 or exceeding maximum supported extent size of 16777215 are invalid.
Note: The agblksize attribute is set at file system creation and cannot be changed after the file system is successfully created.

The ea attribute format is set at file system creation. The chfs command can be used to convert the extended attribute format from v1 to v2, but the format cannot be converted back. The conversion is done in an on-demand manner such that any extended attribute or ACL writes cause the conversion for that file object to occur.

Item Description
-p Prototype Specifies the name of the prototype file when you create a JFS file system. Options specified on the command line override attributes in the prototype file.
-s Size Specifies the size of the file system. Size can be specified in units of 512-byte blocks, megabytes (suffix M must be used) or gigabytes (suffix G must be used). See JFS and JFS2 for more information.
Notes:
  • The volume group in which the file system resides defines a maximum logical volume size and also limits the file system size.
  • The -s Size flag specifies the minimum file size and cannot be decreased after the file system has been successfully created.
  • The maxext attribute is ignored in older releases even if the filesystem was created with it on a later release .
Item Description
-v VolumeLabel Specifies the volume label for the new file system.
-V VfsName Specifies the virtual file system (VFS) type. The VFS must have an entry in the /etc/vfs file.
Restriction: The mkfs command prevents EFS File System enablement of the following File Systems (mount points) because the security infrastructure (kernel extensions, libraries, and so on) are not available when you start the system. The following list is of known File Systems (mount points) that you cannot use:
"/"
"/usr"
"/var"
"/opt"

Security

Access Control: Only the root user or a member of the system group can run this command.

Attention RBAC users and Trusted AIX users: This command can perform privileged operations. Only privileged users can run privileged operations. For more information about authorizations and privileges, see Privileged Command Database in Security. For a list of privileges and the authorizations that are associated with this command, see the lssecattr command or the getcmdattr subcommand.

Examples

  1. To specify the volume and file system name for a new file system, type:
    mkfs  -lworks  -vvol001 /dev/hd3
    This command creates an empty file system on the /dev/hd3 device, giving it the volume serial number vol001 and file system name works. The new file system occupies the entire device. The file system has a default fragment size (4096 bytes) and a default nbpi ratio (4096).
  2. To create a file system with nondefault attributes, type:
    mkfs  -s 8192  -o nbpi=2048,frag=512 /dev/lv01
    This command creates an empty 4 MB file system on the /dev/lv01 device with 512-byte fragments and 1 i-node for each 2048 bytes.
  3. To create a large file enabled file system, type:
    mkfs -V jfs -o nbpi=131072,bf=true,ag=64 /dev/lv01
    This creates a large file enabled JFS file system with an allocation group size of 64 megabytes and 1 i-node for every 131072 bytes of disk. The size of the file system will be the size of the logical volume lv01.
  4. To create a file system with nondefault attributes, type:
    mkfs -s 4M -o nbpi=2048, frag=512 /dev/lv01
    This command creates an empty 4 MB file system on the /dev/lv01 device with 512-byte fragments and one i-node for each 2048 bytes.
  5. To create a JFS2 file system which can support NFS4 ACLs, type:
    mkfs -V jfs2 -o ea=v2 /dev/lv01
    This command creates an empty file system on the /dev/lv01 device with v2 format for extended attributes.

Files

Item Description
/etc/vfs Contains descriptions of virtual file system types.
/etc/filesystems Lists the known file systems and defines their characteristics.