xref: /freebsd/sbin/newfs_msdos/newfs_msdos.8 (revision aa24f48b361effe51163877d84f1b70d32b77e04)
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 May 16, 2017
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 VolumeID
42.Op Fl L Ar label
43.Op Fl O Ar OEM
44.Op Fl S Ar sector-size
45.Op Fl T Ar timestamp
46.Op Fl a Ar FAT-size
47.Op Fl b Ar block-size
48.Op Fl c Ar cluster-size
49.Op Fl e Ar DirEnts
50.Op Fl f Ar format
51.Op Fl h Ar heads
52.Op Fl i Ar info
53.Op Fl k Ar backup
54.Op Fl m Ar media
55.Op Fl n Ar FATs
56.Op Fl o Ar hidden
57.Op Fl r Ar reserved
58.Op Fl s Ar total
59.Op Fl u Ar track-size
60.Ar special
61.Op Ar disktype
62.Sh DESCRIPTION
63The
64.Nm
65utility creates a FAT12, FAT16, or FAT32 file system on device or file named
66.Ar special ,
67using
68.Xr disktab 5
69entry
70.Ar disktype
71to determine geometry, if required.
72.Pp
73If
74.Ar special
75does not contain a
76.Ar /
77and
78.Fl C
79is not used, it is assumed to be a device name and
80.Ar /dev/
81is prepended to the name to construct the actual device name.
82To work a file in the current directory use
83.Ar ./filename
84.Pp
85The options are as follow:
86.Bl -tag -width indent
87.It Fl N
88Do not create a file system: just print out parameters.
89.It Fl @ Ar offset
90Build the filesystem at the specified offset in bytes in the device or file.
91A suffix s, k, m, g (lower or upper case)
92appended to the offset specifies that the
93number is in sectors, kilobytes, megabytes or gigabytes, respectively.
94.It Fl B Ar boot
95Get bootstrap from file.
96.It Fl C Ar create-size
97Create the image file with the specified size.
98A suffix character appended to the size is interpreted as for the
99.Fl @
100option.
101The file is created by truncating any existing file with the same name and
102resizing it to the requested size.
103If the file system supports sparse files, the space occupied on disk may be
104smaller than the size specified as parameter.
105.It Fl F Ar FAT-type
106FAT type (one of 12, 16, or 32).
107.It Fl I Ar VolumeID
108Volume ID, a 32 bit number in decimal or hexadecimal (0x...) format.
109.It Fl L Ar label
110Volume label (up to 11 characters).
111The label should consist of
112only those characters permitted in regular DOS (8+3) filenames.
113.It Fl O Ar OEM
114OEM string (up to 8 characters).
115The default is
116.Qq Li "BSD4.4  " .
117.It Fl S Ar sector-size
118Number of bytes per sector.
119Acceptable values are powers of 2
120in the range 512 through 32768, inclusive.
121.It Fl T Ar timestamp
122Create the filesystem as though the current time is
123.Ar timestamp .
124The default filesystem volume ID is derived from the time.
125.Ar timestamp
126can be a pathname (where the timestamp is derived from
127that file) or an integer value interpreted
128as the number of seconds since the Epoch.
129.It Fl a Ar FAT-size
130Number of sectors per FAT.
131.It Fl b Ar block-size
132File system block size (bytes per cluster).
133This should resolve to an
134acceptable number of sectors per cluster (see below).
135.It Fl c Ar cluster-size
136Sectors per cluster.
137Acceptable values are powers of 2 in the range
1381 through 128.
139If the block or cluster size are not specified, the code
140uses a cluster between 512 bytes and 32K depending on
141the filesystem size.
142.It Fl e Ar DirEnts
143Number of root directory entries (FAT12 and FAT16 only).
144.It Fl f Ar format
145Specify a standard (floppy disk) format.
146The standard formats
147are (capacities in kilobytes): 160, 180, 320, 360, 640, 720, 1200,
1481232, 1440, 2880.
149.It Fl h Ar heads
150Number of drive heads.
151.It Fl i Ar info
152Location of the file system info sector (FAT32 only).
153A value of 0xffff signifies no info sector.
154.It Fl k Ar backup
155Location of the backup boot sector (FAT32 only).
156A value
157of 0xffff signifies no backup sector.
158.It Fl m Ar media
159Media descriptor (acceptable range 0xf0 to 0xff).
160.It Fl n Ar FATs
161Number of FATs.
162Acceptable values are 1 to 16 inclusive.
163The default
164is 2.
165.It Fl o Ar hidden
166Number of hidden sectors.
167.It Fl r Ar reserved
168Number of reserved sectors.
169.It Fl s Ar total
170File system size.
171.It Fl u Ar track-size
172Number of sectors per track.
173.El
174.Sh NOTES
175If some parameters (e.g., size, number of sectors, etc.) are not specified
176through options or disktype, the program tries to generate them automatically.
177In particular, the size is determined as the device or file size minus the
178offset specified with the
179.Fl @
180option.
181When the geometry is not available, it is assumed to be 63 sectors, 255 heads.
182The size is then rounded to become a multiple of the track size and avoid
183complaints by some filesystem code.
184.Pp
185FAT file system parameters occupy a "Boot Sector BPB (BIOS Parameter
186Block)" in the first of the "reserved" sectors which precede the actual
187file system.
188For reference purposes, this structure is presented
189below.
190.Bd -literal
191struct bsbpb {
192    uint16_t	bpbBytesPerSec;		/* [-S] bytes per sector */
193    uint8_t	bpbSecPerClust;		/* [-c] sectors per cluster */
194    uint16_t	bpbResSectors;		/* [-r] reserved sectors */
195    uint8_t	bpbFATs;		/* [-n] number of FATs */
196    uint16_t	bpbRootDirEnts;		/* [-e] root directory entries */
197    uint16_t	bpbSectors;		/* [-s] total sectors */
198    uint8_t	bpbMedia;		/* [-m] media descriptor */
199    uint16_t	bpbFATsecs;		/* [-a] sectors per FAT */
200    uint16_t	bpbSecPerTrack;		/* [-u] sectors per track */
201    uint16_t	bpbHeads;		/* [-h] drive heads */
202    uint32_t	bpbHiddenSecs;		/* [-o] hidden sectors */
203    uint32_t	bpbHugeSectors;		/* [-s] big total sectors */
204};
205/* FAT32 extensions */
206struct bsxbpb {
207    uint32_t	bpbBigFATsecs;		/* [-a] big sectors per FAT */
208    uint16_t	bpbExtFlags;		/* control flags */
209    uint16_t	bpbFSVers;		/* file system version */
210    uint32_t	bpbRootClust;		/* root directory start cluster */
211    uint16_t	bpbFSInfo;		/* [-i] file system info sector */
212    uint16_t	bpbBackup;		/* [-k] backup boot sector */
213};
214.Ed
215.Sh LIMITATION
216The maximum file size is 4GB, even if the file system itself is bigger.
217.Sh EXIT STATUS
218Exit status is 0 on success and 1 on error.
219.Sh EXAMPLES
220Create a file system, using default parameters, on
221.Pa /dev/ada0s1 :
222.Bd -literal -offset indent
223newfs_msdos /dev/ada0s1
224.Ed
225.Pp
226Create a standard 1.44M file system, with volume label
227.Ar foo ,
228on
229.Pa /dev/fd0 :
230.Bd -literal -offset indent
231newfs_msdos -f 1440 -L foo fd0
232.Ed
233.Pp
234Create a 30MB image file, with the FAT partition starting
23563 sectors within the image file:
236.Bd -literal -offset indent
237newfs_msdos -C 30M -@63s ./somefile
238.Ed
239.Sh SEE ALSO
240.Xr gpart 8 ,
241.Xr newfs 8
242.Sh HISTORY
243The
244.Nm
245utility first appeared in
246.Fx 3.0 .
247.Sh AUTHORS
248.An Robert Nordier Aq Mt rnordier@FreeBSD.org
249