[ Previous | Next | Contents | Glossary | Home | Search ]
AIX Version 4.3 Commands Reference, Volume 3

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:

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
Notes:
  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.

Prototype Files

The mkfs command requires an extended prototype file to create a Journaled File System (JFS). A prototype file is a formatted listing of the contents and structure of a file system. A prototype file describes the file system by a series of tokens separated by spaces and new lines. The main body of a prototype file defines the objects of the file system.

A JFS prototype file consists of the main body, which can be created by the proto command, preceded by five special tokens. These five tokens are defined as follows:

1st token Name of a file to be copied onto block 0 as the bootstrap program or the special token <noboot>.
2nd token Size of the file system. For a JFS, the size is expressed in units of 512-byte blocks. If the 2nd token is 0, the mkfs command creates the file system to fill the entire logical volume.
3rd token Number of i-nodes on the file system. This token is not used by a JFS but must be provided to preserve the position.
4th token Fragment size of the file system in bytes. If the 4th token is 0 (zero), the mkfs command uses the default fragment size. For JFS, the token must be either 0 (default value used), 512, 1024, 2048, or 4096. The default fragment size is 4096 for a JFS. An invalid fragment size causes the mkfs command to fail.
5th token Number of bytes per i-node (nbpi). If this token is 0, the mkfs command uses the default nbpi. For a JFS, this token must be either 0 (default value used), 512, 1024, 2048, 4096, 8192, or 16384. The default number of bytes per i-node is 4096 for a JFS. An invalid nbpi causes the mkfs command to fail.

The remaining tokens define the contents and structure of the file system. These tokens are grouped into sets, with each set defining one object of the file system. The syntax of each set is as follows:

{ [ Name ] { - | d | b | c | l | L | p } { - | u } { - | g } { - | t } Mode Owner

Group { Major Minor | SourceFile | DirectoryListing } } | { $ }

where:

Name Specifies the name of the object as it is to appear in the new file system. The Name token is required for every object except for the root directory definition.
{ - | d | b | c | l | L | p } { - | u } { - | g } { - | t }
Represents a string of 4 positional characters, where:
{ - | d | b | c | l | L | p }
Defines the object type. Valid types are:
- Regular file
d Directory
b Block special file
c Character special file
l Symbolic link
L Hard link
p Named pipe
{ - | u } Toggles the set UID bit of the object, as follows:
u Set UID on execution
- Do not set UID on execution
{ - | g } Toggles the set group ID (GID) bit of the object, as follows:
g Set GID on execution
- Do not set GID on execution
{ - | t } Toggles the sticky bit of the object, as follows:
t Sticky bit on
- Sticky bit off

This 4-character token is required for every object.

Mode Represents a string of 3 octal characters defining the read, write, and execute permissions of the object. The Mode token is required of every object. See the chmod command for more information about permissions.
Owner Specifies the UID of the owner of the object. The owner token is required for every object.
Group Specifies the GID of the owner of the object. The group token is required for every object.
Major Minor Specifies the major and minor device numbers of the object if its type is a block or character special file. If the object is not a block or character special file, these tokens are omitted.
SourceFile Applies only to regular file, hard link, and symbolic link objects. For regular files, this token is the path name to the file from which the object file is to be initialized. For both symbolic and hard links, this token is the source of the link. The source of the link is relative to the new file system for hard links.
DirectoryListing Defines the contents of the object if it is a directory. The contents of the directory are defined using the token syntax described here. For example, a directory listing can include one or more regular files, one or more block files, and one or more directory listings. The mkfs command creates the directory entries . (dot) and .. (dot dot). Each directory listing is terminated with the special $ token.
$ Ends the current directory listing or indicates the end of the prototype file.

Example Prototype Specification

The following prototype specification describes a JFS that does not have a boot program in block 0 and occupies the entire device. The 3rd token is ignored. The 4th and 5th tokens define the fragment size as 1024 bytes and the number of bytes per i-node as 2048. The main body of this prototype defines the file system contents.

<noboot> 0 0 1024 2048
d---  755 0 0
 dir1    d--- 755 0 2
  block_dev   b--- 644 0 0   880 881
  char_dev    c--- 644 0 0   990 991
  named_pipe  p--- 644 0 0
  regfile3    ---- 644 0 0   /tmp/proto.examp/dir1/regfile3
  regfile4    ---- 644 0 0   /tmp/proto.examp/dir1/regfile4
  $
 dir2    d--- 755 205 300
  regfile6   ---- 644 0 0    /tmp/proto.examp/dir2/regfile6
  symlnOutofFS l--- 644 0 0  /tmp/proto.examp/dir2/regfile6
  symlnNoExist l--- 644 0 0  /home/foobar
  symlnInFs  l--- 644 0 0    /dir2/regfile6
  regfile5   ---- 644 0 0    /tmp/proto.examp/dir2/regfile5
  hardlink   L--- 644 0 0    /dir2/regfile5
  $
 dir3   d--- 755 0 0
  setgid     --g- 755 0 0    /tmp/proto.examp/dir3/setgid
  setuid     -u-- 755 0 0    /tmp/proto.examp/dir3/setuid
  sticky     ---t 755 0 0    /tmp/proto.examp/dir3/sticky
  $
 dir4   d--- 755 0 0
  dir5  d--- 755 0 0
   dir6 d--- 755 0 0
    $
   dir7 d--- 755 0 0
    $
   $
  regfile7   ---- 644 0 0    /tmp/proto.examp/dir4/regfile7
  $
 regfile1    ---- 555 205 1  /tmp/proto.examp/regfile1
 regfile2    ---- 744 0 0    /tmp/proto.examp/regfile2
 $
$

Three entries for the dir2 object deserve further examination:

symlnOutofFS l--- 644 0 0 /tmp/proto.examp/dir2/regfile6
This entry defines a symbolic link to a file outside the file system to be created. The command ls -l lists something similar to symlnOutofFS -> /tmp/proto.examp/dir2/regfile6.
symlnNoExist l--- 644 0 0 /home/foobar
This entry defines a symbolic link to a file outside the file system to be created to a file that does not exist. The command ls -l lists something similar to symlnNoExist -> /home/foobar.
symlnInFs l--- 644 0 0 /dir2/regfile6
This entry defines a symbolic link to a file within the file system to be created. The command ls -l lists something similar to symlnInFS -> /dir/regfile6.

Flags

-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):

-o ag={ 8 | 16 | 32 | 64 } Specifies the allocation group size in megabytes. An allocation group is a grouping of inodes and disk blocks similar to BSD cylinder groups. The default ag value is 8. This option only applies to AIX Version 4.2 or later.
-o bf={ true | false } Specifies a large file enabled file system. See "Understanding Large File Enabled File Systems" 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. This option only applies to AIX Version 4.2 or later.
-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. The values 32768, 65536, and 131072 only apply to AIX Version 4.2 or later.
Notes:
  1. Only JFS file systems created with the default ag, bf, compress, frag, and nbpi values and a size of less than 2 gigabytes are recognized on an AIX Version 3.2 system. Furthermore, file systems created with an ag value greater than 8 is not recognized on an AIX Version 4.1 system much less an AIX Version 3.2 system.
  2. 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 once the file system is created.
  3. The root filesystem ( / ) cannot be compressed.
  4. Some nbpi values and allocation group sizes are mutually exclusive. See "Understanding JFS Size Limitations" for information.
-p Prototype Specifies the name of the prototype file. Options specified on the command line override attributes in the prototype file.
-s Size Specifies the size of the file system in 512-byte blocks. See "Understanding JFS Size Limitations" for more information.
Notes:
  1. The volume group in which the file system resides defines a maximum logical volume size and also limits the file system size.
  2. The -s Size flag specifies the minimum file size and cannot be decreased after the file system has been successfully created.
-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.

Examples

  1. To specify the volume and file system name for a new file system, enter:
    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, enter:
    mkfs -s 8192 -o nbpi=2048,frag=512 /dev/lv01
    This command creates an empty 4MB 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, enter:
    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 inode for every 131072 bytes of disk. The size of the file system will be the size of the logical volume lv01.

Files

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

Related Information

The fsck command, mkproto command, proto command.

The ioctl subroutine.

The dir file, filesystems file, filsys.h file.

File Systems Overview for System Management in AIX Version 4.3 System Management Guide: Operating System and Devices.

Understanding Journaled File System Size Limitations in AIX Version 4.3 System Management Guide: Operating System and Devices.


[ Previous | Next | Contents | Glossary | Home | Search ]