]> git.ipfire.org Git - thirdparty/util-linux.git/blame - disk-utils/sfdisk.8
Merge branch 'master' of https://github.com/pali/util-linux
[thirdparty/util-linux.git] / disk-utils / sfdisk.8
CommitLineData
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.\"
7f576918 13.TH SFDISK 8 "June 2015" "util-linux" "System Administration"
fd6b7a7f 14.SH NAME
5aac7429 15sfdisk \- 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
135e0389
KZ
28is a script-oriented tool for partitioning any block device. It
29runs in interactive mode if executed on terminal (stdin refers to a terminal).
fd6b7a7f 30
d5206b96 31Since version 2.26
5dbff4c0 32.B sfdisk
5aac7429
KZ
33supports MBR (DOS), GPT, SUN and SGI disk labels, but no longer provides any
34functionality for CHS (Cylinder-Head-Sector) addressing. CHS has
35never been important for Linux, and this addressing concept does not make any
36sense for new devices.
689d83de 37.sp
b69719b6 38.B sfdisk
86800f5d
KZ
39(since version 2.26)
40.B aligns the start and end of partitions
41to block-device I/O limits when relative sizes are specified, when the default
eb024893 42values are used or when multiplicative suffixes (e.g., MiB) are used for sizes.
86800f5d
KZ
43It is possible that partition size will be optimized (reduced or enlarged) due
44to alignment if the start offset is specified exactly in sectors and partition
45size relative or by multiplicative suffixes.
46
47The recommended way is not to specify start offsets at all and specify
48partition size in MiB, GiB (or so). In this case sfdisk align all partitions
49to block-device I/O limits (or when I/O limits are too small then to megabyte
50boundary to keep disk layout portable). If this default behaviour is unwanted
208b2ef0
KZ
51(usually for very small partitions) then specify offsets and sizes in
52sectors. In this case sfdisk entirely follows specified numbers without any
53optimization.
689d83de 54.sp
a8a4887b 55.B sfdisk
689d83de
BS
56does not create the standard system partitions for SGI and SUN disk labels like
57.BR fdisk (8)
58does.
a8a4887b
KZ
59It is necessary to explicitly create all partitions including whole-disk system
60partitions.
61
aefa920a
KZ
62.B sfdisk
63uses BLKRRPART (reread partition table) ioctl to make sure that the device is
1c4c6024 64not used by system or another tools (see also \-\-no-reread). It's possible that
aefa920a
KZ
65this feature or another sfdisk activity races with \fBudevd\fR. The recommended way
66how to avoid possible collisions is to use exclusive flock for the whole-disk
67device to serialize device access. The exclusive lock will cause udevd to skip
68the event handling on the device. For example:
69.RS
70.sp
71.nf
72.B "flock /dev/sdc sfdisk /dev/sdc"
73.fi
74.sp
75.RE
76Note, this semantic is not currently supported by udevd for MD and DM devices.
77
5aac7429
KZ
78.SH COMMANDS
79The commands are mutually exclusive.
fd6b7a7f 80.TP
f49ccec2 81.RB [ \-N " \fIpartition-number\fR] " \fIdevice\fR
689d83de 82The default \fBsfdisk\fR command is to read the specification for the desired
5aac7429 83partitioning of \fIdevice\fR from standard input, and then create a partition
689d83de
BS
84table according to the specification. See below for the description of the
85input format. If standard input is a terminal, then \fBsfdisk\fR starts an
86interactive session.
87.sp
88If the option \fB\-N\fR is specified, then the changes are applied to
7f576918 89the partition addressed by \fIpartition-number\fR. The unspecified fields
d754d554
KZ
90of the partition are not modified.
91.sp
7f576918
BS
92Note that it's possible to address an unused partition with \fB\-N\fR.
93For example, an MBR always contains 4 partitions, but the number of used
94partitions may be smaller. In this case \fBsfdisk\fR follows the default
95values from the partition table and does not use built-in defaults for the
c805c369 96unused partition given with \fB\-N\fR. See also \fB\-\-append\fR.
fd6b7a7f 97.TP
8175ed3d
KZ
98.BR \-A , " \-\-activate \fIdevice " [ \fIpartition-number...]
99Switch on the bootable flag for the specified partitions and switch off the
1c4c6024 100bootable flag on all unspecified partitions. The special placeholder '\-'
8175ed3d
KZ
101may be used instead of the partition numbers to switch off the bootable flag
102on all partitions.
103
49032ef7
KZ
104The activation command is supported for MBR and PMBR only. If GPT label is detected
105than sfdisk prints warning and automatically enter PMBR.
106
8175ed3d
KZ
107If no \fIpartition-number\fR is specified, then list the partitions with an
108enabled flag.
9a79aa6e 109.TP
c805c369
BS
110.BR "\-\-delete \fIdevice " [ \fIpartition-number ...]
111Delete all or the specified partitions.
aab9be66 112.TP
9a79aa6e 113.BR \-d , " \-\-dump " \fIdevice\fR
7f576918 114Dump the partitions of a device in a format that is usable as input to \fBsfdisk\fR.
689d83de 115See the section \fBBACKING UP THE PARTITION TABLE\fR.
9a79aa6e 116.TP
b06c1ca6 117.BR \-g , " \-\-show\-geometry " [ \fIdevice ...]
349ac672
KZ
118List the geometry of all or the specified devices. For backward
119compatibility the deprecated option \fB\-\-show\-pt\-geometry\fR have the same
120meaning as this one.
7f576918 121.TP
a592b4b5 122.BR \-J , " \-\-json " \fIdevice\fR
7f576918
BS
123Dump the partitions of a device in JSON format. Note that \fBsfdisk\fR is
124not able to use JSON as input format.
9a79aa6e 125.TP
689d83de
BS
126.BR \-l , " \-\-list " [ \fIdevice ...]
127List the partitions of all or the specified devices. This command can be used
9a79aa6e
KZ
128together with \fB\-\-verify\fR.
129.TP
8abdb912
KZ
130.BR \-F , " \-\-list-free " [ \fIdevice ...]
131List the free unpartitioned areas on all or the specified devices.
132.TP
c805c369
BS
133.BR "\-\-part\-attrs \fIdevice partition-number " [ \fIattributes ]
134Change the GPT partition attribute bits. If \fIattributes\fR is not specified,
135then print the current partition settings. The \fIattributes\fR argument is a
689d83de 136comma- or space-delimited list of bits. The currently supported attribute
d1b7bfe5 137bits are: RequiredPartition, NoBlockIOProtocol, LegacyBIOSBootable
689d83de 138and GUID-specific bits in the range from 48 to 63. For example, the string
d1b7bfe5 139"RequiredPartition,50,51" sets three bits.
bc9e8547 140.TP
c805c369 141.BR "\-\-part\-label \fIdevice partition-number " [ \fIlabel ]
80840c16 142Change the GPT partition name (label). If \fIlabel\fR is not specified,
689d83de 143then print the current partition label.
e36fb07a 144.TP
c805c369 145.BR "\-\-part\-type \fIdevice partition-number " [ \fItype ]
689d83de
BS
146Change the partition type. If \fItype\fR is not specified, then print the
147current partition type. The \fItype\fR argument is hexadecimal for MBR,
148or a GUID for GPT. For backward compatibility the options \fB\-c\fR and
c805c369 149\fB\-\-id\fR have the same meaning as this one.
e36fb07a 150.TP
c805c369 151.BR "\-\-part\-uuid \fIdevice partition-number " [ \fIuuid ]
689d83de
BS
152Change the GPT partition UUID. If \fIuuid\fR is not specified,
153then print the current partition UUID.
e36fb07a 154.TP
65e27d54
KZ
155.BR "\-\-disk\-id \fIdevice " [ \fIid ]
156Change the disk identifier. If \fIid\fR is not specified,
157then print the current identifier. The identifier is UUID for GPT
158or unsigned integer for MBR.
159.TP
9a17d946 160.BR \-r , " \-\-reorder " \fIdevice
c805c369 161Renumber the partitions, ordering them by their start offset.
9a17d946 162.TP
b06c1ca6 163.BR \-s , " \-\-show\-size " [ \fIdevice ...]
b0ff9a76
CM
164List the sizes of all or the specified devices in units of 1024 byte size.
165This command is DEPRECATED in favour of
dbeb1d73 166.BR blockdev (8).
9a79aa6e 167.TP
b06c1ca6 168.BR \-T , " \-\-list\-types"
689d83de 169Print all supported types for the current disk label or the label specified by
9a79aa6e 170\fB\-\-label\fR.
3a5bdedf 171.TP
3f43f5d0 172.BR \-V , " \-\-verify " [ \fIdevice ...]
689d83de 173Test whether the partition table and partitions seem correct.
ee5a1602
KZ
174.TP
175.BR "\-\-relocate \fIoper " \fIdevice
176Relocate partition table header. This command is currently supported for GPT header only.
177The argument \fIoper\fP can be:
178.RS
179.TP
180.B gpt-bak-std
181Move GPT backup header to the standard location at the end of the device.
182.TP
183.B gpt-bak-mini
184Move GPT backup header behind the last partition. Note that UEFI
185standard requires the backup header at the end of the device and partitioning
186tools can automatically relocate the header to follow the standard.
187.RE
5aac7429 188.SH OPTIONS
fd6b7a7f 189.TP
703ab082 190.BR \-a , " \-\-append"
689d83de 191Don't create a new partition table, but only append the specified partitions.
fd6b7a7f 192.TP
5aac7429 193.BR \-b , " \-\-backup"
689d83de
BS
194Back up the current partition table sectors before starting the partitioning.
195The default backup file name is ~/sfdisk-<device>-<offset>.bak; to use another
7f576918 196name see option \fB\-O\fR, \fB\-\-backup\-file\fR.
f74478a6 197.TP
7e3b3f47 198.BR \-\-color [ =\fIwhen ]
da25898b
KZ
199Colorize the output. The optional argument \fIwhen\fP
200can be \fBauto\fR, \fBnever\fR or \fBalways\fR. If the \fIwhen\fR argument is omitted,
7f576918
BS
201it defaults to \fBauto\fR. The colors can be disabled; for the current built-in default
202see the \fB\-\-help\fR output. See also the \fBCOLORS\fR section.
da25898b 203.TP
5aac7429
KZ
204.BR \-f , " \-\-force"
205Disable all consistency checking.
f74478a6 206.TP
0bb7e904 207.B \-\-Linux
80840c16 208Deprecated and ignored option. Partitioning that is compatible with
7f576918 209Linux (and other modern operating systems) is the default.
80840c16
BS
210.TP
211.BR \-n , " \-\-no\-act"
212Do everything except writing to the device.
213.TP
214.B \-\-no\-reread
215Do not check through the re-read-partition-table ioctl whether the device is in use.
216.TP
d4a90151
KZ
217.B \-\-no\-tell\-kernel
218Don't tell the kernel about partition changes. This option is recommended together
219with \fB\-\-no\-reread\fR to modify a partition on used disk. The modified partition
eb024893 220should not be used (e.g., mounted).
d4a90151 221.TP
c805c369 222.BR \-O , " \-\-backup\-file " \fIpath
80840c16
BS
223Override the default backup file name. Note that the device name and offset
224are always appended to the file name.
f42205d8 225.TP
7e3b3f47 226.BR \-\-move-data [ =\fIpath ]
c805c369
BS
227Move data after partition relocation, for example when moving the beginning
228of a partition to another place on the disk. The size of the partition has
229to remain the same, the new and old location may overlap. This option requires
230option \fB\-N\fR in order to be processed on one specific partition only.
f42205d8 231
69f30c31
KZ
232The optional \fIpath\fR specifies log file name. The log file contains information
233about all read/write operations on the partition data. The word "@default" as
234a \fIpath\fR forces sfdisk to use ~/sfdisk-<devname>.move for the log. The log is
235optional since v2.35.
f42205d8 236
c805c369 237Note that this operation is risky and not atomic. \fBDon't forget to backup your data!\fR
f42205d8 238
7942ba8a
KZ
239See also \fB\-\-move\-use\-fsync\fR.
240
c805c369 241In the example below, the first command creates a 100MiB free area before
eb024893 242the first partition and moves the data it contains (e.g., a filesystem),
c805c369
BS
243the next command creates a new partition from the free space (at offset 2048),
244and the last command reorders partitions to match disk order
245(the original sdc1 will become sdc2).
f42205d8
KZ
246.RS
247.sp
1c4c6024 248.B "echo '+100M,' | sfdisk \-\-move-data /dev/sdc \-N 1"
f42205d8 249.br
1c4c6024 250.B "echo '2048,' | sfdisk /dev/sdc \-\-append
f42205d8 251.br
1c4c6024 252.B sfdisk /dev/sdc \-\-reorder
f42205d8
KZ
253.sp
254.RE
255
7942ba8a 256.TP
2fb684f0 257.B \-\-move\-use\-fsync
7942ba8a
KZ
258Use fsync system call after each write when move dara to a new location by
259\fB\-\-move\-data\fR.
80840c16 260.TP
689d83de 261.BR \-o , " \-\-output " \fIlist
01f9286c
KZ
262Specify which output columns to print. Use
263.B \-\-help
264to get a list of all supported columns.
689d83de 265.sp
01f9286c 266The default list of columns may be extended if \fIlist\fP is
1c4c6024 267specified in the format \fI+list\fP (e.g., \fB\-o +UUID\fP).
01f9286c 268.TP
5aac7429
KZ
269.BR \-q , " \-\-quiet"
270Suppress extra info messages.
f74478a6 271.TP
689d83de 272.BR \-u , " \-\-unit S"
b0ff9a76 273Deprecated option. Only the sector unit is supported. This option is not
1c4c6024 274supported when using the \-\-show-size command.
f74478a6 275.TP
689d83de 276.BR \-X , " \-\-label " \fItype
eb024893 277Specify the disk label type (e.g., \fBdos\fR, \fBgpt\fR, ...). If this option
689d83de 278is not given, then \fBsfdisk\fR defaults to the existing label, but if there
35ca5118
KZ
279is no label on the device yet, then the type defaults to \fBdos\fR. The default
280or the current label may be overwritten by the "label: <name>" script header
281line. The option \fB\-\-label\fR does not force \fBsfdisk\fR to create empty
282disk label (see the \fBEMPTY DISK LABEL\fR section below).
01f9286c 283.TP
b06c1ca6 284.BR \-Y , " \-\-label\-nested " \fItype
689d83de
BS
285Force editing of a nested disk label. The primary disk label has to exist already.
286This option allows to edit for example a hybrid/protective MBR on devices with GPT.
15b5e942
KZ
287
288.TP
1c4c6024 289.BR \-w , " \-\-wipe "\fIwhen
589b6931
BS
290Wipe filesystem, RAID and partition-table signatures from the device, in order
291to avoid possible collisions. The argument \fIwhen\fR can be \fBauto\fR,
292\fBnever\fR or \fBalways\fR. When this option is not given, the default is
bb881527
KZ
293\fBauto\fR, in which case signatures are wiped only when in interactive mode;
294except the old partition-table signatures which are always wiped before create
295a new partition-table if the argument \fIwhen\fR is not \fBnever\fR. In all
296cases detected signatures are reported by warning messages before a new
297partition table is created. See also
15b5e942
KZ
298.BR wipefs (8)
299command.
300
3d6db3fd 301.TP
1c4c6024 302.BR \-W , " \-\-wipe-partitions "\fIwhen
3d6db3fd
KZ
303Wipe filesystem, RAID and partition-table signatures from a newly created
304partitions, in order to avoid possible collisions. The argument \fIwhen\fR can
305be \fBauto\fR, \fBnever\fR or \fBalways\fR. When this option is not given, the
306default is \fBauto\fR, in which case signatures are wiped only when in
307interactive mode and after confirmation by user. In all cases detected
308signatures are reported by warning messages after a new partition is created.
309See also
310.BR wipefs (8)
311command.
312
689d83de
BS
313.TP
314.BR \-v , " \-\-version"
315Display version information and exit.
e1422de3 316.TP
5aac7429
KZ
317.BR \-h , " \-\-help"
318Display help text and exit.
fd6b7a7f 319
9a79aa6e
KZ
320.SH "INPUT FORMATS"
321.B sfdisk
322supports two input formats and generic header lines.
323
324.B Header lines
325.RS
689d83de
BS
326The optional header lines specify generic information that apply to the partition
327table. The header-line format is:
328.RS
329.sp
9a79aa6e 330.B "<name>: <value>"
689d83de
BS
331.sp
332.RE
9a79aa6e
KZ
333The currently recognized headers are:
334.RS
335.TP
336.B unit
689d83de 337Specify the partitioning unit. The only supported unit is \fBsectors\fR.
9a79aa6e
KZ
338.TP
339.B label
689d83de 340Specify the partition table type. For example \fBdos\fR or \fBgpt\fR.
9a79aa6e
KZ
341.TP
342.B label-id
689d83de
BS
343Specify the partition table identifier. It should be a hexadecimal number
344(with a 0x prefix) for MBR and a UUID for GPT.
aef79c1f
KZ
345.TP
346.B first-lba
347Specify the first usable sector for GPT partitions.
348.TP
349.B last-lba
350Specify the last usable sector for GPT partitions.
351.TP
352.B table-length
353Specify the maximal number of GPT partitions.
e4386c8c
KZ
354.TP
355.B grain
356Specify minimal size in bytes used to calculate partitions alignment. The
357default is 1MiB and it's strongly recommended to use the default. Do not
358modify this variable if you're not sure.
e56ca068
KZ
359.TP
360.B sector-size
361Specify sector size. This header is informative only and it is not used when
362sfdisk creates a new partition table, in this case the real device specific
363value is always used and sector size from the dump is ignored.
9a79aa6e
KZ
364.RE
365.sp
689d83de 366Note that it is only possible to use header lines before the first partition
9a79aa6e
KZ
367is specified in the input.
368.RE
369
689d83de
BS
370.B Unnamed-fields format
371.RS
9a79aa6e 372.RS
689d83de
BS
373.sp
374.I start size type bootable
375.sp
376.RE
9a79aa6e 377where each line fills one partition descriptor.
689d83de 378.sp
11aa2aa2
IW
379Fields are separated by whitespace, comma or semicolon possibly
380followed by whitespace; initial and trailing whitespace is ignored.
381Numbers can be octal, decimal or hexadecimal; decimal is the default.
1c4c6024
BIG
382When a field is absent, empty or specified as '\-' a default value is
383used. But when the \fB\-N\fR option (change a single partition) is
11aa2aa2 384given, the default for each field is its previous value.
689d83de 385.sp
9a79aa6e
KZ
386The default value of
387.I start
689d83de 388is the first non-assigned sector aligned according to device I/O limits.
c805c369 389The default start offset for the first partition is 1 MiB. The offset may
80840c16 390be followed by the multiplicative suffixes (KiB, MiB, GiB, TiB, PiB,
ce9f568c 391EiB, ZiB and YiB) then the number is interpreted as offset in bytes.
689d83de 392.sp
9a79aa6e
KZ
393The default value of
394.I size
eb024893 395indicates "as much as possible"; i.e., until the next partition or
11aa2aa2
IW
396end-of-device. A numerical argument is by default interpreted as a
397number of sectors, however if the size is followed by one of the
398multiplicative suffixes (KiB, MiB, GiB, TiB, PiB, EiB, ZiB and YiB)
399then the number is interpreted as the size of the partition in bytes
400and it is then aligned according to the device I/O limits. A '+' can
401be used instead of a number to enlarge the partition as much as
402possible. Note '+' is equivalent to the default behaviour for a new
403partition; existing partitions will be resized as required.
689d83de
BS
404.sp
405The partition
9a79aa6e 406.I type
689d83de
BS
407is given in hex for MBR (DOS), without the 0x prefix, a GUID string for GPT, or
408a shortcut:
9a79aa6e
KZ
409.RS
410.TP
689d83de 411.B L
9a79aa6e
KZ
412Linux; means 83 for MBR and 0FC63DAF-8483-4772-8E79-3D69D8477DE4 for GPT.
413.TP
689d83de 414.B S
9a79aa6e
KZ
415swap area; means 82 for MBR and 0657FD6D-A4AB-43C4-84E5-0933C84B4F4F for GPT
416.TP
417.B E
418extended partition; means 5 for MBR
419.TP
420.B H
421home partition; means 933AC7E1-2EB4-4F13-B844-0E14E2AEF915 for GPT
422.TP
423.B X
424linux extended partition; means 85 for MBR.
d09c06ba
KZ
425.TP
426.B U
300e24a8 427EFI System partition, means EF for MBR and C12A7328-F81F-11D2-BA4B-00A0C93EC93B for GPT
6ebc3785
KZ
428.TP
429.B R
7e95fd82 430Linux RAID; means FD for MBR and A19D880F-05FC-4D3B-A006-743F0F84911E for GPT
6ebc3785
KZ
431.TP
432.B V
7e95fd82 433LVM; means 8E for MBR and E6D6D379-F507-44C2-A23C-238F2A3DF928 for GPT
9a79aa6e 434.RE
11aa2aa2
IW
435.PP
436The default
437.I type
438value is
439.I L
9a79aa6e 440
689d83de 441.I bootable
11aa2aa2
IW
442is specified as [\fB*\fR|\fB-\fR], with as default not-bootable. The
443value of this field is irrelevant for Linux - when Linux runs it has
c7a3455c 444been booted already - but it might play a role for certain boot
11aa2aa2 445loaders and for other operating systems.
9a79aa6e
KZ
446.RE
447
689d83de 448.B Named-fields format
9a79aa6e 449.RS
d35df4db 450This format is more readable, robust, extensible and allows to specify additional
eb024893 451information (e.g., a UUID). It is recommended to use this format to keep your scripts
9a79aa6e 452more readable.
689d83de
BS
453.RS
454.sp
455.RI [ "device \fB:" ] " name" [\fB= value "], ..."
456.sp
457.RE
458The
9a79aa6e 459.I device
c805c369 460field is optional. \fBsfdisk\fR extracts the partition number from the
689d83de 461device name. It allows to specify the partitions in random order.
97325257 462This functionality is mostly used by \fB\-\-dump\fR.
689d83de 463Don't use it if you are not sure.
9a79aa6e
KZ
464
465The
466.I value
eb024893 467can be between quotation marks (e.g., name="This is partition name").
689d83de 468The currently supported fields are:
9a79aa6e
KZ
469.RS
470.TP
689d83de
BS
471.BI start= number
472The first non-assigned sector aligned according to device I/O limits. The default
ce9f568c
KZ
473start offset for the first partition is 1 MiB. The offset may be followed by
474the multiplicative suffixes (KiB, MiB, GiB, TiB, PiB, EiB, ZiB and YiB) then
475the number is interpreted as offset in bytes.
9a79aa6e 476.TP
689d83de
BS
477.BI size= number
478Specify the partition size in sectors. The number may be followed by the multiplicative
9a79aa6e
KZ
479suffixes (KiB, MiB, GiB, TiB, PiB, EiB, ZiB and YiB), then it's interpreted as size
480in bytes and the size is aligned according to device I/O limits.
481.TP
689d83de
BS
482.B bootable
483Mark the partition as bootable.
9a79aa6e 484.TP
689d83de
BS
485.BI attrs= string
486Partition attributes, usually GPT partition attribute bits. See
b06c1ca6 487\fB\-\-part\-attrs\fR for more details about the GPT-bits string format.
9a79aa6e 488.TP
689d83de 489.BI uuid= string
9a79aa6e
KZ
490GPT partition UUID.
491.TP
689d83de 492.BI name= string
9a79aa6e
KZ
493GPT partition name.
494.TP
689d83de 495.BI type= code
08474fde
KZ
496A hexadecimal number (without 0x) for an MBR partition, a GUID for a GPT partition,
497or a shortcut as for unnamed-fields format.
689d83de 498For backward compatibility the \fBId=\fR field has the same meaning.
9a79aa6e
KZ
499.RE
500.RE
501
35ca5118
KZ
502.SH "EMPTY DISK LABEL"
503.B sfdisk
504does not create partition table without partitions by default. The lines with
505partitions are expected in the script by default. The empty partition table has
506to be explicitly requested by "label: <name>" script header line without any
507partitions lines. For example:
508.RS
509.sp
510.B "echo 'label: gpt' | sfdisk /dev/sdb"
511.sp
512.RE
513creates empty GPT partition table. Note that the \fB\-\-append\fR disables this feature.
514
689d83de
BS
515.SH "BACKING UP THE PARTITION TABLE"
516It is recommended to save the layout of your devices.
9a79aa6e
KZ
517.B sfdisk
518supports two ways.
689d83de
BS
519.sp
520Use the \fB\-\-dump\fR option to save a description of the device layout
521to a text file. The dump format is suitable for later \fBsfdisk\fR input.
522For example:
9a79aa6e
KZ
523.RS
524.sp
1c4c6024 525.B "sfdisk \-\-dump /dev/sda > sda.dump"
9a79aa6e
KZ
526.sp
527.RE
689d83de 528This can later be restored by:
9a79aa6e
KZ
529.RS
530.sp
531.B "sfdisk /dev/sda < sda.dump"
532.RE
533
689d83de
BS
534If you want to do a full (binary) backup of all sectors where the
535partition table is stored,
536then use the \fB\-\-backup\fR option. It writes the sectors to
537~/sfdisk-<device>-<offset>.bak files. The default name of the backup file can
538be changed with the \fB\-\-backup\-file\fR option. The backup files
539contain only raw data from the \fIdevice\fR.
540Note that the same concept of backup files is used by
541.BR wipefs (8).
542For example:
9a79aa6e
KZ
543.RS
544.sp
1c4c6024 545.B "sfdisk \-\-backup /dev/sda"
9a79aa6e
KZ
546.sp
547.RE
689d83de 548The GPT header can later be restored by:
9a79aa6e
KZ
549.RS
550.sp
c805c369
BS
551.nf
552.B "dd if=~/sfdisk-sda-0x00000200.bak of=/dev/sda \e"
553.B " seek=$((0x00000200)) bs=1 conv=notrunc"
554.fi
9a79aa6e
KZ
555.sp
556.RE
689d83de
BS
557Note that \fBsfdisk\fR since version 2.26 no longer provides the \fB\-I\fR option to
558restore sectors.
5593132a 559.BR dd (1)
9a79aa6e
KZ
560provides all necessary functionality.
561
da25898b
KZ
562.SH COLORS
563Implicit coloring can be disabled by an empty file \fI/etc/terminal-colors.d/sfdisk.disable\fR.
564
565See
566.BR terminal-colors.d (5)
567for more details about colorization configuration. The logical color names
568supported by
569.B sfdisk
570are:
571.TP
572.B header
573The header of the output tables.
574.TP
575.B warn
576The warning messages.
577.TP
578.B welcome
579The welcome message.
580
9a79aa6e 581.SH NOTES
689d83de 582Since version 2.26 \fBsfdisk\fR no longer provides the \fB\-R\fR or
b06c1ca6 583\fB\-\-re\-read\fR option to force the kernel to reread the partition table.
689d83de 584Use \fBblockdev \-\-rereadpt\fR instead.
9a79aa6e 585.PP
b06c1ca6
WP
586Since version 2.26 \fBsfdisk\fR does not provide the \fB\-\-DOS\fR, \fB\-\-IBM\fR, \fB\-\-DOS\-extended\fR,
587\fB\-\-unhide\fR, \fB\-\-show\-extended\fR, \fB\-\-cylinders\fR, \fB\-\-heads\fR, \fB\-\-sectors\fR,
588\fB\-\-inside\-outer\fR, \fB\-\-not\-inside\-outer\fR options.
9a79aa6e 589
68e422ec 590.SH ENVIRONMENT
47dd6918
KZ
591.IP SFDISK_DEBUG=all
592enables sfdisk debug output.
68e422ec
KZ
593.IP LIBFDISK_DEBUG=all
594enables libfdisk debug output.
595.IP LIBBLKID_DEBUG=all
596enables libblkid debug output.
597.IP LIBSMARTCOLS_DEBUG=all
598enables libsmartcols debug output.
599
612721db 600.SH "SEE ALSO"
612721db 601.BR fdisk (8),
5aac7429 602.BR cfdisk (8),
c64061c9
VD
603.BR parted (8),
604.BR partprobe (8),
5593132a 605.BR partx (8)
689d83de 606
5aac7429
KZ
607.SH AUTHOR
608Karel Zak <kzak@redhat.com>
609.PP
610The current sfdisk implementation is based on the original sfdisk
611from Andries E. Brouwer.
612
86d62711 613.SH AVAILABILITY
601d12fb 614The sfdisk command is part of the util-linux package and is available from
d673b74e 615https://www.kernel.org/pub/linux/utils/util-linux/.