1.\" $NetBSD: newfs_msdos.8,v 1.23 2017/02/17 09:29:35 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 February 16, 2017 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 T Ar timestamp 61.Op Fl u Ar track-size 62.Ar special 63.Op Ar disktype 64.Sh DESCRIPTION 65The 66.Nm 67utility creates a FAT12, FAT16, or FAT32 file system on device or file named 68.Ar special , 69using 70.Xr disktab 5 71entry 72.Ar disktype 73to determine geometry, if required. 74.Pp 75The options are as follow: 76.Bl -tag -width indent 77.It Fl N 78Do not create a file system: just print out parameters. 79.It Fl @ Ar offset 80Build the file system at the specified offset in bytes in the device or file. 81A suffix s, k, m, g (lower or upper case) 82appended to the offset specifies that the 83number is in sectors, kilobytes, megabytes or gigabytes, respectively. 84.It Fl B Ar boot 85Get bootstrap from file. 86.It Fl C Ar create-size 87Create the image file with the specified size. 88A suffix character appended to the size is interpreted as for the 89.Fl @ 90option. 91The file is created by truncating any existing file with the 92same name, seeking just before the required size and writing 93a single 0 byte. 94As a consequence, the space occupied on disk 95may be smaller than the size specified as a parameter. 96.It Fl F Ar FAT-type 97FAT type (one of 12, 16, or 32). 98.It Fl I Ar volid 99Volume ID. 100.It Fl L Ar label 101Volume label (up to 11 characters). 102The label should consist of only those characters permitted 103in regular DOS (8+3) filenames. 104The default is 105.Qq Li "NO NAME" . 106.It Fl O Ar OEM 107OEM string (up to 8 characters). 108The default is 109.Qq Li "NetBSD" . 110.It Fl S Ar sector-size 111Number of bytes per sector. 112Acceptable values are powers of 2 in the range 512 through 32768. 113.It Fl a Ar FAT-size 114Number of sectors per FAT. 115.It Fl b Ar block-size 116File system block size (bytes per cluster). 117This should resolve to an acceptable number of sectors 118per cluster (see below). 119.It Fl c Ar cluster-size 120Sectors per cluster. 121Acceptable values are powers of 2 in the range 1 through 128. 122If the block or cluster size are not specified, the code 123uses a cluster between 512 bytes and 32K depending on 124the file system size. 125.It Fl e Ar dirents 126Number of root directory entries (FAT12 and FAT16 only). 127.It Fl f Ar format 128Specify a standard (floppy disk) format. 129The standard formats are (capacities in kilobytes): 130160, 180, 320, 360, 640, 720, 1200, 1232, 1440, 2880. 131.It Fl h Ar heads 132Number of drive heads. 133.It Fl i Ar info 134Location of the file system info sector (FAT32 only). 135A value of 0xffff signifies no info sector. 136.It Fl k Ar backup 137Location of the backup boot sector (FAT32 only). 138A value of 0xffff signifies no backup sector. 139.It Fl m Ar media 140Media descriptor (acceptable range 0xf0 to 0xff). 141.It Fl n Ar FATs 142Number of FATs. 143Acceptable values are 1 to 16 inclusive. 144The default is 2. 145.It Fl o Ar hidden 146Number of hidden sectors. 147.It Fl r Ar reserved 148Number of reserved sectors. 149.It Fl s Ar total 150File system size. 151.It Fl T At timestamp 152Specify a timestamp to be used for file system creation so that 153it can be consistent for reproducible builds. 154The timestamp can be a pathname, where the timestamps are derived from 155that file, a parseable date for parsedate(3) (this option is not 156yet available in the tools build), or an integer value interpreted 157as the number of seconds from the Epoch. 158.It Fl u Ar track-size 159Number of sectors per track. 160.El 161.Pp 162If 163.Nm 164receives a 165.Dv SIGINFO 166signal 167(see the 168.Sy status 169argument for 170.Xr stty 1 ) , 171a line will be written to the standard error output indicating 172the name of the device currently being formatted, the sector 173number being written, and the total number of sectors to be written. 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 177automatically. 178In particular, the size is determined as the 179device or file size minus the offset specified with the 180.Fl @ 181option. 182When the geometry is not available, it is assumed to be 18363 sectors, 255 heads. 184The size is then rounded to become 185a multiple of the track size and avoid complaints by some file system code. 186.Pp 187FAT file system parameters occupy a "Boot Sector BPB (BIOS Parameter 188Block)" in the first of the "reserved" sectors which precede the actual 189file system. 190For reference purposes, this structure is presented below. 191.Bd -literal 192struct bsbpb { 193 u_int16_t bps; /* [-S] bytes per sector */ 194 u_int8_t spc; /* [-c] sectors per cluster */ 195 u_int16_t res; /* [-r] reserved sectors */ 196 u_int8_t nft; /* [-n] number of FATs */ 197 u_int16_t rde; /* [-e] root directory entries */ 198 u_int16_t sec; /* [-s] total sectors */ 199 u_int8_t mid; /* [-m] media descriptor */ 200 u_int16_t spf; /* [-a] sectors per FAT */ 201 u_int16_t spt; /* [-u] sectors per track */ 202 u_int16_t hds; /* [-h] drive heads */ 203 u_int32_t hid; /* [-o] hidden sectors */ 204 u_int32_t bsec; /* [-s] big total sectors */ 205}; 206/* FAT32 extensions */ 207struct bsxbpb { 208 u_int32_t bspf; /* [-a] big sectors per FAT */ 209 u_int16_t xflg; /* control flags */ 210 u_int16_t vers; /* file system version */ 211 u_int32_t rdcl; /* root directory start cluster */ 212 u_int16_t infs; /* [-i] file system info sector */ 213 u_int16_t bkbs; /* [-k] backup boot sector */ 214}; 215.Ed 216.Sh EXAMPLES 217.Bd -literal -offset indent 218newfs_msdos /dev/rwd1a 219.Ed 220.Pp 221Create a file system, using default parameters, on 222.Pa /dev/rwd1a . 223.Bd -literal -offset indent 224newfs_msdos -f 1440 -L foo /dev/rfd0a 225.Ed 226.Pp 227Create a standard 1.44M file system, with volume label 228.Ar foo , 229on 230.Pa /dev/rfd0a . 231Create a 30MB image file, with the FAT partition starting 23263 sectors within the image file: 233.Bd -literal -offset indent 234newfs_msdos -C 30M -@63s ./somefile 235.Ed 236.Sh DIAGNOSTICS 237Exit status is 0 on success and 1 on error. 238.Sh SEE ALSO 239.Xr disktab 5 , 240.Xr disklabel 8 , 241.Xr fdisk 8 , 242.Xr newfs 8 243.Sh HISTORY 244A 245.Nm 246utility appeared in 247.Fx 3.0 . 248The 249.Nm 250command first appeared in 251.Nx 1.3 . 252.Sh AUTHORS 253.An Robert Nordier Aq Mt rnordier@FreeBSD.org . 254