mke2fs

From RaySoft

mke2fs is used to create an ext2/ext3 filesystem (usually in a disk partition). device is the special file corresponding to the device (e.g /dev/hdXX). blocks-count is the number of blocks on the device. If omitted, mke2fs automagically figures the file system size. If called as mkfs.ext3 a journal is created as if the -j option was specified.[1]

Documentation

Syntax

mke2fs [PARAMETER ...] [DEVICE]

Parameters

-b SIZE
Specify the SIZE of blocks in bytes. Valid block-size values are 1024, 2048 and 4096 bytes per block. If omitted, block-size is heuristically determined by the filesystem size and the expected usage of the filesystem (see the -T option). If block-size is negative, then mke2fs will use heuristics to determine the appropriate block size, with the constraint that the block size will be at least block-size bytes. This is useful for certain hardware devices which require that the blocksize be a multiple of 2k.
-c
Check the device for bad blocks before creating the file system. If this option is specified twice, then a slower, read-write test is used instead of a fast read-only test.
-E OPTION,[...]
Set extended options for the filesystem. Extended options are comma separated, and may take an argument using the equals (=) sign. The following extended options are supported:
stride=SIZE
Configure the filesystem for a RAID array with stripe-size filesystem blocks per stripe.
stripe-width=WIDTH
Configure the filesystem for a RAID array with stripe-width filesystem blocks per stripe.
-F
Force mke2fs to run, even if the specified device is not a block special device, or appears to be mounted.
-i BYTES
Specify the BYTES per inode ratio. mke2fs creates an inode for every bytes-per-inode bytes of space on the disk. The larger the bytes-per-inode ratio, the fewer inodes will be created. This value generally shouldn't be smaller than the blocksize of the filesystem, since in that case more inodes would be made than can ever be used. Be warned that it is not possible to expand the number of inodes on a filesystem after it is created, so be careful deciding the correct value for this parameter.
-j
Create the filesystem with an ext3 journal. If the -J option is not specified, the default journal parameters will be used to create an appropriately sized journal (given the size of the filesystem) stored within the filesystem.
NOTE:
You must be using a kernel which has ext3 support in order to actually make use of the journal.
-l FILE
Read the bad blocks list from FILE.
NOTE:
The block numbers in the bad block list must be generated using the same block size as used by mke2fs. As a result, the -c option to mke2fs is a much simpler and less error-prone method of checking a disk for bad blocks before formatting it, as mke2fs will automatically pass the correct parameters to the badblocks program.
-L LABEL
Set the volume label for the filesystem to LABEL. The maximum length of the volume label is 16 bytes.
-m PRECENTAGE
Specify the PRECENTAGE of the filesystem blocks reserved for the super-user. This avoids fragmentation, and allows root-owned daemons, such as syslogd, to continue to function correctly after non-privileged processes are prevented from writing to the filesystem. The default percentage is 5%.
-M DIRECTORY
Set the last mounted DIRECTORY for the filesystem. This might be useful for the sake of utilities that key off of the last mounted directory to determine where the filesystem should be mounted.
-n
Causes mke2fs to not actually create a filesystem, but display what it would do if it were to create a filesystem. This can be used to determine the location of the backup superblocks for a particular filesystem, so long as the mke2fs parameters that were passed when the filesystem was originally created are used again.
-N NUMBER
Overrides the default calculation of the NUMBER of inodes that should be reserved for the filesystem (which is based on the number of blocks and the bytes-per-inode ratio). This allows the user to specify the number of desired inodes directly.
-q
Quiet execution. Useful if mke2fs is run in a script.
-S
Write superblock and group descriptors only. This is useful if all of the superblock and backup superblocks are corrupted, and a last-ditch recovery method is desired. It causes mke2fs to reinitialize the superblock and group descriptors, while not touching the inode table and the block and inode bitmaps. The e2fsck program should be run immediately after this option is used, and there is no guarantee that any data will be salvageable. It is critical to specify the correct filesystem blocksize when using this option, or there is no chance of recovery.
-t TYPE
Specify the filesystem TYPE (i.e., ext2, ext3, ext4, etc.) that is to be created. If this option is not specified, mke2fs will pick a default either via how the command was run (for example, using a name of the form mkfs.ext2, mkfs.ext3, etc.) or via a default as defined by the /etc/mke2fs.conf file.
-T USAGE[,...]
Specify how the filesystem is going to be used, so that mke2fs can choose optimal filesystem parameters for that use. The USAGE types that are supported are defined in the configuration file /etc/mke2fs.conf. The user may specify one or more usage types using a comma separated list.

References

  1. man 8 'mke2fs'