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