1 .\" $NetBSD: newfs_msdos.8,v 1.16 2009/03/26 08:39:24 pooka 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
60 .Op Fl u Ar track-size
66 utility creates a FAT12, FAT16, or FAT32 file system on device or file named
72 to determine geometry, if required.
74 The options are as follow:
75 .Bl -tag -width indent
77 Don't create a file system: just print out parameters.
79 Build the filesystem at the specified offset in bytes in the device or file.
80 A suffix s, k, m, g (lower or upper case)
81 appended to the offset specifies that the
82 number is in sectors, kilobytes, megabytes or gigabytes, respectively.
84 Get bootstrap from file.
85 .It Fl C Ar create-size
86 Create the image file with the specified size.
87 A suffix character appended to the size is interpreted as for the
90 The file is created by truncating any existing file with the
91 same name, seeking just before the required size and writing
93 As a consequence, the space occupied on disk
94 may be smaller than the size specified as a parameter.
96 FAT type (one of 12, 16, or 32).
100 Volume label (up to 11 characters).
101 The label should consist of only those characters permitted
102 in regular DOS (8+3) filenames.
106 OEM string (up to 8 characters).
109 .It Fl S Ar sector-size
110 Number of bytes per sector.
111 Acceptable values are powers of 2 in the range 512 through 32768.
113 Number of sectors per FAT.
114 .It Fl b Ar block-size
115 File system block size (bytes per cluster).
116 This should resolve to an acceptable number of sectors
117 per cluster (see below).
118 .It Fl c Ar cluster-size
120 Acceptable values are powers of 2 in the range 1 through 128.
121 If the block or cluster size are not specified, the code
122 uses a cluster between 512 bytes and 32K depending on
125 Number of root directory entries (FAT12 and FAT16 only).
127 Specify a standard (floppy disk) format.
128 The standard formats are (capacities in kilobytes):
129 160, 180, 320, 360, 640, 720, 1200, 1232, 1440, 2880.
131 Number of drive heads.
133 Location of the file system info sector (FAT32 only).
134 A value of 0xffff signifies no info sector.
136 Location of the backup boot sector (FAT32 only).
137 A value of 0xffff signifies no backup sector.
139 Media descriptor (acceptable range 0xf0 to 0xff).
142 Acceptable values are 1 to 16 inclusive.
145 Number of hidden sectors.
147 Number of reserved sectors.
150 .It Fl u Ar track-size
151 Number of sectors per track.
163 a line will be written to the standard error output indicating
164 the name of the device currently being formatted, the sector
165 number being written, and the total number of sectors to be written.
167 If some parameters (e.g. size, number of sectors, etc.) are not specified
168 through options or disktype, the program tries to generate them
170 In particular, the size is determined as the
171 device or file size minus the offset specified with the
174 When the geometry is not available, it is assumed to be
175 63 sectors, 255 heads.
176 The size is then rounded to become
177 a multiple of the track size and avoid complaints by some filesystem code.
179 FAT file system parameters occupy a "Boot Sector BPB (BIOS Parameter
180 Block)" in the first of the "reserved" sectors which precede the actual
182 For reference purposes, this structure is presented below.
185 u_int16_t bps; /* [-S] bytes per sector */
186 u_int8_t spc; /* [-c] sectors per cluster */
187 u_int16_t res; /* [-r] reserved sectors */
188 u_int8_t nft; /* [-n] number of FATs */
189 u_int16_t rde; /* [-e] root directory entries */
190 u_int16_t sec; /* [-s] total sectors */
191 u_int8_t mid; /* [-m] media descriptor */
192 u_int16_t spf; /* [-a] sectors per FAT */
193 u_int16_t spt; /* [-u] sectors per track */
194 u_int16_t hds; /* [-h] drive heads */
195 u_int32_t hid; /* [-o] hidden sectors */
196 u_int32_t bsec; /* [-s] big total sectors */
198 /* FAT32 extensions */
200 u_int32_t bspf; /* [-a] big sectors per FAT */
201 u_int16_t xflg; /* control flags */
202 u_int16_t vers; /* file system version */
203 u_int32_t rdcl; /* root directory start cluster */
204 u_int16_t infs; /* [-i] file system info sector */
205 u_int16_t bkbs; /* [-k] backup boot sector */
209 .Bd -literal -offset indent
210 newfs_msdos /dev/rwd1a
213 Create a file system, using default parameters, on
215 .Bd -literal -offset indent
216 newfs_msdos -f 1440 -L foo /dev/rfd0a
219 Create a standard 1.44M file system, with volume label
223 Create a 30MB image file, with the FAT partition starting
224 63 sectors within the image file:
225 .Bd -literal -offset indent
226 newfs_msdos -C 30M -@63s ./somefile
229 Exit status is 0 on success and 1 on error.
238 command first appeared in
241 .An Robert Nordier Aq rnordier@FreeBSD.org .