xref: /minix/sbin/newfs_msdos/newfs_msdos.8 (revision 9f988b79)
1.\" $NetBSD: newfs_msdos.8,v 1.18 2013/07/20 21:39:58 wiz Exp $
2.\"
3.\" Copyright (c) 1998 Robert Nordier
4.\" 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
13.\"    the documentation and/or other materials provided with the
14.\"    distribution.
15.\"
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.
27.\"
28.\" From: $FreeBSD: src/sbin/newfs_msdos/newfs_msdos.8,v 1.13 2001/08/14 10:01:48 ru Exp $
29.\"
30.Dd March 26, 2009
31.Dt NEWFS_MSDOS 8
32.Os
33.Sh NAME
34.Nm newfs_msdos
35.Nd construct a new MS-DOS (FAT) file system
36.Sh SYNOPSIS
37.Nm
38.Op Fl N
39.Op Fl @ Ar offset
40.Op Fl B Ar boot
41.Op Fl C Ar create-size
42.Op Fl F Ar FAT-type
43.Op Fl I Ar volid
44.Op Fl L Ar label
45.Op Fl O Ar OEM
46.Op Fl S Ar sector-size
47.Op Fl a Ar FAT-size
48.Op Fl b Ar block-size
49.Op Fl c Ar cluster-size
50.Op Fl e Ar dirents
51.Op Fl f Ar format
52.Op Fl h Ar heads
53.Op Fl i Ar info
54.Op Fl k Ar backup
55.Op Fl m Ar media
56.Op Fl n Ar FATs
57.Op Fl o Ar hidden
58.Op Fl r Ar reserved
59.Op Fl s Ar total
60.Op Fl u Ar track-size
61.Ar special
62.Op Ar disktype
63.Sh DESCRIPTION
64The
65.Nm
66utility creates a FAT12, FAT16, or FAT32 file system on device or file named
67.Ar special ,
68using
69.Xr disktab 5
70entry
71.Ar disktype
72to determine geometry, if required.
73.Pp
74The options are as follow:
75.Bl -tag -width indent
76.It Fl N
77Don't create a file system: just print out parameters.
78.It Fl @ Ar offset
79Build the filesystem at the specified offset in bytes in the device or file.
80A suffix s, k, m, g (lower or upper case)
81appended to the offset specifies that the
82number is in sectors, kilobytes, megabytes or gigabytes, respectively.
83.It Fl B Ar boot
84Get bootstrap from file.
85.It Fl C Ar create-size
86Create the image file with the specified size.
87A suffix character appended to the size is interpreted as for the
88.Fl @
89option.
90The file is created by truncating any existing file with the
91same name, seeking just before the required size and writing
92a single 0 byte.
93As a consequence, the space occupied on disk
94may be smaller than the size specified as a parameter.
95.It Fl F Ar FAT-type
96FAT type (one of 12, 16, or 32).
97.It Fl I Ar volid
98Volume ID.
99.It Fl L Ar label
100Volume label (up to 11 characters).
101The label should consist of only those characters permitted
102in regular DOS (8+3) filenames.
103The default is
104.Qq Li "NO_NAME" .
105.It Fl O Ar OEM
106OEM string (up to 8 characters).
107The default is
108.Qq Li "NetBSD" .
109.It Fl S Ar sector-size
110Number of bytes per sector.
111Acceptable values are powers of 2 in the range 512 through 32768.
112.It Fl a Ar FAT-size
113Number of sectors per FAT.
114.It Fl b Ar block-size
115File system block size (bytes per cluster).
116This should resolve to an acceptable number of sectors
117per cluster (see below).
118.It Fl c Ar cluster-size
119Sectors per cluster.
120Acceptable values are powers of 2 in the range 1 through 128.
121If the block or cluster size are not specified, the code
122uses a cluster between 512 bytes and 32K depending on
123the filesystem size.
124.It Fl e Ar dirents
125Number of root directory entries (FAT12 and FAT16 only).
126.It Fl f Ar format
127Specify a standard (floppy disk) format.
128The standard formats are (capacities in kilobytes):
129160, 180, 320, 360, 640, 720, 1200, 1232, 1440, 2880.
130.It Fl h Ar heads
131Number of drive heads.
132.It Fl i Ar info
133Location of the file system info sector (FAT32 only).
134A value of 0xffff signifies no info sector.
135.It Fl k Ar backup
136Location of the backup boot sector (FAT32 only).
137A value of 0xffff signifies no backup sector.
138.It Fl m Ar media
139Media descriptor (acceptable range 0xf0 to 0xff).
140.It Fl n Ar FATs
141Number of FATs.
142Acceptable values are 1 to 16 inclusive.
143The default is 2.
144.It Fl o Ar hidden
145Number of hidden sectors.
146.It Fl r Ar reserved
147Number of reserved sectors.
148.It Fl s Ar total
149File system size.
150.It Fl u Ar track-size
151Number of sectors per track.
152.El
153.Pp
154If
155.Nm
156receives a
157.Dv SIGINFO
158signal
159(see the
160.Sy status
161argument for
162.Xr stty 1 ) ,
163a line will be written to the standard error output indicating
164the name of the device currently being formatted, the sector
165number being written, and the total number of sectors to be written.
166.Sh NOTES
167If some parameters (e.g. size, number of sectors, etc.) are not specified
168through options or disktype, the program tries to generate them
169automatically.
170In particular, the size is determined as the
171device or file size minus the offset specified with the
172.Fl @
173option.
174When the geometry is not available, it is assumed to be
17563 sectors, 255 heads.
176The size is then rounded to become
177a multiple of the track size and avoid complaints by some filesystem code.
178.Pp
179FAT file system parameters occupy a "Boot Sector BPB (BIOS Parameter
180Block)" in the first of the "reserved" sectors which precede the actual
181file system.
182For reference purposes, this structure is presented below.
183.Bd -literal
184struct bsbpb {
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 */
197};
198/* FAT32 extensions */
199struct bsxbpb {
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 */
206};
207.Ed
208.Sh EXAMPLES
209.Bd -literal -offset indent
210newfs_msdos /dev/rwd1a
211.Ed
212.Pp
213Create a file system, using default parameters, on
214.Pa /dev/rwd1a .
215.Bd -literal -offset indent
216newfs_msdos -f 1440 -L foo /dev/rfd0a
217.Ed
218.Pp
219Create a standard 1.44M file system, with volume label
220.Ar foo ,
221on
222.Pa /dev/rfd0a .
223Create a 30MB image file, with the FAT partition starting
22463 sectors within the image file:
225.Bd -literal -offset indent
226newfs_msdos -C 30M -@63s ./somefile
227.Ed
228.Sh DIAGNOSTICS
229Exit status is 0 on success and 1 on error.
230.Sh SEE ALSO
231.Xr disktab 5 ,
232.Xr disklabel 8 ,
233.Xr fdisk 8 ,
234.Xr newfs 8
235.Sh HISTORY
236The
237.Nm
238command first appeared in
239.Nx 1.3 .
240.Sh AUTHORS
241.An Robert Nordier Aq Mt rnordier@FreeBSD.org .
242