1 .\" sfdisk.8 -- man page for sfdisk
2 .\" Copyright (C) 2014 Karel Zak <kzak@redhat.com>
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.
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.
13 .TH SFDISK 8 "December 2014" "util-linux" "System Administration"
15 sfdisk \- display or manipulate a disk partition table
21 .IR partition-number ]
28 is a script-oriented tool for partitioning any block device.
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.
38 (since version 2.26) aligns start and end of the partitions to
39 block-device I/O limits when relative sizes are specified, or when the
40 default values are used.
43 does not create the standard system partitions for SGI and SUN disk labels like
46 It is necessary to explicitly create all partitions including whole-disk system
50 The commands are mutually exclusive.
52 .RB [ \-N " \fIpartition-number\fR] " \fIdevice\fR
53 The default \fBsfdisk\fR command is to read the specification for the desired
54 partitioning of \fIdevice\fR from standard input, and then create a partition
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
59 If the option \fB\-N\fR is specified, then the changes are applied to
60 the partition addressed by \fIpartition-number\fR. The unspecified fields
61 of the partition are not modified.
63 Note that it's possible to address unused partition by \fB\-N\fR. For example
64 MBR always contains 4 partitions, but the number of the used partitions may be
65 smaller. In this case sfdisk follows the default values from the partition
66 table and it does not use built-in defaults for the unused partition specified
67 by \fB\-N\fR. See also \fB\---append\fR.
69 .BR \-A , " \-\-activate \fIdevice\fR [" \fIpartition-number\fR...]
70 Switch on the bootable flag. If no \fIpartition-number\fR is specified,
71 then all partitions with an enabled flag are listed.
73 .BR \-d , " \-\-dump " \fIdevice\fR
74 Dump the partitions of a device in a format that is usable as input to sfdisk.
75 See the section \fBBACKING UP THE PARTITION TABLE\fR.
77 .BR \-g , " \-\-show\-geometry " [ \fIdevice ...]
78 List the geometry of all or the specified devices.
80 .BR \-l , " \-\-list " [ \fIdevice ...]
81 List the partitions of all or the specified devices. This command can be used
82 together with \fB\-\-verify\fR.
84 .BR \-\-part\-attrs " \fIdevice partno [" \fIattrs ]
85 Change the GPT partition attribute bits. If \fIattrs\fR is not specified,
86 then print the current partition settings. The \fIattrs\fR argument is a
87 comma- or space-delimited list of bits. The currently supported attribute
88 bits are: RequiredPartiton, NoBlockIOProtocol, LegacyBIOSBootable
89 and GUID-specific bits in the range from 48 to 63. For example, the string
90 "RequiredPartiton,50,51" sets three bits.
92 .BR \-\-part\-label " \fIdevice partno [" \fIlabel ]
93 Change the GPT partition name (label). If \fIlabel\fR is not specified,
94 then print the current partition label.
96 .BR \-\-part\-type " \fIdevice partno [" \fItype ]
97 Change the partition type. If \fItype\fR is not specified, then print the
98 current partition type. The \fItype\fR argument is hexadecimal for MBR,
99 or a GUID for GPT. For backward compatibility the options \fB\-c\fR and
100 \fB\-\-id\fR have the same meaning.
102 .BR \-\-part\-uuid " \fIdevice partno [" \fIuuid ]
103 Change the GPT partition UUID. If \fIuuid\fR is not specified,
104 then print the current partition UUID.
106 .BR \-s , " \-\-show\-size " [ \fIdevice ...]
107 List the sizes of all or the specified devices.
109 .BR \-T , " \-\-list\-types"
110 Print all supported types for the current disk label or the label specified by
113 .BR \-V , " \-\-verify
114 Test whether the partition table and partitions seem correct.
118 .BR \-a , " \-\-append"
119 Don't create a new partition table, but only append the specified partitions.
121 .BR \-b , " \-\-backup"
122 Back up the current partition table sectors before starting the partitioning.
123 The default backup file name is ~/sfdisk-<device>-<offset>.bak; to use another
124 name see \fB\-\-backup\-file\fR.
126 .BR "\-\-color"[\fI=when\fR]
127 Colorize the output. The optional argument \fIwhen\fP
128 can be \fBauto\fR, \fBnever\fR or \fBalways\fR. If the \fIwhen\fR argument is omitted,
129 it defaults to \fBauto\fR. The colors can be disabled, for the current built-in default
130 see \fB\-\-help\fR output. See also the COLORS section.
132 .BR \-f , " \-\-force"
133 Disable all consistency checking.
136 Deprecated and ignored option. Partitioning that is compatible with
137 Linux (and other modern OS) is the default.
139 .BR \-n , " \-\-no\-act"
140 Do everything except writing to the device.
143 Do not check through the re-read-partition-table ioctl whether the device is in use.
145 .BR \-O , " \-\-backup\-file " \fIpath\fR
146 Override the default backup file name. Note that the device name and offset
147 are always appended to the file name.
149 .BR \-o , " \-\-output " \fIlist
150 Specify which output columns to print. Use
152 to get a list of all supported columns.
154 The default list of columns may be extended if \fIlist\fP is
155 specified in the format \fI+list\fP (e.g. \fB-o +UUID\fP).
157 .BR \-q , " \-\-quiet"
158 Suppress extra info messages.
160 .BR \-u , " \-\-unit S"
161 Deprecated option. Only the sector unit is supported.
163 .BR \-X , " \-\-label " \fItype
164 Specify the disk label type (e.g. \fBdos\fR, \fBgpt\fR, ...). If this option
165 is not given, then \fBsfdisk\fR defaults to the existing label, but if there
166 is no label on the device yet, then the type defaults to \fBdos\fR.
168 .BR \-Y , " \-\-label\-nested " \fItype
169 Force editing of a nested disk label. The primary disk label has to exist already.
170 This option allows to edit for example a hybrid/protective MBR on devices with GPT.
172 .BR \-v , " \-\-version"
173 Display version information and exit.
175 .BR \-h , " \-\-help"
176 Display help text and exit.
180 supports two input formats and generic header lines.
184 The optional header lines specify generic information that apply to the partition
185 table. The header-line format is:
191 The currently recognized headers are:
195 Specify the partitioning unit. The only supported unit is \fBsectors\fR.
198 Specify the partition table type. For example \fBdos\fR or \fBgpt\fR.
201 Specify the partition table identifier. It should be a hexadecimal number
202 (with a 0x prefix) for MBR and a UUID for GPT.
205 Note that it is only possible to use header lines before the first partition
206 is specified in the input.
209 .B Unnamed-fields format
213 .I start size type bootable
216 where each line fills one partition descriptor.
218 Fields are separated by whitespace, or by comma or semicolon possibly followed by
219 whitespace; initial and trailing whitespace is ignored. Numbers can be octal,
220 decimal or hexadecimal; decimal is the default. When a field is absent or empty,
221 a default value is used. But when the \fB-N\fR option (change a single partition)
222 is given, the default for each field is its previous value.
226 is the first non-assigned sector aligned according to device I/O limits.
227 The default start offset for the first partition is 1 MiB. The offset may
228 be followed by the multiplicative suffixes (KiB, MiB, GiB, TiB, PiB,
229 EiB, ZiB and YiB) then the number is interpreted as offset in bytes.
233 is as much as possible (until the next partition or end-of-device). A '+' can be
234 used instead of a number for size, which also means as much as possible. The
235 size may be followed by the multiplicative suffixes (KiB, MiB, GiB, TiB, PiB,
236 EiB, ZiB and YiB), then the number is interpreted as size of the partition in
237 bytes and then the size is aligned according to the device I/O limits.
238 The default is to interpret the number as number of sectors.
242 is given in hex for MBR (DOS), without the 0x prefix, a GUID string for GPT, or
247 Linux; means 83 for MBR and 0FC63DAF-8483-4772-8E79-3D69D8477DE4 for GPT.
250 swap area; means 82 for MBR and 0657FD6D-A4AB-43C4-84E5-0933C84B4F4F for GPT
253 extended partition; means 5 for MBR
256 home partition; means 933AC7E1-2EB4-4F13-B844-0E14E2AEF915 for GPT
259 linux extended partition; means 85 for MBR.
263 is specified as [\fB*\fR|\fB-\fR], with as default not-bootable. (The value of
264 this field is irrelevant for Linux - when Linux runs it has been booted already -
265 but might play a role for certain boot loaders and for other operating systems.)
268 .B Named-fields format
270 This format is more readable, robust, extendible and allows to specify additional
271 information (e.g. a UUID). It is recommended to use this format to keep your scripts
275 .RI [ "device \fB:" ] " name" [\fB= value "], ..."
280 field is optional. \fBsfdisk\fRextracts the partition number from the
281 device name. It allows to specify the partitions in random order.
282 This functionality is mostly used by \fB\-\-dump\fR.
283 Don't use it if you are not sure.
287 can be between quotation marks (e.g. name="This is partition name").
288 The currently supported fields are:
292 The first non-assigned sector aligned according to device I/O limits. The default
293 start offset for the first partition is 1 MiB. The offset may be followed by
294 the multiplicative suffixes (KiB, MiB, GiB, TiB, PiB, EiB, ZiB and YiB) then
295 the number is interpreted as offset in bytes.
298 Specify the partition size in sectors. The number may be followed by the multiplicative
299 suffixes (KiB, MiB, GiB, TiB, PiB, EiB, ZiB and YiB), then it's interpreted as size
300 in bytes and the size is aligned according to device I/O limits.
303 Mark the partition as bootable.
306 Partition attributes, usually GPT partition attribute bits. See
307 \fB\-\-part\-attrs\fR for more details about the GPT-bits string format.
316 A hexadecimal number (without 0x) for an MBR partition, or a GUID for a GPT partition.
317 For backward compatibility the \fBId=\fR field has the same meaning.
321 .SH "BACKING UP THE PARTITION TABLE"
322 It is recommended to save the layout of your devices.
326 Use the \fB\-\-dump\fR option to save a description of the device layout
327 to a text file. The dump format is suitable for later \fBsfdisk\fR input.
331 .B "sfdisk --dump /dev/sda > sda.dump"
334 This can later be restored by:
337 .B "sfdisk /dev/sda < sda.dump"
340 If you want to do a full (binary) backup of all sectors where the
341 partition table is stored,
342 then use the \fB\-\-backup\fR option. It writes the sectors to
343 ~/sfdisk-<device>-<offset>.bak files. The default name of the backup file can
344 be changed with the \fB\-\-backup\-file\fR option. The backup files
345 contain only raw data from the \fIdevice\fR.
346 Note that the same concept of backup files is used by
351 .B "sfdisk --backup /dev/sda"
354 The GPT header can later be restored by:
357 .B dd if=~/sfdisk-sda-0x00000200.bak of=/dev/sda seek=$((0x00000200)) bs=1 conv=notrunc
360 Note that \fBsfdisk\fR since version 2.26 no longer provides the \fB\-I\fR option to
363 provides all necessary functionality.
366 Implicit coloring can be disabled by an empty file \fI/etc/terminal-colors.d/sfdisk.disable\fR.
369 .BR terminal-colors.d (5)
370 for more details about colorization configuration. The logical color names
376 The header of the output tables.
379 The warning messages.
385 Since version 2.26 \fBsfdisk\fR no longer provides the \fB\-R\fR or
386 \fB\-\-re\-read\fR option to force the kernel to reread the partition table.
387 Use \fBblockdev \-\-rereadpt\fR instead.
389 Since version 2.26 \fBsfdisk\fR does not provide the \fB\-\-DOS\fR, \fB\-\-IBM\fR, \fB\-\-DOS\-extended\fR,
390 \fB\-\-unhide\fR, \fB\-\-show\-extended\fR, \fB\-\-cylinders\fR, \fB\-\-heads\fR, \fB\-\-sectors\fR,
391 \fB\-\-inside\-outer\fR, \fB\-\-not\-inside\-outer\fR options.
395 enables sfdisk debug output.
396 .IP LIBFDISK_DEBUG=all
397 enables libfdisk debug output.
398 .IP LIBBLKID_DEBUG=all
399 enables libblkid debug output.
400 .IP LIBSMARTCOLS_DEBUG=all
401 enables libsmartcols debug output.
411 Karel Zak <kzak@redhat.com>
413 The current sfdisk implementation is based on the original sfdisk
414 from Andries E. Brouwer.
417 The sfdisk command is part of the util-linux package and is available from
418 ftp://ftp.kernel.org/pub/linux/utils/util-linux/.