1*704d4179Sryoon.\" $NetBSD: newfs_msdos.8,v 1.24 2020/12/11 18:49:37 ryoon Exp $ 2d06c5d9fSthorpej.\" 3de3ce7e7Schristos.\" Copyright (c) 1998 Robert Nordier 4d5fff03eSchristos.\" All rights reserved. 5d5fff03eSchristos.\" 6d5fff03eSchristos.\" Redistribution and use in source and binary forms, with or without 7d5fff03eSchristos.\" modification, are permitted provided that the following conditions 8d5fff03eSchristos.\" are met: 9d5fff03eSchristos.\" 1. Redistributions of source code must retain the above copyright 10d5fff03eSchristos.\" notice, this list of conditions and the following disclaimer. 11d5fff03eSchristos.\" 2. Redistributions in binary form must reproduce the above copyright 12de3ce7e7Schristos.\" notice, this list of conditions and the following disclaimer in 13de3ce7e7Schristos.\" the documentation and/or other materials provided with the 14de3ce7e7Schristos.\" distribution. 15d5fff03eSchristos.\" 16de3ce7e7Schristos.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS 17de3ce7e7Schristos.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18de3ce7e7Schristos.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19de3ce7e7Schristos.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY 20de3ce7e7Schristos.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21de3ce7e7Schristos.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 22de3ce7e7Schristos.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23de3ce7e7Schristos.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 24de3ce7e7Schristos.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 25de3ce7e7Schristos.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 26de3ce7e7Schristos.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27d5fff03eSchristos.\" 28de3ce7e7Schristos.\" From: $FreeBSD: src/sbin/newfs_msdos/newfs_msdos.8,v 1.13 2001/08/14 10:01:48 ru Exp $ 29d5fff03eSchristos.\" 3029723468Schristos.Dd February 16, 2017 31d5fff03eSchristos.Dt NEWFS_MSDOS 8 32de3ce7e7Schristos.Os 33d5fff03eSchristos.Sh NAME 34d5fff03eSchristos.Nm newfs_msdos 35de3ce7e7Schristos.Nd construct a new MS-DOS (FAT) file system 36d5fff03eSchristos.Sh SYNOPSIS 37d5fff03eSchristos.Nm 38de3ce7e7Schristos.Op Fl N 3932852eceSpooka.Op Fl @ Ar offset 40de3ce7e7Schristos.Op Fl B Ar boot 4132852eceSpooka.Op Fl C Ar create-size 42de3ce7e7Schristos.Op Fl F Ar FAT-type 43de3ce7e7Schristos.Op Fl I Ar volid 44de3ce7e7Schristos.Op Fl L Ar label 45de3ce7e7Schristos.Op Fl O Ar OEM 46de3ce7e7Schristos.Op Fl S Ar sector-size 47de3ce7e7Schristos.Op Fl a Ar FAT-size 48de3ce7e7Schristos.Op Fl b Ar block-size 49de3ce7e7Schristos.Op Fl c Ar cluster-size 50de3ce7e7Schristos.Op Fl e Ar dirents 51de3ce7e7Schristos.Op Fl f Ar format 52de3ce7e7Schristos.Op Fl h Ar heads 53de3ce7e7Schristos.Op Fl i Ar info 54de3ce7e7Schristos.Op Fl k Ar backup 55de3ce7e7Schristos.Op Fl m Ar media 56de3ce7e7Schristos.Op Fl n Ar FATs 57de3ce7e7Schristos.Op Fl o Ar hidden 58de3ce7e7Schristos.Op Fl r Ar reserved 59de3ce7e7Schristos.Op Fl s Ar total 6029723468Schristos.Op Fl T Ar timestamp 61de3ce7e7Schristos.Op Fl u Ar track-size 62de3ce7e7Schristos.Ar special 63de3ce7e7Schristos.Op Ar disktype 64d5fff03eSchristos.Sh DESCRIPTION 65de3ce7e7SchristosThe 66d5fff03eSchristos.Nm 6732852eceSpookautility creates a FAT12, FAT16, or FAT32 file system on device or file named 68de3ce7e7Schristos.Ar special , 69de3ce7e7Schristosusing 70de3ce7e7Schristos.Xr disktab 5 71de3ce7e7Schristosentry 72de3ce7e7Schristos.Ar disktype 73de3ce7e7Schristosto determine geometry, if required. 74d5fff03eSchristos.Pp 75de3ce7e7SchristosThe options are as follow: 76de3ce7e7Schristos.Bl -tag -width indent 77de3ce7e7Schristos.It Fl N 781137c8dcSsevanDo not create a file system: just print out parameters. 7932852eceSpooka.It Fl @ Ar offset 8032852eceSpookaBuild the file system at the specified offset in bytes in the device or file. 8132852eceSpookaA suffix s, k, m, g (lower or upper case) 8232852eceSpookaappended to the offset specifies that the 8332852eceSpookanumber is in sectors, kilobytes, megabytes or gigabytes, respectively. 84de3ce7e7Schristos.It Fl B Ar boot 85de3ce7e7SchristosGet bootstrap from file. 8632852eceSpooka.It Fl C Ar create-size 8732852eceSpookaCreate the image file with the specified size. 8832852eceSpookaA suffix character appended to the size is interpreted as for the 8932852eceSpooka.Fl @ 9032852eceSpookaoption. 9132852eceSpookaThe file is created by truncating any existing file with the 9232852eceSpookasame name, seeking just before the required size and writing 9332852eceSpookaa single 0 byte. 9432852eceSpookaAs a consequence, the space occupied on disk 9532852eceSpookamay be smaller than the size specified as a parameter. 96de3ce7e7Schristos.It Fl F Ar FAT-type 97de3ce7e7SchristosFAT type (one of 12, 16, or 32). 98de3ce7e7Schristos.It Fl I Ar volid 99de3ce7e7SchristosVolume ID. 100de3ce7e7Schristos.It Fl L Ar label 1012fb4b1dbSwizVolume label (up to 11 characters). 1022fb4b1dbSwizThe label should consist of only those characters permitted 1032fb4b1dbSwizin regular DOS (8+3) filenames. 1046e82649dSthorpejThe default is 105e6c9ef61Schristos.Qq Li "NO NAME" . 106de3ce7e7Schristos.It Fl O Ar OEM 1072fb4b1dbSwizOEM string (up to 8 characters). 1082fb4b1dbSwizThe default is 1093af81affSthorpej.Qq Li "NetBSD" . 110de3ce7e7Schristos.It Fl S Ar sector-size 1112fb4b1dbSwizNumber of bytes per sector. 112258fa36dSscwAcceptable values are powers of 2 in the range 512 through 32768. 113de3ce7e7Schristos.It Fl a Ar FAT-size 114de3ce7e7SchristosNumber of sectors per FAT. 115de3ce7e7Schristos.It Fl b Ar block-size 1162fb4b1dbSwizFile system block size (bytes per cluster). 1172fb4b1dbSwizThis should resolve to an acceptable number of sectors 1182fb4b1dbSwizper cluster (see below). 119de3ce7e7Schristos.It Fl c Ar cluster-size 1202fb4b1dbSwizSectors per cluster. 1212fb4b1dbSwizAcceptable values are powers of 2 in the range 1 through 128. 12232852eceSpookaIf the block or cluster size are not specified, the code 12332852eceSpookauses a cluster between 512 bytes and 32K depending on 12432852eceSpookathe file system size. 125de3ce7e7Schristos.It Fl e Ar dirents 126de3ce7e7SchristosNumber of root directory entries (FAT12 and FAT16 only). 127de3ce7e7Schristos.It Fl f Ar format 1282fb4b1dbSwizSpecify a standard (floppy disk) format. 1292fb4b1dbSwizThe standard formats are (capacities in kilobytes): 1302fb4b1dbSwiz160, 180, 320, 360, 640, 720, 1200, 1232, 1440, 2880. 131de3ce7e7Schristos.It Fl h Ar heads 132de3ce7e7SchristosNumber of drive heads. 133de3ce7e7Schristos.It Fl i Ar info 134de3ce7e7SchristosLocation of the file system info sector (FAT32 only). 135de3ce7e7SchristosA value of 0xffff signifies no info sector. 136de3ce7e7Schristos.It Fl k Ar backup 1372fb4b1dbSwizLocation of the backup boot sector (FAT32 only). 1382fb4b1dbSwizA value of 0xffff signifies no backup sector. 139de3ce7e7Schristos.It Fl m Ar media 140de3ce7e7SchristosMedia descriptor (acceptable range 0xf0 to 0xff). 141de3ce7e7Schristos.It Fl n Ar FATs 1422fb4b1dbSwizNumber of FATs. 1432fb4b1dbSwizAcceptable values are 1 to 16 inclusive. 1442fb4b1dbSwizThe default is 2. 145de3ce7e7Schristos.It Fl o Ar hidden 146de3ce7e7SchristosNumber of hidden sectors. 147de3ce7e7Schristos.It Fl r Ar reserved 148de3ce7e7SchristosNumber of reserved sectors. 149de3ce7e7Schristos.It Fl s Ar total 150de3ce7e7SchristosFile system size. 15129723468Schristos.It Fl T At timestamp 15229723468SchristosSpecify a timestamp to be used for file system creation so that 15329723468Schristosit can be consistent for reproducible builds. 15429723468SchristosThe timestamp can be a pathname, where the timestamps are derived from 15529723468Schristosthat file, a parseable date for parsedate(3) (this option is not 15629723468Schristosyet available in the tools build), or an integer value interpreted 15729723468Schristosas the number of seconds from the Epoch. 158de3ce7e7Schristos.It Fl u Ar track-size 159de3ce7e7SchristosNumber of sectors per track. 160d5fff03eSchristos.El 1612e6348f3Sdbj.Pp 1622e6348f3SdbjIf 1632e6348f3Sdbj.Nm 1642e6348f3Sdbjreceives a 1652e6348f3Sdbj.Dv SIGINFO 1662e6348f3Sdbjsignal 1672e6348f3Sdbj(see the 1682e6348f3Sdbj.Sy status 1692e6348f3Sdbjargument for 1702e6348f3Sdbj.Xr stty 1 ) , 1712e6348f3Sdbja line will be written to the standard error output indicating 1722e6348f3Sdbjthe name of the device currently being formatted, the sector 1732e6348f3Sdbjnumber being written, and the total number of sectors to be written. 174de3ce7e7Schristos.Sh NOTES 17532852eceSpookaIf some parameters (e.g. size, number of sectors, etc.) are not specified 17632852eceSpookathrough options or disktype, the program tries to generate them 17761ae4edcSwizautomatically. 17861ae4edcSwizIn particular, the size is determined as the 17932852eceSpookadevice or file size minus the offset specified with the 18032852eceSpooka.Fl @ 18161ae4edcSwizoption. 18261ae4edcSwizWhen the geometry is not available, it is assumed to be 18361ae4edcSwiz63 sectors, 255 heads. 18461ae4edcSwizThe size is then rounded to become 18532852eceSpookaa multiple of the track size and avoid complaints by some file system code. 18632852eceSpooka.Pp 187de3ce7e7SchristosFAT file system parameters occupy a "Boot Sector BPB (BIOS Parameter 188de3ce7e7SchristosBlock)" in the first of the "reserved" sectors which precede the actual 1892fb4b1dbSwizfile system. 1902fb4b1dbSwizFor reference purposes, this structure is presented below. 191de3ce7e7Schristos.Bd -literal 192de3ce7e7Schristosstruct bsbpb { 193de3ce7e7Schristos u_int16_t bps; /* [-S] bytes per sector */ 194de3ce7e7Schristos u_int8_t spc; /* [-c] sectors per cluster */ 195de3ce7e7Schristos u_int16_t res; /* [-r] reserved sectors */ 196de3ce7e7Schristos u_int8_t nft; /* [-n] number of FATs */ 197de3ce7e7Schristos u_int16_t rde; /* [-e] root directory entries */ 198de3ce7e7Schristos u_int16_t sec; /* [-s] total sectors */ 199de3ce7e7Schristos u_int8_t mid; /* [-m] media descriptor */ 200de3ce7e7Schristos u_int16_t spf; /* [-a] sectors per FAT */ 201de3ce7e7Schristos u_int16_t spt; /* [-u] sectors per track */ 202de3ce7e7Schristos u_int16_t hds; /* [-h] drive heads */ 203de3ce7e7Schristos u_int32_t hid; /* [-o] hidden sectors */ 204de3ce7e7Schristos u_int32_t bsec; /* [-s] big total sectors */ 205de3ce7e7Schristos}; 206de3ce7e7Schristos/* FAT32 extensions */ 207de3ce7e7Schristosstruct bsxbpb { 208de3ce7e7Schristos u_int32_t bspf; /* [-a] big sectors per FAT */ 209de3ce7e7Schristos u_int16_t xflg; /* control flags */ 210de3ce7e7Schristos u_int16_t vers; /* file system version */ 211de3ce7e7Schristos u_int32_t rdcl; /* root directory start cluster */ 212de3ce7e7Schristos u_int16_t infs; /* [-i] file system info sector */ 213de3ce7e7Schristos u_int16_t bkbs; /* [-k] backup boot sector */ 214de3ce7e7Schristos}; 215de3ce7e7Schristos.Ed 216de3ce7e7Schristos.Sh EXAMPLES 217de3ce7e7Schristos.Bd -literal -offset indent 218d06c5d9fSthorpejnewfs_msdos /dev/rwd1a 219de3ce7e7Schristos.Ed 220d5fff03eSchristos.Pp 221de3ce7e7SchristosCreate a file system, using default parameters, on 222d06c5d9fSthorpej.Pa /dev/rwd1a . 223de3ce7e7Schristos.Bd -literal -offset indent 224d06c5d9fSthorpejnewfs_msdos -f 1440 -L foo /dev/rfd0a 225de3ce7e7Schristos.Ed 226de3ce7e7Schristos.Pp 227de3ce7e7SchristosCreate a standard 1.44M file system, with volume label 228de3ce7e7Schristos.Ar foo , 229de3ce7e7Schristoson 230d06c5d9fSthorpej.Pa /dev/rfd0a . 23132852eceSpooka.Bd -literal -offset indent 23232852eceSpookanewfs_msdos -C 30M -@63s ./somefile 23332852eceSpooka.Ed 234*704d4179Sryoon.Pp 235*704d4179SryoonCreate a 30MB image file, with the FAT partition starting 236*704d4179Sryoon63 sectors within the image file: 23780d1ff49Swiz.Sh DIAGNOSTICS 23880d1ff49SwizExit status is 0 on success and 1 on error. 239d5fff03eSchristos.Sh SEE ALSO 240de3ce7e7Schristos.Xr disktab 5 , 241de3ce7e7Schristos.Xr disklabel 8 , 242de3ce7e7Schristos.Xr fdisk 8 , 243f8c66df3Smsaitoh.Xr newfs 8 244d5fff03eSchristos.Sh HISTORY 2451137c8dcSsevanA 2461137c8dcSsevan.Nm 2471137c8dcSsevanutility appeared in 2481137c8dcSsevan.Fx 3.0 . 249de3ce7e7SchristosThe 250d5fff03eSchristos.Nm 251de3ce7e7Schristoscommand first appeared in 252d06c5d9fSthorpej.Nx 1.3 . 253de3ce7e7Schristos.Sh AUTHORS 254a5684d07Swiz.An Robert Nordier Aq Mt rnordier@FreeBSD.org . 255