[BACK]Return to fdisk.8 CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / sbin / fdisk

Annotation of src/sbin/fdisk/fdisk.8, Revision 1.62

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

CVSweb <webmaster@jp.NetBSD.org>