From 15b5e942f2c159db8f726079573bb77cdad560ed Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Thu, 18 Feb 2016 12:57:13 +0100 Subject: [PATCH] sfdisk: add --wipe This patch changes sfdisk behavior and it wipes foreign signatures from the device to avoid collisions. The wipe functionality is automatically enabled in the interactive mode only (user is always warned about it), otherwise it's possible to control all by --wipe . The program does not change behavior when executed in scripts (echo | sfdisk), the option "--wipe=always" is required to enable in this case. Signed-off-by: Karel Zak --- disk-utils/sfdisk.8 | 11 +++++++++++ disk-utils/sfdisk.c | 32 +++++++++++++++++++++++++++++++- 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/disk-utils/sfdisk.8 b/disk-utils/sfdisk.8 index 31b43c2c9..1e60de519 100644 --- a/disk-utils/sfdisk.8 +++ b/disk-utils/sfdisk.8 @@ -208,6 +208,17 @@ is no label on the device yet, then the type defaults to \fBdos\fR. .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 -w , " \-\-wipe "\fImode +Wipe filesystems, RAIDs and partition tables signatures from the device, in +order to avoid possible collisions. The \fImode\fR can be \fBauto\fR, +\fBnever\fR or \fBalways\fR. The default is \fBauto\fR, in this case signatures +are wiped in the interactive mode only, in all cases detected signatures are +reported by warning message before a new partition table is created. See also +.BR wipefs (8) +command. + .TP .BR \-v , " \-\-version" Display version information and exit. diff --git a/disk-utils/sfdisk.c b/disk-utils/sfdisk.c index 4e99df53b..81371eb34 100644 --- a/disk-utils/sfdisk.c +++ b/disk-utils/sfdisk.c @@ -89,6 +89,7 @@ enum { struct sfdisk { int act; /* ACT_* */ int partno; /* -N , default -1 */ + int wipemode; /* remove foreign signatures */ const char *label; /* --label