1*d656534bSElliott Hughes.\" Copyright (c) 1998 Robert Nordier 2*d656534bSElliott Hughes.\" All rights reserved. 3*d656534bSElliott Hughes.\" 4*d656534bSElliott Hughes.\" Redistribution and use in source and binary forms, with or without 5*d656534bSElliott Hughes.\" modification, are permitted provided that the following conditions 6*d656534bSElliott Hughes.\" are met: 7*d656534bSElliott Hughes.\" 1. Redistributions of source code must retain the above copyright 8*d656534bSElliott Hughes.\" notice, this list of conditions and the following disclaimer. 9*d656534bSElliott Hughes.\" 2. Redistributions in binary form must reproduce the above copyright 10*d656534bSElliott Hughes.\" notice, this list of conditions and the following disclaimer in 11*d656534bSElliott Hughes.\" the documentation and/or other materials provided with the 12*d656534bSElliott Hughes.\" distribution. 13*d656534bSElliott Hughes.\" 14*d656534bSElliott Hughes.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS 15*d656534bSElliott Hughes.\" OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 16*d656534bSElliott Hughes.\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17*d656534bSElliott Hughes.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY 18*d656534bSElliott Hughes.\" DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19*d656534bSElliott Hughes.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 20*d656534bSElliott Hughes.\" GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 21*d656534bSElliott Hughes.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 22*d656534bSElliott Hughes.\" IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 23*d656534bSElliott Hughes.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 24*d656534bSElliott Hughes.\" IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25*d656534bSElliott Hughes.\" 26*d656534bSElliott Hughes.\" $FreeBSD: head/sbin/newfs_msdos/newfs_msdos.8 335189 2018-06-15 06:03:40Z delphij $ 27*d656534bSElliott Hughes.\" 28*d656534bSElliott Hughes.Dd June 14, 2018 29*d656534bSElliott Hughes.Dt NEWFS_MSDOS 8 30*d656534bSElliott Hughes.Os 31*d656534bSElliott Hughes.Sh NAME 32*d656534bSElliott Hughes.Nm newfs_msdos 33*d656534bSElliott Hughes.Nd construct a new MS-DOS (FAT) file system 34*d656534bSElliott Hughes.Sh SYNOPSIS 35*d656534bSElliott Hughes.Nm 36*d656534bSElliott Hughes.Op Fl N 37*d656534bSElliott Hughes.Op Fl @ Ar offset 38*d656534bSElliott Hughes.Op Fl A 39*d656534bSElliott Hughes.Op Fl B Ar boot 40*d656534bSElliott Hughes.Op Fl C Ar create-size 41*d656534bSElliott Hughes.Op Fl F Ar FAT-type 42*d656534bSElliott Hughes.Op Fl I Ar VolumeID 43*d656534bSElliott Hughes.Op Fl L Ar label 44*d656534bSElliott Hughes.Op Fl O Ar OEM 45*d656534bSElliott Hughes.Op Fl S Ar sector-size 46*d656534bSElliott Hughes.Op Fl T Ar timestamp 47*d656534bSElliott Hughes.Op Fl a Ar FAT-size 48*d656534bSElliott Hughes.Op Fl b Ar block-size 49*d656534bSElliott Hughes.Op Fl c Ar cluster-size 50*d656534bSElliott Hughes.Op Fl e Ar DirEnts 51*d656534bSElliott Hughes.Op Fl f Ar format 52*d656534bSElliott Hughes.Op Fl h Ar heads 53*d656534bSElliott Hughes.Op Fl i Ar info 54*d656534bSElliott Hughes.Op Fl k Ar backup 55*d656534bSElliott Hughes.Op Fl m Ar media 56*d656534bSElliott Hughes.Op Fl n Ar FATs 57*d656534bSElliott Hughes.Op Fl o Ar hidden 58*d656534bSElliott Hughes.Op Fl r Ar reserved 59*d656534bSElliott Hughes.Op Fl s Ar total 60*d656534bSElliott Hughes.Op Fl u Ar track-size 61*d656534bSElliott Hughes.Ar special 62*d656534bSElliott Hughes.Op Ar disktype 63*d656534bSElliott Hughes.Sh DESCRIPTION 64*d656534bSElliott HughesThe 65*d656534bSElliott Hughes.Nm 66*d656534bSElliott Hughesutility creates a FAT12, FAT16, or FAT32 file system on device or file named 67*d656534bSElliott Hughes.Ar special , 68*d656534bSElliott Hughesusing 69*d656534bSElliott Hughes.Xr disktab 5 70*d656534bSElliott Hughesentry 71*d656534bSElliott Hughes.Ar disktype 72*d656534bSElliott Hughesto determine geometry, if required. 73*d656534bSElliott Hughes.Pp 74*d656534bSElliott HughesIf 75*d656534bSElliott Hughes.Ar special 76*d656534bSElliott Hughesdoes not contain a 77*d656534bSElliott Hughes.Ar / 78*d656534bSElliott Hughesand 79*d656534bSElliott Hughes.Fl C 80*d656534bSElliott Hughesis not used, it is assumed to be a device name and 81*d656534bSElliott Hughes.Ar /dev/ 82*d656534bSElliott Hughesis prepended to the name to construct the actual device name. 83*d656534bSElliott HughesTo work a file in the current directory use 84*d656534bSElliott Hughes.Ar ./filename 85*d656534bSElliott Hughes.Pp 86*d656534bSElliott HughesThe options are as follow: 87*d656534bSElliott Hughes.Bl -tag -width indent 88*d656534bSElliott Hughes.It Fl N 89*d656534bSElliott HughesDo not create a file system: just print out parameters. 90*d656534bSElliott Hughes.It Fl @ Ar offset 91*d656534bSElliott HughesBuild the filesystem at the specified offset in bytes in the device or file. 92*d656534bSElliott HughesA suffix s, k, m, g (lower or upper case) 93*d656534bSElliott Hughesappended to the offset specifies that the 94*d656534bSElliott Hughesnumber is in sectors, kilobytes, megabytes or gigabytes, respectively. 95*d656534bSElliott Hughes.It Fl A 96*d656534bSElliott HughesAttempt to cluster align root directory, useful for SD card. 97*d656534bSElliott Hughes.It Fl B Ar boot 98*d656534bSElliott HughesGet bootstrap from file. 99*d656534bSElliott Hughes.It Fl C Ar create-size 100*d656534bSElliott HughesCreate the image file with the specified size. 101*d656534bSElliott HughesA suffix character appended to the size is interpreted as for the 102*d656534bSElliott Hughes.Fl @ 103*d656534bSElliott Hughesoption. 104*d656534bSElliott HughesThe file is created by truncating any existing file with the same name and 105*d656534bSElliott Hughesresizing it to the requested size. 106*d656534bSElliott HughesIf the file system supports sparse files, the space occupied on disk may be 107*d656534bSElliott Hughessmaller than the size specified as parameter. 108*d656534bSElliott Hughes.It Fl F Ar FAT-type 109*d656534bSElliott HughesFAT type (one of 12, 16, or 32). 110*d656534bSElliott Hughes.It Fl I Ar VolumeID 111*d656534bSElliott HughesVolume ID, a 32 bit number in decimal or hexadecimal (0x...) format. 112*d656534bSElliott Hughes.It Fl L Ar label 113*d656534bSElliott HughesVolume label (up to 11 characters). 114*d656534bSElliott HughesThe label should consist of 115*d656534bSElliott Hughesonly those characters permitted in regular DOS (8+3) filenames. 116*d656534bSElliott Hughes.It Fl O Ar OEM 117*d656534bSElliott HughesOEM string (up to 8 characters). 118*d656534bSElliott HughesThe default is 119*d656534bSElliott Hughes.Qq Li "BSD4.4 " . 120*d656534bSElliott Hughes.It Fl S Ar sector-size 121*d656534bSElliott HughesNumber of bytes per sector. 122*d656534bSElliott HughesAcceptable values are powers of 2 123*d656534bSElliott Hughesin the range 512 through 32768, inclusive. 124*d656534bSElliott Hughes.It Fl T Ar timestamp 125*d656534bSElliott HughesCreate the filesystem as though the current time is 126*d656534bSElliott Hughes.Ar timestamp . 127*d656534bSElliott HughesThe default filesystem volume ID is derived from the time. 128*d656534bSElliott Hughes.Ar timestamp 129*d656534bSElliott Hughescan be a pathname (where the timestamp is derived from 130*d656534bSElliott Hughesthat file) or an integer value interpreted 131*d656534bSElliott Hughesas the number of seconds since the Epoch. 132*d656534bSElliott Hughes.It Fl a Ar FAT-size 133*d656534bSElliott HughesNumber of sectors per FAT. 134*d656534bSElliott Hughes.It Fl b Ar block-size 135*d656534bSElliott HughesFile system block size (bytes per cluster). 136*d656534bSElliott HughesThis should resolve to an 137*d656534bSElliott Hughesacceptable number of sectors per cluster (see below). 138*d656534bSElliott Hughes.It Fl c Ar cluster-size 139*d656534bSElliott HughesSectors per cluster. 140*d656534bSElliott HughesAcceptable values are powers of 2 in the range 141*d656534bSElliott Hughes1 through 128. 142*d656534bSElliott HughesIf the block or cluster size are not specified, the code 143*d656534bSElliott Hughesuses a cluster between 512 bytes and 32K depending on 144*d656534bSElliott Hughesthe filesystem size. 145*d656534bSElliott Hughes.It Fl e Ar DirEnts 146*d656534bSElliott HughesNumber of root directory entries (FAT12 and FAT16 only). 147*d656534bSElliott Hughes.It Fl f Ar format 148*d656534bSElliott HughesSpecify a standard (floppy disk) format. 149*d656534bSElliott HughesThe standard formats 150*d656534bSElliott Hughesare (capacities in kilobytes): 160, 180, 320, 360, 640, 720, 1200, 151*d656534bSElliott Hughes1232, 1440, 2880. 152*d656534bSElliott Hughes.It Fl h Ar heads 153*d656534bSElliott HughesNumber of drive heads. 154*d656534bSElliott Hughes.It Fl i Ar info 155*d656534bSElliott HughesLocation of the file system info sector (FAT32 only). 156*d656534bSElliott HughesA value of 0xffff signifies no info sector. 157*d656534bSElliott Hughes.It Fl k Ar backup 158*d656534bSElliott HughesLocation of the backup boot sector (FAT32 only). 159*d656534bSElliott HughesA value 160*d656534bSElliott Hughesof 0xffff signifies no backup sector. 161*d656534bSElliott Hughes.It Fl m Ar media 162*d656534bSElliott HughesMedia descriptor (acceptable range 0xf0 to 0xff). 163*d656534bSElliott Hughes.It Fl n Ar FATs 164*d656534bSElliott HughesNumber of FATs. 165*d656534bSElliott HughesAcceptable values are 1 to 16 inclusive. 166*d656534bSElliott HughesThe default 167*d656534bSElliott Hughesis 2. 168*d656534bSElliott Hughes.It Fl o Ar hidden 169*d656534bSElliott HughesNumber of hidden sectors. 170*d656534bSElliott Hughes.It Fl r Ar reserved 171*d656534bSElliott HughesNumber of reserved sectors. 172*d656534bSElliott Hughes.It Fl s Ar total 173*d656534bSElliott HughesFile system size. 174*d656534bSElliott Hughes.It Fl u Ar track-size 175*d656534bSElliott HughesNumber of sectors per track. 176*d656534bSElliott Hughes.El 177*d656534bSElliott Hughes.Sh NOTES 178*d656534bSElliott HughesIf some parameters (e.g., size, number of sectors, etc.) are not specified 179*d656534bSElliott Hughesthrough options or disktype, the program tries to generate them automatically. 180*d656534bSElliott HughesIn particular, the size is determined as the device or file size minus the 181*d656534bSElliott Hughesoffset specified with the 182*d656534bSElliott Hughes.Fl @ 183*d656534bSElliott Hughesoption. 184*d656534bSElliott HughesWhen the geometry is not available, it is assumed to be 63 sectors, 255 heads. 185*d656534bSElliott HughesThe size is then rounded to become a multiple of the track size and avoid 186*d656534bSElliott Hughescomplaints by some filesystem code. 187*d656534bSElliott Hughes.Pp 188*d656534bSElliott HughesFAT file system parameters occupy a "Boot Sector BPB (BIOS Parameter 189*d656534bSElliott HughesBlock)" in the first of the "reserved" sectors which precede the actual 190*d656534bSElliott Hughesfile system. 191*d656534bSElliott HughesFor reference purposes, this structure is presented 192*d656534bSElliott Hughesbelow. 193*d656534bSElliott Hughes.Bd -literal 194*d656534bSElliott Hughesstruct bsbpb { 195*d656534bSElliott Hughes uint16_t bpbBytesPerSec; /* [-S] bytes per sector */ 196*d656534bSElliott Hughes uint8_t bpbSecPerClust; /* [-c] sectors per cluster */ 197*d656534bSElliott Hughes uint16_t bpbResSectors; /* [-r] reserved sectors */ 198*d656534bSElliott Hughes uint8_t bpbFATs; /* [-n] number of FATs */ 199*d656534bSElliott Hughes uint16_t bpbRootDirEnts; /* [-e] root directory entries */ 200*d656534bSElliott Hughes uint16_t bpbSectors; /* [-s] total sectors */ 201*d656534bSElliott Hughes uint8_t bpbMedia; /* [-m] media descriptor */ 202*d656534bSElliott Hughes uint16_t bpbFATsecs; /* [-a] sectors per FAT */ 203*d656534bSElliott Hughes uint16_t bpbSecPerTrack; /* [-u] sectors per track */ 204*d656534bSElliott Hughes uint16_t bpbHeads; /* [-h] drive heads */ 205*d656534bSElliott Hughes uint32_t bpbHiddenSecs; /* [-o] hidden sectors */ 206*d656534bSElliott Hughes uint32_t bpbHugeSectors; /* [-s] big total sectors */ 207*d656534bSElliott Hughes}; 208*d656534bSElliott Hughes/* FAT32 extensions */ 209*d656534bSElliott Hughesstruct bsxbpb { 210*d656534bSElliott Hughes uint32_t bpbBigFATsecs; /* [-a] big sectors per FAT */ 211*d656534bSElliott Hughes uint16_t bpbExtFlags; /* control flags */ 212*d656534bSElliott Hughes uint16_t bpbFSVers; /* file system version */ 213*d656534bSElliott Hughes uint32_t bpbRootClust; /* root directory start cluster */ 214*d656534bSElliott Hughes uint16_t bpbFSInfo; /* [-i] file system info sector */ 215*d656534bSElliott Hughes uint16_t bpbBackup; /* [-k] backup boot sector */ 216*d656534bSElliott Hughes}; 217*d656534bSElliott Hughes.Ed 218*d656534bSElliott Hughes.Sh LIMITATION 219*d656534bSElliott HughesThe maximum file size is 4GB, even if the file system itself is bigger. 220*d656534bSElliott Hughes.Sh EXIT STATUS 221*d656534bSElliott HughesExit status is 0 on success and 1 on error. 222*d656534bSElliott Hughes.Sh EXAMPLES 223*d656534bSElliott HughesCreate a file system, using default parameters, on 224*d656534bSElliott Hughes.Pa /dev/ada0s1 : 225*d656534bSElliott Hughes.Bd -literal -offset indent 226*d656534bSElliott Hughesnewfs_msdos /dev/ada0s1 227*d656534bSElliott Hughes.Ed 228*d656534bSElliott Hughes.Pp 229*d656534bSElliott HughesCreate a standard 1.44M file system, with volume label 230*d656534bSElliott Hughes.Ar foo , 231*d656534bSElliott Hugheson 232*d656534bSElliott Hughes.Pa /dev/fd0 : 233*d656534bSElliott Hughes.Bd -literal -offset indent 234*d656534bSElliott Hughesnewfs_msdos -f 1440 -L foo fd0 235*d656534bSElliott Hughes.Ed 236*d656534bSElliott Hughes.Pp 237*d656534bSElliott HughesCreate a 30MB image file, with the FAT partition starting 238*d656534bSElliott Hughes63 sectors within the image file: 239*d656534bSElliott Hughes.Bd -literal -offset indent 240*d656534bSElliott Hughesnewfs_msdos -C 30M -@63s ./somefile 241*d656534bSElliott Hughes.Ed 242*d656534bSElliott Hughes.Sh SEE ALSO 243*d656534bSElliott Hughes.Xr gpart 8 , 244*d656534bSElliott Hughes.Xr newfs 8 245*d656534bSElliott Hughes.Sh HISTORY 246*d656534bSElliott HughesThe 247*d656534bSElliott Hughes.Nm 248*d656534bSElliott Hughesutility first appeared in 249*d656534bSElliott Hughes.Fx 3.0 . 250*d656534bSElliott Hughes.Sh AUTHORS 251*d656534bSElliott Hughes.An Robert Nordier Aq Mt [email protected] 252