1.Dd April 4, 1993 2.Dt FDISK 8 3.\".Os BSD 4 4.Sh NAME 5.Nm fdisk 6.Nd DOS partition maintenance program 7.Sh SYNOPSIS 8.Nm 9.Op Fl i 10.Op Fl u 11.Op Fl a 12.Op Fl 0123 13.Op disk 14.Bl -tag -width time 15.It Fl u 16Is used for updating (editing) sector 0 of the disk. 17.It Fl i 18Initializes sector 0 of the disk. This implies 19.Fl u . 20.It Fl a 21Change the active partition only. 22.It Fl 0123 23Operate on a single fdisk entry only. 24.El 25.Pp 26The final disk name can be provided as a 27.Sq bare 28disk name only, e.g. 29.Ql sd0 , 30or as a fully qualified device node under 31.Pa /dev . 32If omitted, the disks 33.Ql wd0 , 34.Ql sd0 , 35and 36.Ql od0 37are being searched in that order, until one is 38being found responding. 39.Sh PROLOGUE 40In order for the BIOS to boot the kernel, 41certain conventions must be adhered to. 42Sector 0 of the disk must contain boot code, 43a partition table, 44and a magic number. 45BIOS partitions can be used to break the disk up into several pieces. 46The BIOS brings in sector 0 47(does it really use the code?) 48and verifies the magic number. 49It then searches the 4 BIOS partitions described by sector 0 50to determine which of them is 51.Em active. 52This boot then brings in the secondary boot block from the 53.Em active 54partition and runs it. 55Under DOS, 56you could have one or more partitions with one 57.Em active. 58The DOS 59.Nm 60program can be used to divide space on the disk into partitions and set one 61.Em active. 62.Sh DESCRIPTION 63The FreeBSD program 64.Nm 65serves a similar purpose to the DOS program. 66When called with no arguments, it prints the sector 0 partition table. 67An example follows: 68 69.Bd -literal 70 ******* Working on device /dev/rwd0 ******* 71 parameters extracted from in-core disklabel are: 72 cylinders=769 heads=15 sectors/track=33 (495 blks/cyl) 73 74 parameters to be used for BIOS calculations are: 75 cylinders=769 heads=15 sectors/track=33 (495 blks/cyl) 76 77 Warning: BIOS sector numbering starts with sector 1 78 Information from DOS bootblock is: 79 The data for partition 0 is: 80 sysid 165,(FreeBSD/NetBSD/386BSD) 81 start 495, size 380160 (185 Meg), flag 0 82 beg: cyl 1/ sector 1/ head 0; 83 end: cyl 768/ sector 33/ head 14 84 The data for partition 1 is: 85 sysid 164,(unknown) 86 start 378180, size 2475 (1 Meg), flag 0 87 beg: cyl 764/ sector 1/ head 0; 88 end: cyl 768/ sector 33/ head 14 89 The data for partition 2 is: 90 <UNUSED> 91 The data for partition 3 is: 92 sysid 99,(ISC UNIX, other System V/386, GNU HURD or Mach) 93 start 380656, size 224234 (109 Meg), flag 80 94 beg: cyl 769/ sector 2/ head 0; 95 end: cyl 197/ sector 33/ head 14 96.Ed 97.Pp 98The disk is divided into three partitions that happen to fill the disk. 99The second partition overlaps the end of the first. 100(Used for debugging purposes) 101.Bl -tag -width "cyl, sector and head" 102.It Em "sysid" 103is used to label the partition. FreeBSD reserves the 104magic number 165 decimal (A5 in hex). 105.It Em "start and size" 106fields provide the start address 107and size of a partition in sectors. 108.It Em "flag 80" 109specifies that this is the active partition. 110.It Em "cyl, sector and head" 111fields are used to specify the beginning address 112and end address for the partition. 113.It Em "Note:" 114these numbers are calculated using BIOS's understanding of the disk geometry 115and saved in the bootblock. 116.El 117.Pp 118The flags 119.Fl i 120or 121.Fl u 122are used to indicate that the partition data is to be updated. 123The 124.Nm 125program will enter a conversational mode. 126This mode is designed not to change any data unless you explicitly tell it to. 127.Nm 128selects defaults for its questions to guarantee the above behavior. 129.Pp 130It displays each partition 131and ask if you want to edit it. 132If you say yes, 133it will step through each field showing the old value 134and asking for a new one. 135When you are done with a partition, 136.Nm 137will display it and ask if it is correct. 138.Nm 139will then proceed to the next entry. 140.Pp 141Getting the 142.Em cyl, sector, 143and 144.Em head 145fields correct is tricky. 146So by default, 147they will be calculated for you; 148you can specify them if you choose. 149.Pp 150After all the partitions are processed, 151you are given the option to change the 152.Em active 153partition. 154Finally, 155when the all the data for the first sector has been accumulated, 156you are asked if you really want to rewrite sector 0. 157Only if you answer yes, 158will the data be written to disk. 159.Pp 160The difference between the 161.Fl u 162flag and 163.Fl i 164flag is that 165the 166.Fl u 167flag just edits the fields as they appear on the disk. 168While the 169.Fl i 170flag is used to "initialize" sector 0; 171it will setup the last BIOS partition to use the whole disk for FreeBSD; 172and make it active. 173.Sh NOTES 174.Pp 175The automatic calculation of starting cylinder etc. uses 176a set of figures that represent what the BIOS thinks is the 177geometry of the drive. 178These figures are by default taken from the incore disklabel, 179but the program initially gives you an opportunity to change them. 180This allows the user to create a bootblock that can work with drives 181that use geometry translation under the BIOS. 182.Pp 183If you hand craft your disk layout, 184please make sure that the FreeBSD partition starts on a cylinder boundary. 185A number of decisions made later may assume this. 186(This might not be necessary later.) 187.Pp 188Editing an existing partition will most likely cause you to 189lose all the data in that partition. 190.Pp 191You should run this program interactively once or twice to see how it works. 192This is completely safe as long as you answer the last question in the negative. 193There are subtleties 194that the program detects 195that are not fully explained in this manual page. 196.Sh SEE ALSO 197.Xr disklabel 8 198.Sh BUGS 199The entire program should be made more user-friendly. 200.Pp 201Throughout this man page, the term 202.Sq partition 203is used where it should actually be 204.Sq slice , 205in order to conform with the terms used elsewhere. 206