fdisk.8 revision 4
1205821Sedwin.Dd April 4, 1993
217849Swosch.Dt FDISK 8
3181322Sedwin.\".Os BSD 4
413840Swosch.Sh NAME
517849Swosch.Nm fdisk
617849Swosch.Nd DOS partition maintainance program
717849Swosch.Sh SYNOPSIS
817849Swosch.Nm
917849Swosch.Op Fl i
1017849Swosch.Op Fl u
1117849Swosch.Bl -tag -width time
1217849Swosch.It Fl i
1317849SwoschInitializes sector 0 of the disk.
1417849Swosch.It Fl u
1517849SwoschIs used for updating (editing) sector 0 of the disk.
1617849Swosch.El
1717849Swosch.Sh PROLOGUE
1817849SwoschIn order for the BIOS to boot the kernel,
1917849Swoschcertain conventions must be adhered to.
2017849SwoschSector 0 of the disk must contain boot code,
2117849Swoscha partition table,
2217849Swoschand a magic number.
2317849SwoschBIOS partitions can be used to break the disk up into several pieces.
2417849SwoschThe BIOS brings in sector 0
2517849Swosch(does it really use the code?)
2613840Swoschand verifies the magic number.
2787235SmarkmIt then searches the 4 BIOS partitions described by sector 0
2887235Smarkmto determine which of them is
2987235Smarkm.Em active.
3015737SacheThis boot then brings in the secondary boot block from the
3115737Sache.Em active
3213840Swoschpartition and runs it.
3313840SwoschUnder DOS,
3415720Sacheyou could have one or more partitions with one
3515720Sache.Em active.
3613840SwoschThe DOS
3713840Swosch.Nm
3870598Sdwmaloneprogram can be used to divide space on the disk into partitions and set one
3970598Sdwmalone.Em active.
4070598Sdwmalone.Sh DESCRIPTION
4170598SdwmaloneThe 386bsd program
4270598Sdwmalone.Nm
4370598Sdwmaloneserves a similar purpose to the DOS program.
4470598SdwmaloneWhen called with no arguments, it prints the sector 0 partition table.
45169343SdwmaloneAn example follows:
46169343Sdwmalone
4713840Swosch.Bd -literal
48181322Sedwin	******* Working on device /dev/rwd0d *******
49181322Sedwin	parameters extracted from in-core disklabel are:
50181322Sedwin	cylinders=769 heads=15 sectors/track=33 (495 blks/cyl)
51181322Sedwin
52181322Sedwin	parameters to be used for BIOS calculations are:
53181322Sedwin	cylinders=769 heads=15 sectors/track=33 (495 blks/cyl)
5413840Swosch		
55181322Sedwin	Warning: BIOS sector numbering starts with sector 1
56181322Sedwin	Information from DOS bootblock is:
57181322Sedwin	The data for partition 0 is:
58181322Sedwin	sysid 165,(386BSD)
59181322Sedwin    	    start 495, size 380160 (185 Meg), flag 0
6013840Swosch		beg: cyl 1/ sector 1/ head 0;
61181322Sedwin		end: cyl 768/ sector 33/ head 14
6213840Swosch	The data for partition 1 is:
63205821Sedwin	sysid 164,(unknown)
64181322Sedwin    	    start 378180, size 2475 (1 Meg), flag 0
65181322Sedwin		beg: cyl 764/ sector 1/ head 0;
66181322Sedwin		end: cyl 768/ sector 33/ head 14
6713840Swosch	The data for partition 2 is:
68	<UNUSED>
69	The data for partition 3 is:
70	sysid 99,(ISC UNIX, other System V/386, GNU HURD or Mach)
71    	    start 380656, size 224234 (109 Meg), flag 80
72		beg: cyl 769/ sector 2/ head 0;
73		end: cyl 197/ sector 33/ head 14
74.Ed
75.Pp
76The disk is divided into three parititions that happen to fill the disk.
77The second partition overlaps the end of the first.
78(Used for debugging purposes)
79.Bl -tag -width "cyl, sector and head"
80.It Em "sysid"
81is used to label the partition.  386bsd reserves the
82magic number 165 decimal (A5 in hex).
83.It Em "start and size"
84fields provide the start address
85and size of a parition in sectors.
86.It Em "flag 80"
87specifies that this is the active partition.
88.It Em "cyl, sector and head"
89fields are used to specify the beginning address
90and end address for the parititon.
91.It Em "Note:"
92these numbers are calculated using BIOS's understanding of the disk geometry
93and saved in the bootblock.
94.El
95.Pp
96The flags
97.Fl i
98or
99.Fl u
100are used to indicate that the paritition data is to be updated.
101The
102.Nm
103program will enter a conversational mode.
104This mode is designed not to change any data unless you explicitly tell it to.
105.Nm
106selects defaults for its questions to guarantee the above behaviour.
107.Pp
108It displays each partition
109and ask if you want to edit it.
110If you say yes,
111it will step through each field showing the old value
112and asking for a new one.
113When you are done with a partition,
114.Nm
115will display it and ask if it is correct.
116.Nm
117will then procede to the next entry.
118.Pp
119Getting the
120.Em cyl, sector,
121and
122.Em head
123fields correct is tricky.
124So by default,
125they will be calculated for you;
126you can specify them if you choose.
127.Pp
128After all the partitions are processed,
129you are given the option to change the
130.Em active
131partition.
132Finally,
133when the all the data for the first sector has been accumulated,
134you are asked if you really want to rewrite sector 0.
135Only if you answer yes,
136will the data be written to disk.
137.Pp
138The difference between the
139.Fl u
140flag and
141.Fl i
142flag is that
143the
144.Fl u
145flag just edits the fields as they appear on the disk.
146While the
147.Fl i
148flag is used to "initialize" sector 0;
149it will setup the last BIOS partition to use the whole disk for 386bsd;
150and make it active.
151.Sh NOTES
152.Pp
153The automatic calculation of starting cylinder etc. uses
154a set of figures that represent what the BIOS thinks is the
155geometry of the drive.
156These figures are by default taken from the incore disklabel,
157but the program initially gives you an oportunity to change them.
158This allows the user to create a bootblock that can work with drives
159that use geometry translation under the BIOS.
160.Pp
161If you hand craft your disk layout,
162please make sure that the 386bsd partition starts on a cylinder boundary.
163A number of decisions made later may assume this.
164(This might not be necessary later.)
165.Pp
166Editing an existing partition will most likely cause you to
167lose all the data in that partition.
168.Pp
169You should run this program interactively once or twice to see how it works.
170This is completely safe as long as you answer the last question in the negative.
171There are subtleties
172that the program detects
173that are not fully explained in this manual page.
174.Sh SEE ALSO
175.Xr disklabel 8
176.Sh BUGS
177One less now, but probably more
178