xref: /freebsd/sbin/newfs_msdos/newfs_msdos.8 (revision 39beb93c)
1.\" Copyright (c) 1998 Robert Nordier
2.\" All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\"    notice, this list of conditions and the following disclaimer in
11.\"    the documentation and/or other materials provided with the
12.\"    distribution.
13.\"
14.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS
15.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY
18.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
20.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
22.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
23.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
24.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25.\"
26.\" $FreeBSD$
27.\"
28.Dd December 8, 2007
29.Dt NEWFS_MSDOS 8
30.Os
31.Sh NAME
32.Nm newfs_msdos
33.Nd construct a new MS-DOS (FAT) file system
34.Sh SYNOPSIS
35.Nm
36.Op Fl N
37.Op Fl @ Ar offset
38.Op Fl B Ar boot
39.Op Fl C Ar create-size
40.Op Fl F Ar FAT-type
41.Op Fl I Ar volid
42.Op Fl L Ar label
43.Op Fl O Ar OEM
44.Op Fl S Ar sector-size
45.Op Fl a Ar FAT-size
46.Op Fl b Ar block-size
47.Op Fl c Ar cluster-size
48.Op Fl e Ar dirents
49.Op Fl f Ar format
50.Op Fl h Ar heads
51.Op Fl i Ar info
52.Op Fl k Ar backup
53.Op Fl m Ar media
54.Op Fl n Ar FATs
55.Op Fl o Ar hidden
56.Op Fl r Ar reserved
57.Op Fl s Ar total
58.Op Fl u Ar track-size
59.Ar special
60.Op Ar disktype
61.Sh DESCRIPTION
62The
63.Nm
64utility creates a FAT12, FAT16, or FAT32 file system on device or file named
65.Ar special ,
66using
67.Xr disktab 5
68entry
69.Ar disktype
70to determine geometry, if required.
71.Pp
72If
73.Ar special
74does not contain a
75.Ar / ,
76it is assumed to be a device name and
77.Ar /dev
78is prepended to the name to construct the actual device name.
79To work a file in the current directory use
80.Ar ./filename
81.Pp
82The options are as follow:
83.Bl -tag -width indent
84.It Fl N
85Do not create a file system: just print out parameters.
86.It Fl @ Ar offset
87Build the filesystem at the specified offset in bytes in the device or file.
88A suffix s, k, m, g (lower or upper case)
89appended to the offset specifies that the
90number is in sectors, kilobytes, megabytes or gigabytes, respectively.
91.It Fl B Ar boot
92Get bootstrap from file.
93.It Fl C Ar create-size
94Create the image file with the specified size. A suffix character appended
95to the size is interpreted as for the
96.Fl @
97option. The file is created by truncating any existing file with the
98same name, seeking just before the required size and writing
99a single 0 byte. As a consequence, the space occupied on disk
100may be smaller than the size specified as a parameter.
101.It Fl F Ar FAT-type
102FAT type (one of 12, 16, or 32).
103.It Fl I Ar volid
104Volume ID, a 32 bit number in decimal or hexadecimal (0x...) format.
105.It Fl L Ar label
106Volume label (up to 11 characters).
107The label should consist of
108only those characters permitted in regular DOS (8+3) filenames.
109.It Fl O Ar OEM
110OEM string (up to 8 characters).
111The default is
112.Qq Li "BSD  4.4" .
113.It Fl S Ar sector-size
114Number of bytes per sector.
115Acceptable values are powers of 2
116in the range 128 through 32768.
117.It Fl a Ar FAT-size
118Number of sectors per FAT.
119.It Fl b Ar block-size
120File system block size (bytes per cluster).
121This should resolve to an
122acceptable number of sectors per cluster (see below).
123.It Fl c Ar cluster-size
124Sectors per cluster.
125Acceptable values are powers of 2 in the range
1261 through 128.
127If the block or cluster size are not specified, the code
128uses a cluster between 512 bytes and 32K depending on
129the filesystem size.
130.It Fl e Ar dirents
131Number of root directory entries (FAT12 and FAT16 only).
132.It Fl f Ar format
133Specify a standard (floppy disk) format.
134The standard formats
135are (capacities in kilobytes): 160, 180, 320, 360, 640, 720, 1200,
1361232, 1440, 2880.
137.It Fl h Ar heads
138Number of drive heads.
139.It Fl i Ar info
140Location of the file system info sector (FAT32 only).
141A value of 0xffff signifies no info sector.
142.It Fl k Ar backup
143Location of the backup boot sector (FAT32 only).
144A value
145of 0xffff signifies no backup sector.
146.It Fl m Ar media
147Media descriptor (acceptable range 0xf0 to 0xff).
148.It Fl n Ar FATs
149Number of FATs.
150Acceptable values are 1 to 16 inclusive.
151The default
152is 2.
153.It Fl o Ar hidden
154Number of hidden sectors.
155.It Fl r Ar reserved
156Number of reserved sectors.
157.It Fl s Ar total
158File system size.
159.It Fl u Ar track-size
160Number of sectors per track.
161.El
162.Sh NOTES
163If some parameters (e.g. size, number of sectors, etc.) are not specified
164through options or disktype, the program tries to generate them
165automatically. In particular, the size is determined as the
166device or file size minus the offset specified with the
167.Fl @
168option. When the geometry is not available, it is assumed to be
16963 sectors, 255 heads. The size is then rounded to become
170a multiple of the track size and avoid complaints by some filesystem code.
171.Pp
172FAT file system parameters occupy a "Boot Sector BPB (BIOS Parameter
173Block)" in the first of the "reserved" sectors which precede the actual
174file system.
175For reference purposes, this structure is presented
176below.
177.Bd -literal
178struct bsbpb {
179    u_int16_t	bps;		/* [-S] bytes per sector */
180    u_int8_t	spc;		/* [-c] sectors per cluster */
181    u_int16_t	res;		/* [-r] reserved sectors */
182    u_int8_t	nft;		/* [-n] number of FATs */
183    u_int16_t	rde;		/* [-e] root directory entries */
184    u_int16_t	sec;		/* [-s] total sectors */
185    u_int8_t	mid;		/* [-m] media descriptor */
186    u_int16_t	spf;		/* [-a] sectors per FAT */
187    u_int16_t	spt;		/* [-u] sectors per track */
188    u_int16_t	hds;		/* [-h] drive heads */
189    u_int32_t	hid;		/* [-o] hidden sectors */
190    u_int32_t	bsec;		/* [-s] big total sectors */
191};
192/* FAT32 extensions */
193struct bsxbpb {
194    u_int32_t	bspf;		/* [-a] big sectors per FAT */
195    u_int16_t	xflg;		/* control flags */
196    u_int16_t	vers;		/* file system version */
197    u_int32_t	rdcl;		/* root directory start cluster */
198    u_int16_t	infs;		/* [-i] file system info sector */
199    u_int16_t	bkbs;		/* [-k] backup boot sector */
200};
201.Ed
202.Sh LIMITATION
203The maximum file size is 4GB, even if the file system itself is bigger.
204.Sh EXIT STATUS
205Exit status is 0 on success and 1 on error.
206.Sh EXAMPLES
207Create a file system, using default parameters, on
208.Pa /dev/ad0s1 :
209.Bd -literal -offset indent
210newfs_msdos /dev/ad0s1
211.Ed
212.Pp
213Create a standard 1.44M file system, with volume label
214.Ar foo ,
215on
216.Pa /dev/fd0 :
217.Bd -literal -offset indent
218newfs_msdos -f 1440 -L foo fd0
219.Ed
220.Pp
221Create a 30MB image file, with the FAT partition starting
22263 sectors within the image file:
223.Bd -literal -offset indent
224newfs_msdos -C 30M -@63s ./somefile
225.Ed
226.Sh SEE ALSO
227.Xr disktab 5 ,
228.Xr disklabel 8 ,
229.Xr fdisk 8 ,
230.Xr newfs 8
231.Sh HISTORY
232The
233.Nm
234utility first appeared in
235.Fx 3.0 .
236.Sh AUTHORS
237.An Robert Nordier Aq rnordier@FreeBSD.org .
238