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