From 35ca51182782193f555fbdcb06bb10766550d017 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Wed, 30 Nov 2016 12:43:10 +0100 Subject: sfdisk: support empty label use-case By default sfdisk creates partition table when a first partition is specified, otherwise the device is not modified. This force users to create at least one partition. This commit allows to create empty label without partitions if "label: " header line is specified by script. The commit also modifies "New situation:" output to list label name and label identifier. Addresses: https://github.com/karelzak/util-linux/issues/374 Signed-off-by: Karel Zak --- disk-utils/sfdisk.8 | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'disk-utils/sfdisk.8') diff --git a/disk-utils/sfdisk.8 b/disk-utils/sfdisk.8 index fcde8726b..efe4a86bf 100644 --- a/disk-utils/sfdisk.8 +++ b/disk-utils/sfdisk.8 @@ -212,7 +212,10 @@ Deprecated option. Only the sector unit is supported. .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. +is no label on the device yet, then the type defaults to \fBdos\fR. The default +or the current label may be overwritten by the "label: " script header +line. The option \fB\-\-label\fR does not force \fBsfdisk\fR to create empty +disk label (see the \fBEMPTY DISK LABEL\fR section below). .TP .BR \-Y , " \-\-label\-nested " \fItype Force editing of a nested disk label. The primary disk label has to exist already. @@ -404,6 +407,19 @@ For backward compatibility the \fBId=\fR field has the same meaning. .RE .RE +.SH "EMPTY DISK LABEL" +.B sfdisk +does not create partition table without partitions by default. The lines with +partitions are expected in the script by default. The empty partition table has +to be explicitly requested by "label: " script header line without any +partitions lines. For example: +.RS +.sp +.B "echo 'label: gpt' | sfdisk /dev/sdb" +.sp +.RE +creates empty GPT partition table. Note that the \fB\-\-append\fR disables this feature. + .SH "BACKING UP THE PARTITION TABLE" It is recommended to save the layout of your devices. .B sfdisk -- cgit v1.2.3-55-g7522