Annotation of src/sbin/fdisk/fdisk.8, Revision 1.49
1.49 ! wiz 1: .\" $NetBSD: fdisk.8,v 1.48 2004/07/13 10:45:49 darcy Exp $
1.8 cgd 2: .\"
1.49 ! wiz 3: .Dd July 13, 2004
1.1 cgd 4: .Dt FDISK 8
1.25 wiz 5: .Os
1.1 cgd 6: .Sh NAME
7: .Nm fdisk
1.43 lukem 8: .Nd MS-DOS partition maintenance program
1.1 cgd 9: .Sh SYNOPSIS
1.34 wiz 10: .Nm
1.44 dyoung 11: .Op Fl afiuvBFS
1.17 mycroft 12: .Bk -words
1.9 phil 13: .Op Fl 0 | 1 | 2 | 3
1.17 mycroft 14: .Ek
15: .Bk -words
1.44 dyoung 16: .Op Fl t Ar disktab
17: .Ek
18: .Bk -words
19: .Op Fl T Ar disktype
20: .Ek
21: .Bk -words
1.35 dsl 22: .Op Fl E Ar number
23: .Ek
24: .Bk -words
1.10 phil 25: .Op Fl b Ar cylinders/heads/sectors
1.17 mycroft 26: .Ek
27: .Bk -words
1.38 wiz 28: .Op Fl s Ar id/start/size Ns Bq Ar /bootmenu
1.17 mycroft 29: .Ek
30: .Bk -words
1.16 ws 31: .Op Fl c Ar bootcode
1.17 mycroft 32: .Ek
33: .Bk -words
1.35 dsl 34: .Op Fl r|w Ar file
35: .Ek
36: .Bk -words
1.6 mycroft 37: .Op Ar device
1.17 mycroft 38: .Ek
1.35 dsl 39: .Nm
40: .Fl l
1.24 lukem 41: .Sh DESCRIPTION
1.35 dsl 42: The
1.1 cgd 43: .Nm
1.35 dsl 44: program is used to divide space on a disk into partitions and set
1.6 mycroft 45: one active.
1.35 dsl 46: There can be at most 4 partitions defined in sector 0,
47: one of which can be an extended
48: partition which can be split into any number of sub-partitions.
1.6 mycroft 49: .Pp
1.13 perry 50: .Nx
1.35 dsl 51: does not use the partitioning done by
52: .Nm ,
53: instead it uses a
54: .Nx
55: disklabel saved in sector 1 of the
56: .Nx
57: partition.
1.1 cgd 58: .Pp
1.45 snj 59: The standard MBR boot code will only boot the
60: .Sq active
61: partition.
1.35 dsl 62: However
63: .Nx
64: contains two alternate boot programs which allow the user to
65: interactively select which of the partitions to boot.
1.45 snj 66: The
67: .Sq mbr_ext
68: code will boot
1.13 perry 69: .Nx
1.35 dsl 70: from an extended partition but will not work on old systems that do not
71: support LBA reads.
1.1 cgd 72: .Pp
1.24 lukem 73: At the start the
74: .Nm
75: program will determine whether the disk sector 0 is valid as a boot sector.
76: (This is determined by checking the magic number.)
77: If not,
78: .Nm
1.35 dsl 79: will initialise the boot code as well as the partition table.
1.24 lukem 80: During this, all four partitions will be marked empty.
81: .Pp
1.1 cgd 82: The flags
1.9 phil 83: .Fl a ,
1.26 wiz 84: .Fl i
1.1 cgd 85: or
86: .Fl u
1.4 jtc 87: are used to indicate that the partition data is to be updated.
1.1 cgd 88: The
89: .Nm
1.24 lukem 90: program will enter an interactive conversational mode.
1.6 mycroft 91: This mode is designed not to change any data unless you explicitly tell it to;
1.1 cgd 92: .Nm
1.35 dsl 93: selects defaults for its questions to guarantee that behaviour.
1.1 cgd 94: .Pp
1.35 dsl 95: .Nm
96: will calculate the correct
1.11 lukem 97: .Em cylinder ,
98: .Em head ,
1.1 cgd 99: and
1.11 lukem 100: .Em sector
1.38 wiz 101: values for any partition you edit.
102: If you specify
1.35 dsl 103: .Fl v
104: you will be asked whether you want to specify them yourself.
1.1 cgd 105: .Pp
1.35 dsl 106: Finally, when all the data for the first sector has been accumulated,
1.6 mycroft 107: .Nm
1.35 dsl 108: will ask if you really want to write the new partition table.
1.6 mycroft 109: Only if you reply affirmatively to this question will
110: .Nm
111: write anything to the disk.
1.1 cgd 112: .Pp
1.24 lukem 113: Available options:
1.18 fvdl 114: .Pp
1.24 lukem 115: .Bl -tag -width Ds
116: .It Fl 0
117: Update partition slot 0.
118: .It Fl 1
119: Update partition slot 1.
120: .It Fl 2
121: Update partition slot 2.
122: .It Fl 3
123: Update partition slot 3.
124: .It Fl a
125: Change the active partition.
126: In interactive mode this question will be asked after the partitions
127: have been processed.
128: .It Fl b Ar cylinders/heads/sectors
129: Specify the BIOS parameters for
130: .Ar cylinders ,
1.38 wiz 131: .Ar heads ,
1.10 phil 132: and
1.24 lukem 133: .Ar sectors .
134: It is used only in conjunction with the
1.10 phil 135: .Fl u
1.15 ws 136: flag.
1.24 lukem 137: .It Fl B
1.35 dsl 138: On an i386 or amd64 system, interactively update the boot selector settings.
1.32 perry 139: (The boot selector permits the user to interactively select the boot
140: partition, and thus which operating system is run, at system boot time.
1.33 wiz 141: See
1.32 perry 142: .Xr mbr 8
143: for more information.)
1.24 lukem 144: .It Fl c Ar bootcode
145: Specify the filename that
146: .Nm
147: should read the bootcode from.
1.35 dsl 148: If the name of a directory is specified, then
149: .Nm
150: will look for files with the default names in that directory.
1.24 lukem 151: The default is to read from
1.35 dsl 152: .Pa /usr/mdec/mbr ,
153: .Pa /usr/mdec/mbr_bootsel
154: or
155: .Pa /usr/mdec/mbr_ext
156: depending on whether
1.40 dsl 157: .Ar bootmenu
1.35 dsl 158: was specified for any partitions
159: on an i386 machine, and leave the bootcode empty for other
1.24 lukem 160: machines.
1.35 dsl 161: .It Fl E Ar number
162: Update extended partition
1.40 dsl 163: .Ar number .
1.35 dsl 164: If the specified extended partition doesn't exist an additional extended
165: partition will be created.
1.24 lukem 166: .It Fl f
167: Run
1.9 phil 168: .Nm
1.24 lukem 169: in a non-interactive mode.
1.26 wiz 170: In this mode, you can only change the disk parameters by using the
1.10 phil 171: .Fl b
1.24 lukem 172: flag.
173: This is provided only so scripts or other programs may use
174: .Nm
175: as part of an automatic installation process.
1.47 lukem 176: .Pp
1.24 lukem 177: Using the
1.9 phil 178: .Fl f
1.12 ross 179: flag with
1.9 phil 180: .Fl u
1.10 phil 181: makes it impossible to specify the starting and ending
1.24 lukem 182: .Ar cylinder ,
1.38 wiz 183: .Ar head ,
1.26 wiz 184: and
1.24 lukem 185: .Ar sector
186: fields.
187: They will be automatically computed using the BIOS geometry.
1.47 lukem 188: .Pp
1.35 dsl 189: If
190: .Fl u
191: and
1.42 joda 192: .Fl s
1.35 dsl 193: are specified then the details of the specified partition will be changed.
194: Any other partitions which overlap the requested part of the disk will be
195: silently deleted.
1.45 snj 196: .It Fl F
1.44 dyoung 197: Indicate that
198: .Ar device
1.45 snj 199: is a regular file.
200: Unless the geometry of
1.44 dyoung 201: .Ar device
202: is told to
1.46 wiz 203: .Nm
1.44 dyoung 204: by
205: .Fl T Ar disktype ,
1.46 wiz 206: .Nm
1.44 dyoung 207: will count the 512-byte sectors in
208: .Ar device
209: and produce a fake geometry.
1.24 lukem 210: .It Fl i
1.35 dsl 211: Explicitly request initialisation of the master boot code
1.24 lukem 212: (similar to what
1.46 wiz 213: .Ic fdisk /mbr
1.24 lukem 214: does under
1.43 lukem 215: .Tn MS-DOS ) ,
1.26 wiz 216: even if the magic number in the first sector is ok.
1.24 lukem 217: The partition table is left alone by this (but see above).
1.30 christos 218: .It Fl l
219: Lists known
220: .Em sysid
221: values and exit.
1.35 dsl 222: .It Fl r Ar file
223: Read the boot record from file
224: .Ar file
225: instead of the specified disk.
226: The geometry information used is still that of the disk volume.
227: Any changes are written back to the file.
1.38 wiz 228: .It Fl s Ar id/start/size Ns Bq Ar /bootmenu
1.24 lukem 229: Specify the partition
230: .Ar id ,
1.35 dsl 231: .Ar start ,
1.38 wiz 232: .Ar size ,
1.35 dsl 233: and optionally
234: .Ar bootmenu .
1.24 lukem 235: This flag requires the use of a partition selection flag
236: .Po
237: .Fl 0 ,
238: .Fl 1 ,
239: .Fl 2 ,
1.35 dsl 240: .Fl 3 ,
1.24 lukem 241: or
1.35 dsl 242: .Fl E Ar number
1.24 lukem 243: .Pc
244: .It Fl S
1.26 wiz 245: When used with no other flags print a series of
1.24 lukem 246: .Pa /bin/sh
247: commands for setting variables to the partition information.
1.35 dsl 248: This could be used by installation scripts.
1.44 dyoung 249: .It Fl t Ar disktab
1.45 snj 250: Read
1.44 dyoung 251: .Ar disktype
1.45 snj 252: from the named
253: .Xr disktab 5
1.44 dyoung 254: file instead of from
1.45 snj 255: .Pa /etc/disktab .
1.44 dyoung 256: .It Fl T Ar disktype
1.45 snj 257: Use the disklabel
1.44 dyoung 258: .Ar disktype
259: instead of the disklabel on
260: .Ar device .
1.24 lukem 261: .It Fl u
1.35 dsl 262: Display the partitions and interactively ask which one you want to edit.
1.24 lukem 263: .Nm
1.35 dsl 264: will step through each field showing the old value and asking for a new one.
265: The
266: .Em start
1.36 wiz 267: and
1.35 dsl 268: .Em size
269: can be specified in blocks (nn), cylinders (nnc) or megabytes (nnm), values
270: in megabytes will be rounded to the nearest cylinder boundary.
271: The
272: .Em size
273: may be specified as
274: .Em $
275: in which case the partition will extend to the end of the available free space.
1.47 lukem 276: .Pp
1.35 dsl 277: .Nm
278: will not allow you to create partitions which overlap.
279: .Pp
280: If
281: .Em bootmenu
282: is specified for any partition
283: .Nm
284: will determine whether the installed boot code supports the bootselect code,
285: if it doesn't you will be asked whether you want to install the required
286: boot code.
287: .It Fl v
288: Be more verbose, specifying
289: .Fl v
290: more than once may increase the amount of output.
1.47 lukem 291: .Pp
292: Using
1.35 dsl 293: .Fl v
294: with
295: .Fl u
1.47 lukem 296: allows the user to change more parameters than normally permitted.
1.35 dsl 297: .It Fl w Ar file
298: Write the modified partition table to file
299: .Ar file
300: instead of the disk.
301: .El
302: .Pp
303: When called with no arguments, it prints the partition table.
304: An example follows:
305: .Bd -literal
306: Disk: /dev/rwd0d
307: NetBSD disklabel disk geometry:
308: cylinders: 16383, heads: 16, sectors/track: 63 (1008 sectors/cylinder)
309: total sectors: 40032696
310:
311: BIOS disk geometry:
312: cylinders: 1023, heads: 255, sectors/track: 63 (16065 sectors/cylinder)
313: total sectors: 40032696
314:
315: Partition table:
316: 0: NetBSD (sysid 169)
317: bootmenu: net 1.5.
318: start 4209030, size 8289540 (4048 MB, Cyls 262-778), Active
319: 1: Primary DOS with 32 bit FAT (sysid 11)
320: bootmenu: win98
321: start 63, size 4208967 (2055 MB, Cyls 0-262)
322: 2: NetBSD (sysid 169)
323: bootmenu: current
324: start 32515560, size 7517136 (3670 MB, Cyls 2024-2491/234/40)
325: 3: Ext. partition - LBA (sysid 15)
326: start 12498570, size 20016990 (9774 MB, Cyls 778-2024)
327: Extended partition table:
328: E0: NetBSD (sysid 169)
329: bootmenu: test
330: start 12498633, size 12305727 (6009 MB, Cyls 778-1544)
331: E1: Primary DOS with 32 bit FAT (sysid 11)
332: start 24804423, size 4096512 (2000 MB, Cyls 1544-1799)
333: E2: Primary DOS with 32 bit FAT (sysid 11)
334: start 28900998, size 3614562 (1765 MB, Cyls 1799-2024)
335: Bootselector enabled, infinite timeout.
336: .Ed
337: .Pp
338: This example disk is divided into four partitions the last of which is
339: an extended partition.
340: The sub-partitions of the extended partition are also shown.
341: In this case there is no free space in either the disk or in the extended
342: partition.
343: .Pp
344: The various fields in each partition entry are:
345: .br
346: .in +4
347: .Em ptn_number : id_name
348: (sysid
349: .Em id_number )
350: .br
351: .in +4
352: bootmenu:
353: .Em bootmenu
354: .br
355: start
356: .Em start ,
357: size
1.39 wiz 358: .Em size ( MB
1.35 dsl 359: MB, Cyls
1.39 wiz 360: .Em first Ns No - Ns Em next )
1.35 dsl 361: .Op , Active
362: .in -4
363: .in -4
364: .Bl -tag -width "bootmenu"
365: .It Em ptn_number
366: is the number of the partition.
367: .It Em id_name
368: is the name of the filesystem type or operating system that uses this partition.
369: .It Em id_number
370: is the number that identifies the partition type.
371: 169 decimal is used for
372: .Nx
373: partitions,
374: 15 decimal to create an extended partition
375: and 0 to mark a partition as unused.
376: Use
1.24 lukem 377: .Nm
1.35 dsl 378: .Fl l
379: to list the known partition types.
380: .It Em bootmenu
381: is the menu prompt output by the interactive boot code for this partition.
382: This line is omitted if the prompt is not defined.
383: .It Xo
384: .Em start ,
385: .Em size
386: .Xc
387: are the start address and size of the partition in sectors.
388: .It Em MB
389: is the size of the partition in megabytes.
390: .It Xo
391: .Em first ,
392: .Em next
393: .Xc
394: are the bounds of this partition displayed as cylinder/head/sector.
395: If the partition starts (or ends) on a cylinder boundary the head and
396: sector values are omitted.
1.36 wiz 397: If
1.35 dsl 398: .Fl v
399: is not specified the start of extended partitions and the first partition
400: on the disk are rounded down to include the mandatory red tape in the
1.45 snj 401: preceding track.
1.35 dsl 402: .It Active
403: is output if this is the active partition.
404: .El
405: .Pp
406: If the
407: .Fl v
408: flag is given two additional lines are output for each partition:
409: .in +4
410: beg: cylinder
411: .Em cylinder ,
412: head
413: .Em head ,
414: sector
415: .Em sector
416: .br
417: end: cylinder
418: .Em cylinder ,
419: head
420: .Em head ,
421: sector
422: .Em sector
423: .in -4
424: .Bl -tag -width "bootmenu"
425: .It Xo
426: .Em "cylinder" ,
427: .Em "head" ,
428: .Em "sector"
429: .Xc
430: are the beginning or ending address of a partition.
1.47 lukem 431: .Pp
1.35 dsl 432: .Em "Note:"
433: these numbers are read from the bootblock, so are the values calculated
434: by a previous run of
435: .Nm .
1.24 lukem 436: .El
1.1 cgd 437: .Sh NOTES
1.48 darcy 438: This program is only available (and useful) on systems with PC-platform-style
1.49 ! wiz 439: MBR partitioning.
! 440: On
1.48 darcy 441: .Nm
1.49 ! wiz 442: this includes the following ports: amd64, arc, bebox, cobalt, hpcarm,
! 443: hpcmips, hpcsh, i386, macppc, mvmeppc, netwinder, ofppc, playstation2,
! 444: and prep.
1.48 darcy 445: .Pp
1.35 dsl 446: Traditionally the partition boundaries should be on cylinder boundaries
447: using the BIOS geometry, all of the first track should be reserved
448: for use by the BIOS.
449: Although the BIOS geometry is typically different from the geometry
450: reported by the drive, neither will match the actual physical geometry
451: for modern disks (the actual geometry will vary across the disk).
452: Keeping the partition boundaries on cylinder boundaries makes partitioning
453: a driver easier as only relatively small numbers need be entered.
454: .Pp
1.12 ross 455: The automatic calculation of the starting cylinder and
456: other parameters uses
1.1 cgd 457: a set of figures that represent what the BIOS thinks is the
458: geometry of the drive.
1.35 dsl 459: The default values should be correct for the system on which
460: .Nm
461: is run, however if you move the disk to a different system the
462: BIOS of that system might use a different geometry translation.
463: .Pp
464: If you run the equivalent of
1.6 mycroft 465: .Nm
1.35 dsl 466: on a different operating system then the
1.40 dsl 467: .Ar bootmenu
1.35 dsl 468: strings associated with extended partitions may be lost.
1.1 cgd 469: .Pp
1.6 mycroft 470: Editing an existing partition is risky, and may cause you to
1.1 cgd 471: lose all the data in that partition.
472: .Pp
473: You should run this program interactively once or twice to see how it works.
474: This is completely safe as long as you answer the last question in the negative.
1.35 dsl 475: You can also specify
476: .Fl w Ar file
477: to write the output to a file and later specify
478: .Fl r Ar file
479: to read back the updated information.
480: This can be done without having write access to the disk volume.
1.16 ws 481: .Sh FILES
1.18 fvdl 482: .Bl -tag -width /usr/mdec/mbrxxxxxxxx -compact
1.16 ws 483: .It Pa /usr/mdec/mbr
484: Default location of i386 bootcode
1.18 fvdl 485: .It Pa /usr/mdec/mbr_bootsel
486: Default location of i386 bootselect code
1.35 dsl 487: .It Pa /usr/mdec/mbr_ext
488: Default location of i386 bootselect for extended partitions
1.16 ws 489: .El
1.1 cgd 490: .Sh SEE ALSO
1.45 snj 491: .Xr disktab 5 ,
1.23 abs 492: .Xr disklabel 8 ,
1.27 fair 493: .Xr mbr 8 ,
1.23 abs 494: .Xr mbrlabel 8
1.1 cgd 495: .Sh BUGS
1.45 snj 496: The word
497: .Sq partition
498: is used to mean both an MBR partition and a
1.35 dsl 499: .Nx
500: partition, sometimes in the same sentence.
501: .Pp
1.6 mycroft 502: There are subtleties that the program detects that are not explained in
503: this manual page.
CVSweb <webmaster@jp.NetBSD.org>