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