newfs_ext2fs is used to initialize and clear ext2 file systems before first use. Before running
newfs_ext2fs the disk must be labeled using
disklabel(8).
newfs_ext2fs builds a file system on the specified special device basing its defaults on the information in the disk label. Typically the defaults are reasonable, however
newfs_ext2fs has numerous options to allow the defaults to be selectively overridden.
Options with numeric arguments may contain an optional (case-insensitive) suffix:
b
Bytes; causes no modification. (Default)
k
Kilo; multiply the argument by 1024.
m
Mega; multiply the argument by 1048576.
g
Giga; multiply the argument by 1073741824.
The following options define the general layout policies.
-b block-size
The block size of the file system, in bytes. It must be a power of two. The smallest allowable size is 1024 bytes. The default size depends upon the size of the file system:
file system size
block-size
-D inodesize
Set the inode size. Defaults to 128, and can also be set to 256 for compatibility with ext4.
-F
Create a file system image in special. The file system size needs to be specified with “-s size”. No attempts to use or update the disk label will be made.
-f frag-size
The fragment size of the file system in bytes. It must be the same with blocksize because the current ext2fs implementation doesn't support fragmentation.
-I
Do not require that the file system type listed in the disk label is ‘Linux Ext2'.
-i bytes-per-inode
This specifies the density of inodes in the file system. If fewer inodes are desired, a larger number should be used; to create more inodes a smaller number should be given.
-m free-space
The percentage of space reserved from normal users; the minimum free space threshold. The default value used is 5%.
-N
Causes the file system parameters to be printed out without really creating the file system.
-n inodes
This specifies the number of inodes for the file system. If both -i and -n are specified then -n takes precedence. The default number of inodes is calculated from a number of blocks in the file system.
-O filesystem-format
Select the filesystem-format.
0
‘GOOD_OLD_REV'; this option is primarily used to build root file systems that can be understood by old or dumb firmwares for bootstrap. (default)
1
‘DYNAMIC_REV'; various extended (and sometimes incompatible) features are enabled (though not all features are supported on
NetBSD). Currently only the following features are supported:
RESIZE
Prepare some reserved structures which enable future file system resizing.
FTYPE
Store file types in directory entries to improve performance.
SPARSESUPER
Prepare superblock backups for the
fsck_ext2fs(8) utility on not all but sparse block groups.
LARGEFILE
Enable files larger than 2G bytes.
-s size
The size of the file system in sectors. An ‘s' suffix will be interpreted as the number of sectors (the default). All other suffixes are interpreted as per other numeric arguments, except that the number is converted into sectors by dividing by the sector size (as specified by
-S secsize) after suffix interpretation.
If no
-s size is specified then the filesystem size defaults to that of the partition, or, if
-F is specified, the existing file.
If
size is negative the specified size is subtracted from the default size (reserving space at the end of the partition).
-V verbose
This controls the amount of information written to stdout:
1
Overall size and cylinder group details.
2
A progress bar (dots ending at right hand margin).
3
The first few super-block backup sector numbers are displayed before the progress bar.
4
All the super-block backup sector numbers are displayed (no progress bar).
The default is 3. If
-N is specified
newfs_ext2fs stops before outputting the progress bar.
-v volname
This specifies a volume name for the file system.
-Z
Pre-zeros the file system image created with
-F. This is necessary if the image is to be used by
vnd(4) (which doesn't support file systems with ‘holes').
The following option overrides the standard sizes for the disk geometry. The default value is taken from the disk label. Changing this default is useful only when using
newfs_ext2fs to build a file system whose raw image will eventually be used on a different type of disk than the one on which it is initially created (for example on a write-once disk). Note that changing this value from its default will make it impossible for
fsck_ext2fs(8) to find the alternative superblocks if the standard superblock is lost.
-S sector-size
The size of a sector in bytes (almost never anything but 512). Defaults to 512.