1.\" $OpenBSD: newfs_ext2fs.8,v 1.9 2015/03/13 19:58:41 jmc Exp $ 2.\" $NetBSD: newfs_ext2fs.8,v 1.7 2009/12/01 08:47:25 pooka Exp $ 3.\" 4.\" Copyright (c) 1983, 1987, 1991, 1993, 1994 5.\" The Regents of the University of California. All rights reserved. 6.\" 7.\" Redistribution and use in source and binary forms, with or without 8.\" modification, are permitted provided that the following conditions 9.\" are met: 10.\" 1. Redistributions of source code must retain the above copyright 11.\" notice, this list of conditions and the following disclaimer. 12.\" 2. Redistributions in binary form must reproduce the above copyright 13.\" notice, this list of conditions and the following disclaimer in the 14.\" documentation and/or other materials provided with the distribution. 15.\" 3. Neither the name of the University nor the names of its contributors 16.\" may be used to endorse or promote products derived from this software 17.\" without specific prior written permission. 18.\" 19.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 20.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29.\" SUCH DAMAGE. 30.\" 31.\" @(#)newfs.8 8.6 (Berkeley) 5/3/95 32.\" 33.Dd $Mdocdate: March 13 2015 $ 34.Dt NEWFS_EXT2FS 8 35.Os 36.Sh NAME 37.Nm newfs_ext2fs 38.Nd construct a new ext2 file system 39.Sh SYNOPSIS 40.Nm 41.Bk -words 42.Op Fl FINqZ 43.Op Fl b Ar block-size 44.Op Fl D Ar inodesize 45.Op Fl f Ar frag-size 46.Op Fl i Ar bytes-per-inode 47.Op Fl m Ar free-space 48.Op Fl n Ar inodes 49.Op Fl O Ar filesystem-format 50.Op Fl S Ar sector-size 51.Op Fl s Ar size 52.Op Fl V Ar verbose 53.Op Fl v Ar volname 54.Ar special 55.Ek 56.Sh DESCRIPTION 57.Nm 58is used to initialize and clear ext2 file systems before first use. 59Before running 60.Nm 61the disk must be labeled using 62.Xr disklabel 8 . 63.Nm 64builds a file system on the specified 65.Ar special 66device, 67basing its defaults on the information in the disk label. 68Typically the defaults are reasonable, although 69.Nm 70has numerous options to allow the defaults to be selectively overridden. 71.Pp 72The 73.Ar special 74file should be a raw device, 75for example 76.Pa /dev/rsd0a ; 77if a relative path like 78.Pa sd0a 79is specified, 80the corresponding raw device is used. 81.Pp 82Options with numeric arguments may contain an optional (case-insensitive) 83suffix: 84.Pp 85.Bl -tag -width 3n -offset indent -compact 86.It b 87Bytes; causes no modification. 88(Default) 89.It k 90Kilo; multiply the argument by 1024. 91.It m 92Mega; multiply the argument by 1048576. 93.It g 94Giga; multiply the argument by 1073741824. 95.El 96.Pp 97The following options define the general layout policies. 98.Bl -tag -width Fl 99.It Fl b Ar block-size 100The block size of the file system, in bytes. 101It must be a power of two. 102The smallest allowable size is 1024 bytes. 103The default size depends upon the size of the file system: 104.Pp 105.Bl -tag -width "file system size" -compact -offset indent 106.It Sy "file system size" 107.Ar block-size 108.It \*(Lt= 512 MB 1091 KB 110.It \*(Gt 512 MB 1114 KB 112.El 113.It Fl D Ar inodesize 114Set the inode size. 115Defaults to 128, and can also be set to 256 for 116compatibility with ext4. 117.It Fl F 118Create a file system image in 119.Ar special . 120The file system size needs to be specified with 121.Dq Fl s Ar size . 122No attempts to use or update the disk label will be made. 123.It Fl f Ar frag-size 124The fragment size of the file system in bytes. 125It must be the same as the blocksize, 126because the current ext2fs 127implementation doesn't support fragmentation. 128.It Fl I 129Do not require that the file system type listed in the disk label is 130.Ql ext2fs . 131.It Fl i Ar bytes-per-inode 132This specifies the density of inodes in the file system. 133If fewer inodes are desired, a larger number should be used; 134to create more inodes a smaller number should be given. 135.It Fl m Ar free-space 136The percentage of space reserved from normal users; the minimum free 137space threshold. 138The default value used is 5%. 139.It Fl N 140Causes the file system parameters to be printed out 141without really creating the file system. 142.It Fl n Ar inodes 143This specifies the number of inodes for the file system. 144If both 145.Fl i 146and 147.Fl n 148are specified then 149.Fl n 150takes precedence. 151The default number of inodes is calculated from a number of blocks in 152the file system. 153.It Fl O Ar filesystem-format 154Select the filesystem-format. 155.Pp 156.Bl -tag -width 3n -offset indent -compact 157.It 0 158.Ql GOOD_OLD_REV ; 159this option is primarily used to build root file systems that can be 160understood by old or dumb firmware for bootstrap. 161(default) 162.It 1 163.Ql DYNAMIC_REV ; 164various extended (and sometimes incompatible) features are enabled 165(though not all features are supported on 166.Ox ) . 167Currently only the following features are supported: 168.Pp 169.Bl -tag -width "SPARSESUPER" -offset indent -compact 170.It RESIZE 171Prepare some reserved structures which enable future file system resizing. 172.It FTYPE 173Store file types in directory entries to improve performance. 174.It SPARSESUPER 175Prepare superblock backups for the 176.Xr fsck_ext2fs 8 177utility on not all but sparse block groups. 178.It LARGEFILE 179Enable files larger than 2G bytes. 180.El 181.El 182.It Fl q 183Operate in quiet mode. 184Equivalent to 185.Fl V Ar 1 . 186.It Fl s Ar size 187The size of the file system in sectors. 188An 189.Sq s 190suffix will be interpreted as the number of sectors (the default). 191All other suffixes are interpreted as per other numeric arguments, 192except that the number is converted into sectors by dividing by the 193sector size (as specified by 194.Fl S Ar secsize ) 195after suffix interpretation. 196.Pp 197If no 198.Fl s Ar size 199is specified then the filesystem size defaults to that of the partition or, 200if 201.Fl F 202is specified, the existing file. 203.Pp 204If 205.Ar size 206is negative the specified size is subtracted from the default size 207(reserving space at the end of the partition). 208.It Fl V Ar verbose 209This controls the amount of information written to stdout: 210.Pp 211.Bl -tag -width 3n -offset indent -compact 212.It 0 213No output. 214.It 1 215Overall size and cylinder group details. 216.It 2 217A progress bar (dots ending at right hand margin). 218.It 3 219The first few super-block backup sector numbers are displayed before the 220progress bar. 221.It 4 222All the super-block backup sector numbers are displayed (no progress bar). 223.El 224.Pp 225The default is 4. 226If 227.Fl N 228is specified 229.Nm 230stops before outputting the progress bar. 231.It Fl v Ar volname 232This specifies a volume name for the file system. 233.It Fl Z 234Pre-zeros the file system image created with 235.Fl F . 236This is necessary if the image is to be used by 237.Xr vnd 4 238(which doesn't support file systems with 239.Sq holes ) . 240.El 241.Pp 242The following option overrides the standard sizes for the disk geometry. 243The default value is taken from the disk label. 244Changing this default is useful only when using 245.Nm 246to build a file system whose raw image will eventually be used on a 247different type of disk than the one on which it is initially created 248(for example on a write-once disk). 249Note that changing this value from its default will make it impossible for 250.Xr fsck_ext2fs 8 251to find the alternative superblocks if the standard superblock is lost. 252.Bl -tag -width Fl 253.It Fl S Ar sector-size 254The size of a sector in bytes (almost never anything but 512). 255Defaults to 512. 256.El 257.Sh NOTES 258There is no option to specify the metadata byte order on the file system 259to be created because the native ext2 file system is always little endian 260even on big endian hosts. 261.Pp 262The file system is created with 263.Sq random 264inode generation numbers to improve NFS security. 265.Pp 266The owner and group IDs of the root node and reserved blocks of the new 267file system are set to the effective UID and GID of the user initializing 268the file system. 269.Pp 270For the 271.Nm 272command to succeed, 273the disk label should first be updated such that the fstype field for the 274partition is set to 275.Ql ext2fs , 276unless 277.Fl F 278or 279.Fl I 280is used. 281.Pp 282The partition size is found using 283.Xr fstat 2 , 284not by inspecting the disk label. 285The block size and fragment size will be written back to the disk label 286only if the last character of 287.Ar special 288references the same partition as the minor device number. 289.Sh SEE ALSO 290.Xr fstat 2 , 291.Xr disklabel 5 , 292.Xr disktab 5 , 293.Xr fs 5 , 294.Xr disklabel 8 , 295.\" .Xr dumpfs 8 , 296.Xr fsck_ext2fs 8 , 297.Xr mount 8 , 298.Xr mount_ext2fs 8 , 299.Xr newfs 8 300.Rs 301.%A Remy Card 302.%A Theodore Ts'o 303.%A Stephen Tweedie 304.%T "Design and Implementation of the Second Extended Filesystem" 305.%J "The Proceedings of the First Dutch International Symposium on Linux" 306.%U http://e2fsprogs.sourceforge.net/ext2intro.html 307.Re 308.Sh HISTORY 309The 310.Nm 311command first appeared in 312.Ox 4.7 . 313.Sh AUTHORS 314The 315.Nm 316command was written by 317.An Izumi Tsutsui 318.Aq Mt tsutsui@NetBSD.org . 319.Sh BUGS 320The 321.Nm 322command is still experimental and there are few sanity checks. 323.Pp 324The 325.Nm 326command doesn't have options to specify each REV1 file system feature 327independently. 328.Pp 329The 330.Nm 331command doesn't support the bad block list accounted by the bad blocks inode. 332.Pp 333Many newer ext2 file system features (especially journaling) are 334not supported yet. 335.Pp 336Some features in file systems created by the 337.Nm 338command might not be recognized properly by the 339.Xr fsck_ext2fs 8 340utility. 341.Pp 342There is no native tool in the 343.Ox 344distribution for resizing ext2 file systems yet. 345