]>
Commit | Line | Data |
---|---|---|
5aac7429 KZ |
1 | .\" sfdisk.8 -- man page for sfdisk |
2 | .\" Copyright (C) 2014 Karel Zak <kzak@redhat.com> | |
fd6b7a7f | 3 | .\" |
5aac7429 KZ |
4 | .\" Permission is granted to make and distribute verbatim copies of this |
5 | .\" manual provided the copyright notice and this permission notice are | |
6 | .\" preserved on all copies. | |
7 | .\" | |
8 | .\" Permission is granted to copy and distribute modified versions of this | |
9 | .\" manual under the conditions for verbatim copying, provided that the | |
10 | .\" entire resulting derived work is distributed under the terms of a | |
11 | .\" permission notice identical to this one. | |
12 | .\" | |
689d83de | 13 | .TH SFDISK 8 "December 2014" "util-linux" "System Administration" |
fd6b7a7f | 14 | .SH NAME |
5aac7429 | 15 | sfdisk \- display or manipulate a disk partition table |
fd6b7a7f | 16 | .SH SYNOPSIS |
b61dfcf5 | 17 | .B sfdisk |
f49ccec2 BS |
18 | [options] |
19 | .I device | |
20 | .RB [ \-N | |
21 | .IR partition-number ] | |
5aac7429 KZ |
22 | .sp |
23 | .B sfdisk | |
f49ccec2 BS |
24 | [options] |
25 | .I command | |
fd6b7a7f KZ |
26 | .SH DESCRIPTION |
27 | .B sfdisk | |
689d83de | 28 | is a script-oriented tool for partitioning any block device. |
fd6b7a7f | 29 | |
d5206b96 | 30 | Since version 2.26 |
5dbff4c0 | 31 | .B sfdisk |
5aac7429 KZ |
32 | supports MBR (DOS), GPT, SUN and SGI disk labels, but no longer provides any |
33 | functionality for CHS (Cylinder-Head-Sector) addressing. CHS has | |
34 | never been important for Linux, and this addressing concept does not make any | |
35 | sense for new devices. | |
689d83de | 36 | .sp |
b69719b6 | 37 | .B sfdisk |
d5206b96 | 38 | (since version 2.26) aligns start and end of the partitions to |
689d83de BS |
39 | block-device I/O limits when relative sizes are specified, or when the |
40 | default values are used. | |
41 | .sp | |
a8a4887b | 42 | .B sfdisk |
689d83de BS |
43 | does not create the standard system partitions for SGI and SUN disk labels like |
44 | .BR fdisk (8) | |
45 | does. | |
a8a4887b KZ |
46 | It is necessary to explicitly create all partitions including whole-disk system |
47 | partitions. | |
48 | ||
5aac7429 KZ |
49 | .SH COMMANDS |
50 | The commands are mutually exclusive. | |
fd6b7a7f | 51 | .TP |
f49ccec2 | 52 | .RB [ \-N " \fIpartition-number\fR] " \fIdevice\fR |
689d83de | 53 | The default \fBsfdisk\fR command is to read the specification for the desired |
5aac7429 | 54 | partitioning of \fIdevice\fR from standard input, and then create a partition |
689d83de BS |
55 | table according to the specification. See below for the description of the |
56 | input format. If standard input is a terminal, then \fBsfdisk\fR starts an | |
57 | interactive session. | |
58 | .sp | |
59 | If the option \fB\-N\fR is specified, then the changes are applied to | |
60 | the partition addressed by \fIpartition-number\fR. | |
fd6b7a7f | 61 | .TP |
689d83de BS |
62 | .BR \-a , " \-\-activate \fIdevice\fR [" \fIpartition-number\fR...] |
63 | Switch on the bootable flag. If no \fIpartition-number\fR is specified, | |
64 | then all partitions with an enabled flag are listed. | |
9a79aa6e | 65 | .TP |
9a79aa6e KZ |
66 | .BR \-d , " \-\-dump " \fIdevice\fR |
67 | Dump the partitions of a device in a format that is usable as input to sfdisk. | |
689d83de | 68 | See the section \fBBACKING UP THE PARTITION TABLE\fR. |
9a79aa6e | 69 | .TP |
b06c1ca6 | 70 | .BR \-g , " \-\-show\-geometry " [ \fIdevice ...] |
689d83de | 71 | List the geometry of all or the specified devices. |
9a79aa6e | 72 | .TP |
689d83de BS |
73 | .BR \-l , " \-\-list " [ \fIdevice ...] |
74 | List the partitions of all or the specified devices. This command can be used | |
9a79aa6e KZ |
75 | together with \fB\-\-verify\fR. |
76 | .TP | |
b06c1ca6 | 77 | .BR \-\-part\-attrs " \fIdevice partno [" \fIattrs ] |
689d83de BS |
78 | Change the GPT partition attribute bits. If \fIattrs\fR is not specified, |
79 | then print the current partition settings. The \fIattrs\fR argument is a | |
80 | comma- or space-delimited list of bits. The currently supported attribute | |
81 | bits are: RequiredPartiton, NoBlockIOProtocol, LegacyBIOSBootable | |
82 | and GUID-specific bits in the range from 48 to 63. For example, the string | |
bc9e8547 KZ |
83 | "RequiredPartiton,50,51" sets three bits. |
84 | .TP | |
b06c1ca6 | 85 | .BR \-\-part\-label " \fIdevice partno [" \fIlabel ] |
80840c16 | 86 | Change the GPT partition name (label). If \fIlabel\fR is not specified, |
689d83de | 87 | then print the current partition label. |
e36fb07a | 88 | .TP |
b06c1ca6 | 89 | .BR \-\-part\-type " \fIdevice partno [" \fItype ] |
689d83de BS |
90 | Change the partition type. If \fItype\fR is not specified, then print the |
91 | current partition type. The \fItype\fR argument is hexadecimal for MBR, | |
92 | or a GUID for GPT. For backward compatibility the options \fB\-c\fR and | |
93 | \fB\-\-id\fR have the same meaning. | |
e36fb07a | 94 | .TP |
b06c1ca6 | 95 | .BR \-\-part\-uuid " \fIdevice partno [" \fIuuid ] |
689d83de BS |
96 | Change the GPT partition UUID. If \fIuuid\fR is not specified, |
97 | then print the current partition UUID. | |
e36fb07a | 98 | .TP |
b06c1ca6 | 99 | .BR \-s , " \-\-show\-size " [ \fIdevice ...] |
689d83de | 100 | List the sizes of all or the specified devices. |
9a79aa6e | 101 | .TP |
b06c1ca6 | 102 | .BR \-T , " \-\-list\-types" |
689d83de | 103 | Print all supported types for the current disk label or the label specified by |
9a79aa6e | 104 | \fB\-\-label\fR. |
3a5bdedf | 105 | .TP |
9a79aa6e | 106 | .BR \-V , " \-\-verify |
689d83de | 107 | Test whether the partition table and partitions seem correct. |
5aac7429 KZ |
108 | |
109 | .SH OPTIONS | |
fd6b7a7f | 110 | .TP |
5aac7429 | 111 | .BR \-A , " \-\-append" |
689d83de | 112 | Don't create a new partition table, but only append the specified partitions. |
fd6b7a7f | 113 | .TP |
5aac7429 | 114 | .BR \-b , " \-\-backup" |
689d83de BS |
115 | Back up the current partition table sectors before starting the partitioning. |
116 | The default backup file name is ~/sfdisk-<device>-<offset>.bak; to use another | |
b06c1ca6 | 117 | name see \fB\-\-backup\-file\fR. |
f74478a6 | 118 | .TP |
5aac7429 KZ |
119 | .BR \-f , " \-\-force" |
120 | Disable all consistency checking. | |
f74478a6 | 121 | .TP |
80840c16 BS |
122 | .BR \-\-Linux |
123 | Deprecated and ignored option. Partitioning that is compatible with | |
124 | Linux (and other modern OS) is the default. | |
125 | .TP | |
126 | .BR \-n , " \-\-no\-act" | |
127 | Do everything except writing to the device. | |
128 | .TP | |
129 | .B \-\-no\-reread | |
130 | Do not check through the re-read-partition-table ioctl whether the device is in use. | |
131 | .TP | |
132 | .BR \-O , " \-\-backup\-file " \fIpath\fR | |
133 | Override the default backup file name. Note that the device name and offset | |
134 | are always appended to the file name. | |
135 | .TP | |
689d83de | 136 | .BR \-o , " \-\-output " \fIlist |
01f9286c KZ |
137 | Specify which output columns to print. Use |
138 | .B \-\-help | |
139 | to get a list of all supported columns. | |
689d83de | 140 | .sp |
01f9286c KZ |
141 | The default list of columns may be extended if \fIlist\fP is |
142 | specified in the format \fI+list\fP (e.g. \fB-o +UUID\fP). | |
143 | .TP | |
5aac7429 KZ |
144 | .BR \-q , " \-\-quiet" |
145 | Suppress extra info messages. | |
f74478a6 | 146 | .TP |
689d83de BS |
147 | .BR \-u , " \-\-unit S" |
148 | Deprecated option. Only the sector unit is supported. | |
f74478a6 | 149 | .TP |
689d83de BS |
150 | .BR \-X , " \-\-label " \fItype |
151 | Specify the disk label type (e.g. \fBdos\fR, \fBgpt\fR, ...). If this option | |
152 | is not given, then \fBsfdisk\fR defaults to the existing label, but if there | |
153 | is no label on the device yet, then the type defaults to \fBdos\fR. | |
01f9286c | 154 | .TP |
b06c1ca6 | 155 | .BR \-Y , " \-\-label\-nested " \fItype |
689d83de BS |
156 | Force editing of a nested disk label. The primary disk label has to exist already. |
157 | This option allows to edit for example a hybrid/protective MBR on devices with GPT. | |
158 | .TP | |
159 | .BR \-v , " \-\-version" | |
160 | Display version information and exit. | |
e1422de3 | 161 | .TP |
5aac7429 KZ |
162 | .BR \-h , " \-\-help" |
163 | Display help text and exit. | |
fd6b7a7f | 164 | |
9a79aa6e KZ |
165 | .SH "INPUT FORMATS" |
166 | .B sfdisk | |
167 | supports two input formats and generic header lines. | |
168 | ||
169 | .B Header lines | |
170 | .RS | |
689d83de BS |
171 | The optional header lines specify generic information that apply to the partition |
172 | table. The header-line format is: | |
173 | .RS | |
174 | .sp | |
9a79aa6e | 175 | .B "<name>: <value>" |
689d83de BS |
176 | .sp |
177 | .RE | |
9a79aa6e KZ |
178 | The currently recognized headers are: |
179 | .RS | |
180 | .TP | |
181 | .B unit | |
689d83de | 182 | Specify the partitioning unit. The only supported unit is \fBsectors\fR. |
9a79aa6e KZ |
183 | .TP |
184 | .B label | |
689d83de | 185 | Specify the partition table type. For example \fBdos\fR or \fBgpt\fR. |
9a79aa6e KZ |
186 | .TP |
187 | .B label-id | |
689d83de BS |
188 | Specify the partition table identifier. It should be a hexadecimal number |
189 | (with a 0x prefix) for MBR and a UUID for GPT. | |
9a79aa6e KZ |
190 | .RE |
191 | .sp | |
689d83de | 192 | Note that it is only possible to use header lines before the first partition |
9a79aa6e KZ |
193 | is specified in the input. |
194 | .RE | |
195 | ||
689d83de BS |
196 | .B Unnamed-fields format |
197 | .RS | |
9a79aa6e | 198 | .RS |
689d83de BS |
199 | .sp |
200 | .I start size type bootable | |
201 | .sp | |
202 | .RE | |
9a79aa6e | 203 | where each line fills one partition descriptor. |
689d83de | 204 | .sp |
80840c16 | 205 | Fields are separated by whitespace, or by comma or semicolon possibly followed by |
9a79aa6e | 206 | whitespace; initial and trailing whitespace is ignored. Numbers can be octal, |
689d83de BS |
207 | decimal or hexadecimal; decimal is the default. When a field is absent or empty, |
208 | a default value is used. But when the \fB-N\fR option (change a single partition) | |
209 | is given, the default for each field is its previous value. | |
210 | .sp | |
9a79aa6e KZ |
211 | The default value of |
212 | .I start | |
689d83de | 213 | is the first non-assigned sector aligned according to device I/O limits. |
ce9f568c | 214 | The default start offset for the first partition is 1 MiB. The offset may |
80840c16 | 215 | be followed by the multiplicative suffixes (KiB, MiB, GiB, TiB, PiB, |
ce9f568c | 216 | EiB, ZiB and YiB) then the number is interpreted as offset in bytes. |
689d83de | 217 | .sp |
9a79aa6e KZ |
218 | The default value of |
219 | .I size | |
689d83de | 220 | is as much as possible (until the next partition or end-of-device). A '+' can be |
9a79aa6e KZ |
221 | used instead of a number for size, which also means as much as possible. The |
222 | size may be followed by the multiplicative suffixes (KiB, MiB, GiB, TiB, PiB, | |
223 | EiB, ZiB and YiB), then the number is interpreted as size of the partition in | |
224 | bytes and then the size is aligned according to the device I/O limits. | |
225 | The default is to interpret the number as number of sectors. | |
689d83de BS |
226 | .sp |
227 | The partition | |
9a79aa6e | 228 | .I type |
689d83de BS |
229 | is given in hex for MBR (DOS), without the 0x prefix, a GUID string for GPT, or |
230 | a shortcut: | |
9a79aa6e KZ |
231 | .RS |
232 | .TP | |
689d83de | 233 | .B L |
9a79aa6e KZ |
234 | Linux; means 83 for MBR and 0FC63DAF-8483-4772-8E79-3D69D8477DE4 for GPT. |
235 | .TP | |
689d83de | 236 | .B S |
9a79aa6e KZ |
237 | swap area; means 82 for MBR and 0657FD6D-A4AB-43C4-84E5-0933C84B4F4F for GPT |
238 | .TP | |
239 | .B E | |
240 | extended partition; means 5 for MBR | |
241 | .TP | |
242 | .B H | |
243 | home partition; means 933AC7E1-2EB4-4F13-B844-0E14E2AEF915 for GPT | |
244 | .TP | |
245 | .B X | |
246 | linux extended partition; means 85 for MBR. | |
247 | .RE | |
248 | ||
689d83de BS |
249 | .I bootable |
250 | is specified as [\fB*\fR|\fB-\fR], with as default not-bootable. (The value of | |
251 | this field is irrelevant for Linux - when Linux runs it has been booted already - | |
252 | but might play a role for certain boot loaders and for other operating systems.) | |
9a79aa6e KZ |
253 | .RE |
254 | ||
689d83de | 255 | .B Named-fields format |
9a79aa6e | 256 | .RS |
689d83de | 257 | This format is more readable, robust, extendible and allows to specify additional |
80840c16 | 258 | information (e.g. a UUID). It is recommended to use this format to keep your scripts |
9a79aa6e | 259 | more readable. |
689d83de BS |
260 | .RS |
261 | .sp | |
262 | .RI [ "device \fB:" ] " name" [\fB= value "], ..." | |
263 | .sp | |
264 | .RE | |
265 | The | |
9a79aa6e | 266 | .I device |
689d83de BS |
267 | field is optional. \fBsfdisk\fRextracts the partition number from the |
268 | device name. It allows to specify the partitions in random order. | |
97325257 | 269 | This functionality is mostly used by \fB\-\-dump\fR. |
689d83de | 270 | Don't use it if you are not sure. |
9a79aa6e KZ |
271 | |
272 | The | |
273 | .I value | |
689d83de BS |
274 | can be between quotation marks (e.g. name="This is partition name"). |
275 | The currently supported fields are: | |
9a79aa6e KZ |
276 | .RS |
277 | .TP | |
689d83de BS |
278 | .BI start= number |
279 | The first non-assigned sector aligned according to device I/O limits. The default | |
ce9f568c KZ |
280 | start offset for the first partition is 1 MiB. The offset may be followed by |
281 | the multiplicative suffixes (KiB, MiB, GiB, TiB, PiB, EiB, ZiB and YiB) then | |
282 | the number is interpreted as offset in bytes. | |
9a79aa6e | 283 | .TP |
689d83de BS |
284 | .BI size= number |
285 | Specify the partition size in sectors. The number may be followed by the multiplicative | |
9a79aa6e KZ |
286 | suffixes (KiB, MiB, GiB, TiB, PiB, EiB, ZiB and YiB), then it's interpreted as size |
287 | in bytes and the size is aligned according to device I/O limits. | |
288 | .TP | |
689d83de BS |
289 | .B bootable |
290 | Mark the partition as bootable. | |
9a79aa6e | 291 | .TP |
689d83de BS |
292 | .BI attrs= string |
293 | Partition attributes, usually GPT partition attribute bits. See | |
b06c1ca6 | 294 | \fB\-\-part\-attrs\fR for more details about the GPT-bits string format. |
9a79aa6e | 295 | .TP |
689d83de | 296 | .BI uuid= string |
9a79aa6e KZ |
297 | GPT partition UUID. |
298 | .TP | |
689d83de | 299 | .BI name= string |
9a79aa6e KZ |
300 | GPT partition name. |
301 | .TP | |
689d83de BS |
302 | .BI type= code |
303 | A hexadecimal number (without 0x) for an MBR partition, or a GUID for a GPT partition. | |
304 | For backward compatibility the \fBId=\fR field has the same meaning. | |
9a79aa6e KZ |
305 | .RE |
306 | .RE | |
307 | ||
689d83de BS |
308 | .SH "BACKING UP THE PARTITION TABLE" |
309 | It is recommended to save the layout of your devices. | |
9a79aa6e KZ |
310 | .B sfdisk |
311 | supports two ways. | |
689d83de BS |
312 | .sp |
313 | Use the \fB\-\-dump\fR option to save a description of the device layout | |
314 | to a text file. The dump format is suitable for later \fBsfdisk\fR input. | |
315 | For example: | |
9a79aa6e KZ |
316 | .RS |
317 | .sp | |
318 | .B "sfdisk --dump /dev/sda > sda.dump" | |
319 | .sp | |
320 | .RE | |
689d83de | 321 | This can later be restored by: |
9a79aa6e KZ |
322 | .RS |
323 | .sp | |
324 | .B "sfdisk /dev/sda < sda.dump" | |
325 | .RE | |
326 | ||
689d83de BS |
327 | If you want to do a full (binary) backup of all sectors where the |
328 | partition table is stored, | |
329 | then use the \fB\-\-backup\fR option. It writes the sectors to | |
330 | ~/sfdisk-<device>-<offset>.bak files. The default name of the backup file can | |
331 | be changed with the \fB\-\-backup\-file\fR option. The backup files | |
332 | contain only raw data from the \fIdevice\fR. | |
333 | Note that the same concept of backup files is used by | |
334 | .BR wipefs (8). | |
335 | For example: | |
9a79aa6e KZ |
336 | .RS |
337 | .sp | |
338 | .B "sfdisk --backup /dev/sda" | |
339 | .sp | |
340 | .RE | |
689d83de | 341 | The GPT header can later be restored by: |
9a79aa6e KZ |
342 | .RS |
343 | .sp | |
4bb82a45 | 344 | .B dd if=~/sfdisk-sda-0x00000200.bak of=/dev/sda seek=$((0x00000200)) bs=1 conv=notrunc |
9a79aa6e KZ |
345 | .sp |
346 | .RE | |
689d83de BS |
347 | Note that \fBsfdisk\fR since version 2.26 no longer provides the \fB\-I\fR option to |
348 | restore sectors. | |
9a79aa6e KZ |
349 | .B dd (1) |
350 | provides all necessary functionality. | |
351 | ||
352 | .SH NOTES | |
689d83de | 353 | Since version 2.26 \fBsfdisk\fR no longer provides the \fB\-R\fR or |
b06c1ca6 | 354 | \fB\-\-re\-read\fR option to force the kernel to reread the partition table. |
689d83de | 355 | Use \fBblockdev \-\-rereadpt\fR instead. |
9a79aa6e | 356 | .PP |
b06c1ca6 WP |
357 | Since version 2.26 \fBsfdisk\fR does not provide the \fB\-\-DOS\fR, \fB\-\-IBM\fR, \fB\-\-DOS\-extended\fR, |
358 | \fB\-\-unhide\fR, \fB\-\-show\-extended\fR, \fB\-\-cylinders\fR, \fB\-\-heads\fR, \fB\-\-sectors\fR, | |
359 | \fB\-\-inside\-outer\fR, \fB\-\-not\-inside\-outer\fR options. | |
9a79aa6e | 360 | |
68e422ec | 361 | .SH ENVIRONMENT |
47dd6918 KZ |
362 | .IP SFDISK_DEBUG=all |
363 | enables sfdisk debug output. | |
68e422ec KZ |
364 | .IP LIBFDISK_DEBUG=all |
365 | enables libfdisk debug output. | |
366 | .IP LIBBLKID_DEBUG=all | |
367 | enables libblkid debug output. | |
368 | .IP LIBSMARTCOLS_DEBUG=all | |
369 | enables libsmartcols debug output. | |
370 | ||
612721db | 371 | .SH "SEE ALSO" |
612721db | 372 | .BR fdisk (8), |
5aac7429 | 373 | .BR cfdisk (8), |
c64061c9 VD |
374 | .BR parted (8), |
375 | .BR partprobe (8), | |
5aac7429 | 376 | .BR partx(8) |
689d83de | 377 | |
5aac7429 KZ |
378 | .SH AUTHOR |
379 | Karel Zak <kzak@redhat.com> | |
380 | .PP | |
381 | The current sfdisk implementation is based on the original sfdisk | |
382 | from Andries E. Brouwer. | |
383 | ||
86d62711 | 384 | .SH AVAILABILITY |
601d12fb KZ |
385 | The sfdisk command is part of the util-linux package and is available from |
386 | ftp://ftp.kernel.org/pub/linux/utils/util-linux/. |