summaryrefslogblamecommitdiffstats
path: root/disk-utils/sfdisk.8
blob: bb0ba83dc46eafb88743ece611477cd9e85f039b (plain) (tree)
1
2
3
4
5
6
7
8
9
10
11
12

                                                  
   








                                                                          
                                                                 
        
                                                      
            
         



                      

         

          

               
                                                            
 
                  
         



                                                                             
   
         
                                                              


                                                                      
         


                                                                               


                                                                               

                                    
   
                                                  
                                                                             
                                                                             





                                                                           
   


                                                                        
   

                                                                              
                                                     
   

                                                  
   

                                                                              

                               





                                                                           

                                         


                                                                        
   




                                                                          
   


                                                               
   

                                               
   

                                                                              


                      
                                                             

           
   
                       
                                                                             
   
                       


                                                                              
   

                                 
   
                                


                                           
   


                                                            
                                        

                                                                            
   

                             
   

                                     
   

                                                                                    
   

                                                      
   
               
                                                                        
                            
   



                                                                             
   





                                                                                   
   

                           
 





                                                    



                                                                                 
                    

   



                                     
                                                                         

        
                                                                      

           

                                                                           

   
                                                                            


                          

                        
   



                           
                                               

                                                                                
                                                                              



                                                                                  

                    
                                                                        


                                                                           
   

                    
                                                                                 




                                                                             

             
       

                                                                               

   
    

                                                                         
    











                                                                            



                                                                                 

   
                      
   

                                                                                    
              





                                                  
         

                                                                      
                                                    
                                 


        

                                                                    

   

                                                                                  


                                                                            
   

                                                                                        


                                                                                   

                               
   


                                                                       
   
                

                   
                

                   


                                                                                      


   

                                                     

                  



                                                                          




                                      
                              




                               








                                                                              




                             
                                        

   
                                                                                       

   

                                                                                    



                                     


                                                                           
   


                                                                                                          
 







                                  
              
              
               

                  
            
 





                                                                 
                

                                                                          
.\" sfdisk.8 -- man page for sfdisk
.\" Copyright (C) 2014 Karel Zak <kzak@redhat.com>
.\"
.\" Permission is granted to make and distribute verbatim copies of this
.\" manual provided the copyright notice and this permission notice are
.\" preserved on all copies.
.\"
.\" Permission is granted to copy and distribute modified versions of this
.\" manual under the conditions for verbatim copying, provided that the
.\" entire resulting derived work is distributed under the terms of a
.\" permission notice identical to this one.
.\"
.TH SFDISK 8 "December 2014" "util-linux" "System Administration"
.SH NAME
sfdisk \- display or manipulate a disk partition table
.SH SYNOPSIS
.B sfdisk
[options]
.I device
.RB [ \-N
.IR partition-number ]
.sp
.B sfdisk
[options]
.I command
.SH DESCRIPTION
.B sfdisk
is a script-oriented tool for partitioning any block device.

Since version 2.26
.B sfdisk
supports MBR (DOS), GPT, SUN and SGI disk labels, but no longer provides any
functionality for CHS (Cylinder-Head-Sector) addressing.  CHS has
never been important for Linux, and this addressing concept does not make any
sense for new devices.
.sp
.B sfdisk
(since version 2.26) aligns start and end of the partitions to
block-device I/O limits when relative sizes are specified, or when the
default values are used.
.sp
.B sfdisk
does not create the standard system partitions for SGI and SUN disk labels like
.BR fdisk (8)
does.
It is necessary to explicitly create all partitions including whole-disk system
partitions.

.SH COMMANDS
The commands are mutually exclusive.
.TP
.RB [ \-N " \fIpartition-number\fR] " \fIdevice\fR
The default \fBsfdisk\fR command is to read the specification for the desired
partitioning of \fIdevice\fR from standard input, and then create a partition
table according to the specification.  See below for the description of the
input format.  If standard input is a terminal, then \fBsfdisk\fR starts an
interactive session.
.sp
If the option \fB\-N\fR is specified, then the changes are applied to
the partition addressed by \fIpartition-number\fR.
.TP
.BR \-a , " \-\-activate \fIdevice\fR [" \fIpartition-number\fR...]
Switch on the bootable flag.  If no \fIpartition-number\fR is specified,
then all partitions with an enabled flag are listed.
.TP
.BR \-d , " \-\-dump " \fIdevice\fR
Dump the partitions of a device in a format that is usable as input to sfdisk.
See the section \fBBACKING UP THE PARTITION TABLE\fR.
.TP
.BR \-g , " \-\-show-geometry " [ \fIdevice ...]
List the geometry of all or the specified devices.
.TP
.BR \-l , " \-\-list " [ \fIdevice ...]
List the partitions of all or the specified devices.  This command can be used
together with \fB\-\-verify\fR.
.TP
.BR \-\-part-attrs " \fIdevice partno [" \fIattrs ]
Change the GPT partition attribute bits.  If \fIattrs\fR is not specified,
then print the current partition settings.  The \fIattrs\fR argument is a
comma- or space-delimited list of bits.  The currently supported attribute
bits are: RequiredPartiton, NoBlockIOProtocol, LegacyBIOSBootable
and GUID-specific bits in the range from 48 to 63.  For example, the string
"RequiredPartiton,50,51" sets three bits.
.TP
.BR \-\-part-label " \fIdevice partno [" \fIlabel ]
Change the GPT partition name (label).  If \fIlabel\fR is nto specified,
then print the current partition label.
.TP
.BR \-\-part-type " \fIdevice partno [" \fItype ]
Change the partition type.  If \fItype\fR is not specified, then print the
current partition type.  The \fItype\fR argument is hexadecimal for MBR,
or a GUID for GPT.  For backward compatibility the options \fB\-c\fR and
\fB\-\-id\fR have the same meaning.
.TP
.BR \-\-part-uuid " \fIdevice partno [" \fIuuid ]
Change the GPT partition UUID.  If \fIuuid\fR is not specified,
then print the current partition UUID.
.TP
.BR \-s , " \-\-show-size " [ \fIdevice ...]
List the sizes of all or the specified devices.
.TP
.BR \-T , " \-\-list-types"
Print all supported types for the current disk label or the label specified by
\fB\-\-label\fR.
.TP
.BR \-V , " \-\-verify
Test whether the partition table and partitions seem correct.

.SH OPTIONS
.TP
.BR \-A , " \-\-append"
Don't create a new partition table, but only append the specified partitions.
.TP
.BR \-b , " \-\-backup"
Back up the current partition table sectors before starting the partitioning.
The default backup file name is ~/sfdisk-<device>-<offset>.bak; to use another
name see \fB\-\-backup-file\fR.
.TP
.BR \-f , " \-\-force"
Disable all consistency checking.
.TP
.BR \-o , " \-\-output " \fIlist
Specify which output columns to print.  Use
.B \-\-help
to get a list of all supported columns.
.sp
The default list of columns may be extended if \fIlist\fP is
specified in the format \fI+list\fP (e.g. \fB-o +UUID\fP).
.TP
.BR \-O , " \-\-backup-file " \fIpath\fR
Override the default backup file name.  Note that the device name and offset
are always appended to the file name.
.TP
.BR \-q , " \-\-quiet"
Suppress extra info messages.
.TP
.BR \-n , " \-\-no\-act"
Do everything except write to device.
.TP
.B \-\-no-reread
Do not check through the re-read-partition-table ioctl whether the device is in use.
.TP
.BR \-u , " \-\-unit S"
Deprecated option.  Only the sector unit is supported.
.TP
.BR "\-\-Linux"
Deprecated and ignored option.  Linux (and another modern OS) compatible
partitioning is the default.
.TP
.BR \-X , " \-\-label " \fItype
Specify the disk label type (e.g. \fBdos\fR, \fBgpt\fR, ...).  If this option
is not given, then \fBsfdisk\fR defaults to the existing label, but if there
is no label on the device yet, then the type defaults to \fBdos\fR.
.TP
.BR \-Y , " \-\-label-nested " \fItype
Force editing of a nested disk label.  The primary disk label has to exist already.
This option allows to edit for example a hybrid/protective MBR on devices with GPT.
.TP
.BR \-v , " \-\-version"
Display version information and exit.
.TP
.BR \-h , " \-\-help"
Display help text and exit.

.SH "INPUT FORMATS"
.B sfdisk
supports two input formats and generic header lines.

.B Header lines
.RS
The optional header lines specify generic information that apply to the partition
table.  The header-line format is:
.RS
.sp
.B "<name>: <value>"
.sp
.RE
The currently recognized headers are:
.RS
.TP
.B unit
Specify the partitioning unit.  The only supported unit is \fBsectors\fR.
.TP
.B label
Specify the partition table type.  For example \fBdos\fR or \fBgpt\fR.
.TP
.B label-id
Specify the partition table identifier.  It should be a  hexadecimal number
(with a 0x prefix) for MBR and a UUID for GPT.
.RE
.sp
Note that it is only possible to use header lines before the first partition
is specified in the input.
.RE

.B Unnamed-fields format
.RS
.RS
.sp
.I start size type bootable
.sp
.RE
where each line fills one partition descriptor.
.sp
Fields are separated by whitespace, or q comma or semicolon possibly followed by
whitespace; initial and trailing whitespace is ignored.  Numbers can be octal,
decimal or hexadecimal; decimal is the default.  When  a field is absent or empty,
a default value is used.  But when the \fB-N\fR option (change a single partition)
is given, the default for each field is its previous value.
.sp
The default value of
.I start
is the first non-assigned sector aligned according to device I/O limits.
The default start offset for the first partition is 1 MiB. The offset may
be may be followed by the multiplicative suffixes (KiB, MiB, GiB, TiB, PiB,
EiB, ZiB and YiB) then the number is interpreted as offset in bytes.
.sp
The default value of
.I size
is as much as possible (until the next partition or end-of-device).  A '+' can be
used instead of a number for size, which also means as much as possible.  The
size may be followed by the multiplicative suffixes (KiB, MiB, GiB, TiB, PiB,
EiB, ZiB and YiB), then the number is interpreted as size of the partition in
bytes and then the size is aligned according to the device I/O limits.
The default is to interpret the number as number of sectors.
.sp
The partition
.I type
is given in hex for MBR (DOS), without the 0x prefix, a GUID string for GPT, or
a shortcut:
.RS
.TP
.B L
Linux; means 83 for MBR and 0FC63DAF-8483-4772-8E79-3D69D8477DE4 for GPT.
.TP
.B S
swap area; means 82 for MBR and 0657FD6D-A4AB-43C4-84E5-0933C84B4F4F for GPT
.TP
.B E
extended partition; means 5 for MBR
.TP
.B H
home partition; means 933AC7E1-2EB4-4F13-B844-0E14E2AEF915 for GPT
.TP
.B X
linux extended partition; means 85 for MBR.
.RE

.I bootable
is specified as [\fB*\fR|\fB-\fR], with as default not-bootable.  (The value of
this field is irrelevant for Linux - when Linux runs it has been booted already -
but might play a role for certain boot loaders and for other operating systems.)
.RE

.B Named-fields format
.RS
This format is more readable, robust, extendible and allows to specify additional
information (e.g. a UUID).  It is recommended to use this format to keep you scripts
more readable.
.RS
.sp
.RI [ "device \fB:" ] " name" [\fB= value "], ..."
.sp
.RE
The
.I device
field is optional.  \fBsfdisk\fRextracts the partition number from the
device name.  It allows to specify the partitions in random order.
This functionality is mostly used by \fB\-\-dump\fR.
Don't use it if you are not sure.

The
.I value
can be between quotation marks (e.g. name="This is partition name").
The currently supported fields are:
.RS
.TP
.BI start= number
The first non-assigned sector aligned according to device I/O limits.  The default
start offset for the first partition is 1 MiB. The offset may be followed by
the multiplicative suffixes (KiB, MiB, GiB, TiB, PiB, EiB, ZiB and YiB) then
the number is interpreted as offset in bytes.
.TP
.BI size= number
Specify the partition size in sectors.  The number may be followed by the multiplicative
suffixes (KiB, MiB, GiB, TiB, PiB, EiB, ZiB and YiB), then it's interpreted as size
in bytes and the size is aligned according to device I/O limits.
.TP
.B bootable
Mark the partition as bootable.
.TP
.BI attrs= string
Partition attributes, usually GPT partition attribute bits.  See
\fB\-\-part-attrs\fR for more details about the GPT-bits string format.
.TP
.BI uuid= string
GPT partition UUID.
.TP
.BI name= string
GPT partition name.
.TP
.BI type= code
A hexadecimal number (without 0x) for an MBR partition, or a GUID for a GPT partition.
For backward compatibility the \fBId=\fR field has the same meaning.
.RE
.RE

.SH "BACKING UP THE PARTITION TABLE"
It is recommended to save the layout of your devices.
.B sfdisk
supports two ways.
.sp
Use the \fB\-\-dump\fR option to save a description of the device layout
to a text file.  The dump format is suitable for later \fBsfdisk\fR input.
For example:
.RS
.sp
.B "sfdisk --dump /dev/sda > sda.dump"
.sp
.RE
This can later be restored by:
.RS
.sp
.B "sfdisk /dev/sda < sda.dump"
.RE

If you want to do a full (binary) backup of all sectors where the
partition table is stored,
then use the \fB\-\-backup\fR option.  It writes the sectors to
~/sfdisk-<device>-<offset>.bak files.  The default name of the backup file can
be changed with the \fB\-\-backup\-file\fR option.  The backup files
contain only raw data from the \fIdevice\fR.
Note that the same concept of backup files is used by
.BR wipefs (8).
For example:
.RS
.sp
.B "sfdisk --backup /dev/sda"
.sp
.RE
The GPT header can later be restored by:
.RS
.sp
.B dd if=~/sfdisk-sda-0x00000200.bak of=/dev/sda seek=$((0x00000200)) bs=1 conv=notrunc
.sp
.RE
Note that \fBsfdisk\fR since version 2.26 no longer provides the \fB\-I\fR option to
restore sectors.
.B dd (1)
provides all necessary functionality.

.SH NOTES
Since version 2.26 \fBsfdisk\fR no longer provides the \fB\-R\fR or
\fB\-\-re-read\fR option to force the kernel to reread the partition table.
Use \fBblockdev \-\-rereadpt\fR instead.
.PP
Since version 2.26 \fBsfdisk\fR does not provide the \fB\-\-DOS\fR, \fB\-\-IBM\fR, \fB\-\-DOS-extended\fR,
\fB\-\-unhide\fR, \fB\-\-show-extended\fR, \fB\-\-cylinders\fR, \fB\-\-heads\fR, \fB\-\-sectors\fR,
\fB\-\-inside-outer\fR, \fB\-\-not-inside-outer\fR options.

.SH ENVIRONMENT
.IP LIBFDISK_DEBUG=all
enables libfdisk debug output.
.IP LIBBLKID_DEBUG=all
enables libblkid debug output.
.IP LIBSMARTCOLS_DEBUG=all
enables libsmartcols debug output.

.SH "SEE ALSO"
.BR fdisk (8),
.BR cfdisk (8),
.BR parted (8),
.BR partprobe (8),
.BR partx(8)

.SH AUTHOR
Karel Zak <kzak@redhat.com>
.PP
The current sfdisk implementation is based on the original sfdisk
from Andries E. Brouwer.

.SH AVAILABILITY
The sfdisk command is part of the util-linux package and is available from
ftp://ftp.kernel.org/pub/linux/utils/util-linux/.