xref: /NextBSD/sbin/fdisk_pc98/fdisk.8 (revision eb1a5f8de9f7ea602c373a710f531abbf81141c4)
1.\" $FreeBSD$
2.\"
3.Dd April 30, 2007
4.Dt FDISK 8
5.Os
6.Sh NAME
7.Nm fdisk
8.Nd NEC PC-98x1 slice table maintenance utility
9.Sh SYNOPSIS
10.Nm
11.Op Fl BIaistuv
12.Op Fl 12345678
13.Op Ar disk
14.Nm
15.Fl f Ar configfile
16.Op Fl itv
17.Op Ar disk
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 slice table,
23and a magic number.
24BIOS slices can be used to break the disk up into several pieces.
25The BIOS brings in sector 0 and verifies the magic number.
26The sector
270 boot code then searches the slice table to determine which
28slice is marked
29.Dq active .
30This boot code then brings in the bootstrap from the
31active slice and, if marked bootable, runs it.
32Under
33.Tn DOS ,
34you can have one or more slices with one active.
35The
36.Tn DOS
37.Nm
38utility can be used to divide space on the disk into slices and set one
39active.
40.Sh DESCRIPTION
41The
42.Fx
43utility,
44.Nm ,
45serves a similar purpose to the
46.Tn DOS
47utility.
48The first form is used to
49display slice information or to interactively edit the slice
50table.
51The second is used to write a slice table using a
52.Ar configfile ,
53and is designed to be used by other scripts/programs.
54.Pp
55Options are:
56.Bl -tag -width indent
57.It Fl a
58Change the active slice only.
59Ignored if
60.Fl f
61is given.
62.It Fl B
63Reinitialize the boot code contained in sector 0 of the disk.
64Ignored if
65.Fl f
66is given.
67.It Fl f Ar configfile
68Set slice values using the file
69.Ar configfile .
70The
71.Ar configfile
72always modifies existing slices, unless
73.Fl i
74is also given, in which case all existing slices are deleted (marked
75as
76.Dq unused )
77before the
78.Ar configfile
79is read.
80The
81.Ar configfile
82can be
83.Sq Fl ,
84in which case standard input is read.
85See
86.Sx CONFIGURATION FILE ,
87below, for file syntax.
88.Pp
89.Em WARNING :
90when
91.Fl f
92is used, you are not asked if you really want to write the slices
93table (as you are in the interactive mode).
94Use with caution!
95.It Fl i
96Initialize sector 0 of the disk.
97This implies
98.Fl u ,
99unless
100.Fl f
101is given.
102.It Fl I
103Initialize sector 0 slice table
104for one
105.Fx
106slice covering the entire disk.
107Some space at the start of the disk will reserved for the IPL program
108and the pc98 slice table itself.
109.It Fl s
110Print summary information and exit.
111.It Fl t
112Test mode; do not write slice values.
113Generally used with the
114.Fl f
115option to see what would be written to the slice table.
116Implies
117.Fl v .
118.It Fl u
119Update (edit) the disk's sector 0 slice table.
120Ignored if
121.Fl f
122is given.
123.It Fl v
124Be verbose.
125Slices that are unused are suppressed unless this flag is specified.
126When
127.Fl f
128is used,
129.Nm
130prints out the slice table that is written to the disk.
131.It Fl 12345678
132Operate on a single slice table entry only.
133Ignored if
134.Fl f
135is given.
136.El
137.Pp
138The final disk name can be provided as a
139.Dq bare
140disk name only, e.g.\&
141.Pa da0 ,
142or as a full pathname.
143If omitted,
144.Nm
145tries to figure out the default disk device name from the
146mounted root device.
147.Pp
148When called with no arguments, it prints the sector 0 slice table.
149An example follows:
150.Bd -literal
151	******* Working on device /dev/da0 *******
152	parameters extracted from in-core disklabel are:
153	cylinders=33075 heads=8 sectors/track=32 (256 blks/cyl)
154
155	parameters to be used for BIOS calculations are:
156	cylinders=33075 heads=8 sectors/track=32 (256 blks/cyl)
157
158	Media sector size is 512
159	Warning: BIOS sector numbering starts with sector 1
160	Information from DOS bootblock is:
161	The data for partition 1 is:
162	sysmid 148,(FreeBSD/NetBSD/386BSD)
163	    start 256, size 2490112 (1215 Meg), sid 196
164		beg: cyl 1/ sector 0/ head 0;
165		end: cyl 9727/ sector 0/ head 0
166		system Name FreeBSD(98)
167	The data for partition 2 is:
168	sysmid 148,(FreeBSD/NetBSD/386BSD)
169	    start 2490368, size 5505024 (2688 Meg), sid 196
170		beg: cyl 9728/ sector 0/ head 0;
171		end: cyl 31231/ sector 0/ head 0
172		system Name FreeBSD(98)
173	The data for partition 3 is:
174	<UNUSED>
175	The data for partition 4 is:
176	<UNUSED>
177	The data for partition 5 is:
178	<UNUSED>
179	The data for partition 6 is:
180	<UNUSED>
181	The data for partition 7 is:
182	<UNUSED>
183	The data for partition 8 is:
184	<UNUSED>
185	The data for partition 9 is:
186	<UNUSED>
187	The data for partition 10 is:
188	<UNUSED>
189	The data for partition 11 is:
190	<UNUSED>
191	The data for partition 12 is:
192	<UNUSED>
193	The data for partition 13 is:
194	<UNUSED>
195	The data for partition 14 is:
196	<UNUSED>
197	The data for partition 15 is:
198	<UNUSED>
199	The data for partition 16 is:
200	<UNUSED>
201.Ed
202.Pp
203The disk is divided into three slices that happen to fill the disk.
204The second slice overlaps the end of the first.
205(Used for debugging purposes.)
206.Bl -tag -width ".Em cyl , sector No and Em head"
207.It Em sysmid
208is used to label the slice.
209.Fx
210reserves the
211magic number 148 decimal (94 in hex).
212.It Xo
213.Em start
214and
215.Em size
216.Xc
217fields provide the start address
218and size of a slice in sectors.
219.It Xo
220.Em cyl , sector
221and
222.Em head
223.Xc
224fields are used to specify the beginning and end addresses of the slice.
225.It Em "system Name"
226is the name of the slice.
227.El
228.Pp
229.Em Note :
230these numbers are calculated using BIOS's understanding of the disk geometry
231and saved in the bootblock.
232.Pp
233The
234.Fl i
235and
236.Fl u
237flags are used to indicate that the slice data is to be updated.
238Unless the
239.Fl f
240option is also given,
241.Nm
242will enter a conversational mode.
243In this mode, no changes will be written to disk unless you explicitly tell
244.Nm
245to.
246.Pp
247The
248.Nm
249utility will display each slice and ask whether you want to edit it.
250If you say yes,
251.Nm
252will step through each field, show you the old value,
253and ask you for a new one.
254When you are done with the slice,
255.Nm
256will display it and ask you whether it is correct.
257It will then proceed to the next entry.
258.Pp
259Getting the
260.Em cyl , sector ,
261and
262.Em head
263fields correct is tricky, so by default,
264they will be calculated for you;
265you can specify them if you choose to though.
266.Pp
267After all the slices are processed,
268you are given the option to change the
269.Dq active
270slice.
271Finally, when all the new data for sector 0 has been accumulated,
272you are asked to confirm whether you really want to rewrite it.
273.Pp
274The difference between the
275.Fl u
276and
277.Fl i
278flags is that
279the
280.Fl u
281flag edits (updates) the existing slice parameters
282while the
283.Fl i
284flag is used to
285.Dq initialize
286them (old values will be ignored);
287it will setup the last BIOS slice to use the whole disk for
288.Fx ;
289and make it active.
290.Sh NOTES
291The automatic calculation of starting cylinder etc.\& uses
292a set of figures that represent what the BIOS thinks the
293geometry of the drive is.
294These figures are taken from the in-core disklabel by default,
295but
296.Nm
297initially gives you an opportunity to change them.
298This allows you to create a bootblock that can work with drives
299that use geometry translation under the BIOS.
300.Pp
301If you hand craft your disk layout,
302please make sure that the
303.Fx
304slice starts on a cylinder boundary.
305.Pp
306Editing an existing slice will most likely result in the loss of
307all data in that slice.
308.Pp
309You should run
310.Nm
311interactively once or twice to see how it works.
312This is completely safe as long as you answer the last question
313in the negative.
314There are subtleties that
315.Nm
316detects that are not fully explained in this manual page.
317.Sh CONFIGURATION FILE
318When the
319.Fl f
320option is given, a disk's slice table can be written using values
321from a
322.Ar configfile .
323The syntax of this file is very simple;
324each line is either a comment or a specification, as follows:
325.Bl -tag -width indent
326.It Ic # Ar comment ...
327Lines beginning with a
328.Ic #
329are comments and are ignored.
330.It Ic g Ar spec1 spec2 spec3
331Set the BIOS geometry used in slice calculations.
332There must be
333three values specified, with a letter preceding each number:
334.Bl -tag -width indent
335.It Cm c Ns Ar num
336Set the number of cylinders to
337.Ar num .
338.It Cm h Ns Ar num
339Set the number of heads to
340.Ar num .
341.It Cm s Ns Ar num
342Set the number of sectors/track to
343.Ar num .
344.El
345.Pp
346These specs can occur in any order, as the leading letter determines
347which value is which; however, all three must be specified.
348.Pp
349This line must occur before any lines that specify slice
350information.
351.Pp
352It is an error if the following is not true:
353.Bd -literal -offset indent
3541 <= number of cylinders
3551 <= number of heads <= 256
3561 <= number of sectors/track < 64
357.Ed
358.Pp
359The number of cylinders should be less than or equal to 1024, but this
360is not enforced, although a warning will be printed.
361Note that bootable
362.Fx
363slices (the
364.Dq Pa /
365file system) must lie completely within the
366first 1024 cylinders; if this is not true, booting may fail.
367Non-bootable slices do not have this restriction.
368.Pp
369Example (all of these are equivalent), for a disk with 1019 cylinders,
37039 heads, and 63 sectors:
371.Bd -literal -offset indent
372g       c1019   h39     s63
373g       h39     c1019   s63
374g       s63     h39     c1019
375.Ed
376.It Ic p Ar slice type start length
377Set the slice given by
378.Ar slice
379(1-8) to type
380.Ar type ,
381starting at sector
382.Ar start
383for
384.Ar length
385sectors.
386.Pp
387Only those slices explicitly mentioned by these lines are modified;
388any slice not referenced by a
389.Ic p
390line will not be modified.
391However, if an invalid slice table is present, or the
392.Fl i
393option is specified, all existing slice entries will be cleared
394(marked as unused), and these
395.Ic p
396lines will have to be used to
397explicitly set slice information.
398If multiple slices need to be
399set, multiple
400.Ic p
401lines must be specified; one for each slice.
402.Pp
403These slice lines must occur after any geometry specification lines,
404if one is present.
405.Pp
406The
407.Ar type
408is 165 for
409.Fx
410slices.
411Specifying a slice type of zero is
412the same as clearing the slice and marking it as unused; however,
413dummy values (such as
414.Dq 0 )
415must still be specified for
416.Ar start
417and
418.Ar length .
419.Pp
420Note: the start offset will be rounded upwards to a head boundary if
421necessary, and the end offset will be rounded downwards to a cylinder
422boundary if necessary.
423.Pp
424Example: to clear slice 4 and mark it as unused:
425.Pp
426.Dl "p       4       0       0       0"
427.Pp
428Example: to set slice 1 to a
429.Fx
430slice, starting at sector 1
431for 2503871 sectors (note: these numbers will be rounded upwards and
432downwards to correspond to head and cylinder boundaries):
433.Pp
434.Dl "p       1       165     1       2503871"
435.It Ic a Ar slice
436Make
437.Ar slice
438the active slice.
439Can occur anywhere in the config file, but only
440one must be present.
441.Pp
442Example: to make slice 1 the active slice:
443.Pp
444.Dl "a       1"
445.El
446.Sh SEE ALSO
447.Xr boot98cfg 8 ,
448.Xr bsdlabel 8 ,
449.Xr gpart 8 ,
450.Xr newfs 8
451.Sh BUGS
452The default boot code will not necessarily handle all slice types
453correctly, in particular those introduced since
454.Tn MS-DOS
4556.x.
456.Pp
457The entire utility should be made more user-friendly.
458.Pp
459Most users new to
460.Fx
461do not understand the difference between
462.Dq slice
463and
464.Dq partition ,
465causing difficulty to adjust.
466.Pp
467You cannot use this command to completely dedicate a disk to
468.Fx .
469The
470.Xr bsdlabel 8
471command must be used for this.
472