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