1 .\" $NetBSD: newfs_msdos.8,v 1.23 2017/02/17 09:29:35 wiz Exp $
3 .\" Copyright (c) 1998 Robert Nordier
4 .\" All rights reserved.
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
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
13 .\" the documentation and/or other materials provided with the
16 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS
17 .\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY
20 .\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
22 .\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 .\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
24 .\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
25 .\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
26 .\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 .\" From: $FreeBSD: src/sbin/newfs_msdos/newfs_msdos.8,v 1.13 2001/08/14 10:01:48 ru Exp $
35 .Nd construct a new MS-DOS (FAT) file system
41 .Op Fl C Ar create-size
46 .Op Fl S Ar sector-size
48 .Op Fl b Ar block-size
49 .Op Fl c Ar cluster-size
61 .Op Fl u Ar track-size
67 utility creates a FAT12, FAT16, or FAT32 file system on device or file named
73 to determine geometry, if required.
75 The options are as follow:
76 .Bl -tag -width indent
78 Do not create a file system: just print out parameters.
80 Build the file system at the specified offset in bytes in the device or file.
81 A suffix s, k, m, g (lower or upper case)
82 appended to the offset specifies that the
83 number is in sectors, kilobytes, megabytes or gigabytes, respectively.
85 Get bootstrap from file.
86 .It Fl C Ar create-size
87 Create the image file with the specified size.
88 A suffix character appended to the size is interpreted as for the
91 The file is created by truncating any existing file with the
92 same name, seeking just before the required size and writing
94 As a consequence, the space occupied on disk
95 may be smaller than the size specified as a parameter.
97 FAT type (one of 12, 16, or 32).
101 Volume label (up to 11 characters).
102 The label should consist of only those characters permitted
103 in regular DOS (8+3) filenames.
107 OEM string (up to 8 characters).
110 .It Fl S Ar sector-size
111 Number of bytes per sector.
112 Acceptable values are powers of 2 in the range 512 through 32768.
114 Number of sectors per FAT.
115 .It Fl b Ar block-size
116 File system block size (bytes per cluster).
117 This should resolve to an acceptable number of sectors
118 per cluster (see below).
119 .It Fl c Ar cluster-size
121 Acceptable values are powers of 2 in the range 1 through 128.
122 If the block or cluster size are not specified, the code
123 uses a cluster between 512 bytes and 32K depending on
124 the file system size.
126 Number of root directory entries (FAT12 and FAT16 only).
128 Specify a standard (floppy disk) format.
129 The standard formats are (capacities in kilobytes):
130 160, 180, 320, 360, 640, 720, 1200, 1232, 1440, 2880.
132 Number of drive heads.
134 Location of the file system info sector (FAT32 only).
135 A value of 0xffff signifies no info sector.
137 Location of the backup boot sector (FAT32 only).
138 A value of 0xffff signifies no backup sector.
140 Media descriptor (acceptable range 0xf0 to 0xff).
143 Acceptable values are 1 to 16 inclusive.
146 Number of hidden sectors.
148 Number of reserved sectors.
151 .It Fl T At timestamp
152 Specify a timestamp to be used for file system creation so that
153 it can be consistent for reproducible builds.
154 The timestamp can be a pathname, where the timestamps are derived from
155 that file, a parseable date for parsedate(3) (this option is not
156 yet available in the tools build), or an integer value interpreted
157 as the number of seconds from the Epoch.
158 .It Fl u Ar track-size
159 Number of sectors per track.
171 a line will be written to the standard error output indicating
172 the name of the device currently being formatted, the sector
173 number being written, and the total number of sectors to be written.
175 If some parameters (e.g. size, number of sectors, etc.) are not specified
176 through options or disktype, the program tries to generate them
178 In particular, the size is determined as the
179 device or file size minus the offset specified with the
182 When the geometry is not available, it is assumed to be
183 63 sectors, 255 heads.
184 The size is then rounded to become
185 a multiple of the track size and avoid complaints by some file system code.
187 FAT file system parameters occupy a "Boot Sector BPB (BIOS Parameter
188 Block)" in the first of the "reserved" sectors which precede the actual
190 For reference purposes, this structure is presented below.
193 u_int16_t bps; /* [-S] bytes per sector */
194 u_int8_t spc; /* [-c] sectors per cluster */
195 u_int16_t res; /* [-r] reserved sectors */
196 u_int8_t nft; /* [-n] number of FATs */
197 u_int16_t rde; /* [-e] root directory entries */
198 u_int16_t sec; /* [-s] total sectors */
199 u_int8_t mid; /* [-m] media descriptor */
200 u_int16_t spf; /* [-a] sectors per FAT */
201 u_int16_t spt; /* [-u] sectors per track */
202 u_int16_t hds; /* [-h] drive heads */
203 u_int32_t hid; /* [-o] hidden sectors */
204 u_int32_t bsec; /* [-s] big total sectors */
206 /* FAT32 extensions */
208 u_int32_t bspf; /* [-a] big sectors per FAT */
209 u_int16_t xflg; /* control flags */
210 u_int16_t vers; /* file system version */
211 u_int32_t rdcl; /* root directory start cluster */
212 u_int16_t infs; /* [-i] file system info sector */
213 u_int16_t bkbs; /* [-k] backup boot sector */
217 .Bd -literal -offset indent
218 newfs_msdos /dev/rwd1a
221 Create a file system, using default parameters, on
223 .Bd -literal -offset indent
224 newfs_msdos -f 1440 -L foo /dev/rfd0a
227 Create a standard 1.44M file system, with volume label
231 Create a 30MB image file, with the FAT partition starting
232 63 sectors within the image file:
233 .Bd -literal -offset indent
234 newfs_msdos -C 30M -@63s ./somefile
237 Exit status is 0 on success and 1 on error.
250 command first appeared in
253 .An Robert Nordier Aq Mt rnordier@FreeBSD.org .