]>
Commit | Line | Data |
---|---|---|
6dbe3af9 | 1 | .\" Copyright 1992, 1993 Rickard E. Faith (faith@cs.unc.edu) |
2b6fc908 | 2 | .\" Copyright 1998 Andries E. Brouwer (aeb@cwi.nl) |
6dbe3af9 | 3 | .\" May be distributed under the GNU General Public License |
2b6fc908 | 4 | .TH FDISK 8 "11 June 1998" "Linux 2.0" "Linux Programmer's Manual" |
6dbe3af9 KZ |
5 | .SH NAME |
6 | fdisk \- Partition table manipulator for Linux | |
7 | .SH SYNOPSIS | |
5c36a0eb | 8 | .BI "fdisk [\-u] [" device ] |
2b6fc908 | 9 | .sp |
5c36a0eb | 10 | .BI "fdisk \-l [\-u] [" "device ..." ] |
2b6fc908 KZ |
11 | .sp |
12 | .BI "fdisk \-s " "partition ..." | |
13 | .sp | |
14 | .BI "fdisk \-v | |
6dbe3af9 | 15 | .SH DESCRIPTION |
2b6fc908 KZ |
16 | Hard disks can be divided into one or more logical disks called |
17 | .IR partitions . | |
18 | This division is described in the | |
19 | .I "partition table" | |
20 | found in sector 0 of the disk. | |
21 | ||
22 | In the BSD world one talks about `disk slices' and a `disklabel'. | |
23 | ||
24 | Linux needs at least one partition, namely for its root file system. | |
25 | It can use swap files and/or swap partitions, but the latter are more | |
26 | efficient. So, usually one will want a second Linux partition | |
27 | dedicated as swap partition. | |
28 | On Intel compatible hardware, the BIOS that boots the system | |
29 | can often only access the first 1024 cylinders of the disk. | |
30 | For this reason people with large disks often create a third partition, | |
31 | just a few MB large, typically mounted on | |
32 | .IR /boot , | |
33 | to store the kernel image and a few auxiliary files needed at boot time, | |
34 | so as to make sure that this stuff is accessible to the BIOS. | |
35 | There may be reasons of security, ease of administration and backup, | |
36 | or testing, to use more than the minimum number of partitions. | |
37 | ||
6dbe3af9 | 38 | .B fdisk |
2b6fc908 KZ |
39 | (in the first form of invocation) |
40 | is a menu driven program for creation and manipulation of | |
41 | partition tables. | |
42 | It understands DOS type partition tables and BSD or SUN type disklabels. | |
43 | ||
6dbe3af9 KZ |
44 | The |
45 | .I device | |
46 | is usually one of the following: | |
2b6fc908 | 47 | .br |
6dbe3af9 KZ |
48 | .nf |
49 | .RS | |
50 | /dev/hda | |
51 | /dev/hdb | |
52 | /dev/sda | |
53 | /dev/sdb | |
54 | .RE | |
55 | .fi | |
2b6fc908 KZ |
56 | (/dev/hd[a-h] for IDE disks, /dev/sd[a-p] for SCSI disks, |
57 | /dev/ed[a-d] for ESDI disks, /dev/xd[ab] for XT disks). | |
58 | A device name refers to the entire disk. | |
59 | ||
6dbe3af9 KZ |
60 | The |
61 | .I partition | |
62 | is a | |
63 | .I device | |
64 | name followed by a partition number. For example, | |
65 | .B /dev/hda1 | |
2b6fc908 KZ |
66 | is the first partition on the first IDE hard disk in the system. |
67 | IDE disks can have up to 63 partitions, SCSI disks up to 15. | |
68 | See also | |
69 | .IR /usr/src/linux/Documentation/devices.txt . | |
70 | ||
71 | A BSD/SUN type disklabel can describe 8 partitions, | |
72 | the third of which should be a `whole disk' partition. | |
73 | Do not start a partition that actually uses its first sector | |
74 | (like a swap partition) at cylinder 0, since that will | |
75 | destroy the disklabel. | |
76 | ||
5c36a0eb KZ |
77 | An IRIX/SGI type disklabel can describe 16 partitions, |
78 | the eleventh of which should be an entire `volume' partition, | |
79 | while the ninth should be labeled `volume header'. | |
80 | The volume header will also cover the partition table, i.e., | |
81 | it starts at block zero and extends by default over five cylinders. | |
82 | The remaining space in the volume header may be used by header | |
83 | directory entries. No partitions may overlap with the volume header. | |
84 | Also do not change its type and make some file system on it, since | |
85 | you will lose the partition table. Use this type of label only when | |
86 | working with Linux on IRIX/SGI machines or IRIX/SGI disks under Linux. | |
87 | ||
2b6fc908 KZ |
88 | A DOS type partition table can describe an unlimited number |
89 | of partitions. In sector 0 there is room for the description | |
90 | of 4 partitions (called `primary'). One of these may be an | |
91 | extended partition; this is a box holding logical partitions, | |
92 | with descriptors found in a linked list of sectors, each | |
93 | preceding the corresponding logical partitions. | |
94 | The four primary partitions, present or not, get numbers 1-4. | |
95 | Logical partitions start numbering from 5. | |
96 | ||
97 | In a DOS type partition table the starting offset and the size | |
98 | of each partition is stored in two ways: as an absolute number | |
99 | of sectors (given in 32 bits) and as a Cylinders/Heads/Sectors | |
100 | triple (given in 10+8+6 bits). The former is OK - with 512-byte | |
101 | sectors this will work up to 2 TB. The latter has two different | |
102 | problems. First of all, these C/H/S fields can be filled only | |
103 | when the number of heads and the number of sectors per track | |
104 | are known. Secondly, even if we know what these numbers should be, | |
105 | the 24 bits that are available do not suffice. | |
106 | DOS uses C/H/S only, Windows uses both, Linux never uses C/H/S. | |
6dbe3af9 KZ |
107 | |
108 | If possible, | |
109 | .B fdisk | |
2b6fc908 KZ |
110 | will obtain the disk geometry automatically. This is not |
111 | necessarily the physical disk geometry (indeed, modern disks do not | |
112 | really have anything like a physical geometry, certainly not something | |
113 | that can be described in simplistic Cylinders/Heads/Sectors form), | |
114 | but is the disk geometry that MS-DOS uses for the partition table. | |
115 | ||
116 | Usually all goes well by default, and there are no problems if | |
117 | Linux is the only system on the disk. However, if the disk has | |
118 | to be shared with other operating systems, it is often a good idea | |
119 | to let an fdisk from another operating system make at least one | |
120 | partition. When Linux boots it looks at the partition table, and | |
121 | tries to deduce what (fake) geometry is required for good | |
122 | cooperation with other systems. | |
6dbe3af9 KZ |
123 | |
124 | Whenever a partition table is printed out, a consistency check is performed | |
125 | on the partition table entries. This check verifies that the physical and | |
126 | logical start and end points are identical, and that the partition starts | |
127 | and ends on a cylinder boundary (except for the first partition). | |
128 | ||
6dbe3af9 KZ |
129 | Some versions of MS-DOS create a first partition which does not begin |
130 | on a cylinder boundary, but on sector 2 of the first cylinder. | |
131 | Partitions beginning in cylinder 1 cannot begin on a cylinder boundary, but | |
132 | this is unlikely to cause difficulty unless you have OS/2 on your machine. | |
133 | ||
2b6fc908 KZ |
134 | A sync() and a BLKRRPART ioctl() (reread partition table from disk) |
135 | are performed before exiting when the partition table has been updated. | |
136 | Long ago it used to be necessary to reboot after the use of fdisk. | |
137 | I do not think this is the case anymore - indeed, rebooting too quickly | |
138 | might cause loss of not-yet-written data. Note that both the kernel | |
139 | and the disk hardware may buffer data. | |
6dbe3af9 KZ |
140 | |
141 | .SH "DOS 6.x WARNING" | |
142 | ||
143 | The DOS 6.x FORMAT command looks for some information in the first | |
144 | sector of the data area of the partition, and treats this information | |
145 | as more reliable than the information in the partition table. DOS | |
146 | FORMAT expects DOS FDISK to clear the first 512 bytes of the data area | |
147 | of a partition whenever a size change occurs. DOS FORMAT will look at | |
148 | this extra information even if the /U flag is given -- we consider | |
149 | this a bug in DOS FORMAT and DOS FDISK. | |
150 | ||
151 | The bottom line is that if you use cfdisk or fdisk to change the size of a | |
152 | DOS partition table entry, then you must also use | |
153 | .B dd | |
154 | to zero the first 512 bytes of that partition before using DOS FORMAT to | |
155 | format the partition. For example, if you were using cfdisk to make a DOS | |
156 | partition table entry for /dev/hda1, then (after exiting fdisk or cfdisk | |
157 | and rebooting Linux so that the partition table information is valid) you | |
158 | would use the command "dd if=/dev/zero of=/dev/hda1 bs=512 count=1" to zero | |
159 | the first 512 bytes of the partition. | |
6dbe3af9 KZ |
160 | |
161 | .B BE EXTREMELY CAREFUL | |
162 | if you use the | |
163 | .B dd | |
164 | command, since a small typo can make all of the data on your disk useless. | |
165 | ||
fd6b7a7f | 166 | For best results, you should always use an OS-specific partition table |
6dbe3af9 KZ |
167 | program. For example, you should make DOS partitions with the DOS FDISK |
168 | program and Linux partitions with the Linux fdisk or Linux cfdisk program. | |
169 | ||
170 | .SH OPTIONS | |
171 | .TP | |
172 | .B \-v | |
2b6fc908 | 173 | Print version number of |
6dbe3af9 | 174 | .B fdisk |
2b6fc908 | 175 | program and exit. |
6dbe3af9 KZ |
176 | .TP |
177 | .B \-l | |
2b6fc908 KZ |
178 | List the partition tables for |
179 | .BR /dev/hd[a-d] , | |
180 | .BR /dev/sd[a-h] , | |
181 | .BR /dev/ed[a-d] , | |
182 | and then exit. | |
6dbe3af9 | 183 | .TP |
2b6fc908 KZ |
184 | .B \-u |
185 | When listing partition tables, give sizes in sectors instead | |
186 | of cylinders. | |
187 | .TP | |
188 | .BI "\-s " partition | |
189 | The | |
6dbe3af9 | 190 | .I size |
2b6fc908 KZ |
191 | of the partition (in blocks) is printed on the standard output. |
192 | This value is normally used as an argument to the | |
6dbe3af9 KZ |
193 | .BR mkfs (8) |
194 | program to specify the size of the partition which will be formatted. | |
2b6fc908 KZ |
195 | (Older versions of fdisk would do this only if the partition id is |
196 | greater than 10, in an attempt to refuse DOS partitions; | |
197 | this test has been deleted.) | |
198 | Note that | |
199 | .B "sfdisk -s" | |
200 | gives different (namely, correct) answers. | |
201 | Reasons for the difference are that the kernel and | |
6dbe3af9 | 202 | .B fdisk |
2b6fc908 KZ |
203 | need not have the same idea about partition numbering |
204 | (e.g., in case you have BSD slices), and have different | |
205 | ideas about the size of an extended partition. | |
206 | .SH BUGS | |
207 | There are several *fdisk programs around. | |
208 | Each has its problems and strengths. | |
209 | Try them in the order | |
210 | .BR cfdisk , | |
211 | .BR fdisk , | |
212 | .BR sfdisk . | |
5c36a0eb KZ |
213 | .PP |
214 | The IRIX/SGI type disklabel is currently not supported by the kernel. | |
215 | Moreover, IRIX/SGI header directories are not fully supported yet. | |
216 | .PP | |
217 | The option `dump partition table to file' is missing. | |
2b6fc908 KZ |
218 | .\" .SH AUTHORS |
219 | .\" A. V. Le Blanc (LeBlanc@mcc.ac.uk) | |
220 | .\" Bernhard Fastenrath (fasten@informatik.uni-bonn.de) | |
221 | .\" Jakub Jelinek (jj@sunsite.mff.cuni.cz) | |
5c36a0eb | 222 | .\" Andreas Neuper (ANeuper@GUUG.de) |
2b6fc908 | 223 | .\" and many others. |