sfdisk: disable bootbits protection on '--wipe always'

Addresses: https://github.com/karelzak/util-linux/issues/1156
Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
Karel Zak 2020-10-15 12:04:15 +02:00
parent e57cbfe0aa
commit 29decc7b37
2 changed files with 16 additions and 4 deletions

View File

@ -36,6 +36,14 @@ never been important for Linux, and this addressing concept does not make any
sense for new devices.
.sp
.B sfdisk
protects the first disk sector when create a new disk label.
The option \fB\-\-wipe always\fR disables this protection. Note that
.BR fdisk (8)
and
.BR cfdisk (8)
completely erase this area by default.
.sp
.B sfdisk
(since version 2.26)
.B aligns the start and end of partitions
to block-device I/O limits when relative sizes are specified, when the default
@ -315,8 +323,10 @@ to avoid possible collisions. The argument \fIwhen\fR can be \fBauto\fR,
\fBnever\fR or \fBalways\fR. When this option is not given, the default is
\fBauto\fR, in which case signatures are wiped only when in interactive mode;
except the old partition-table signatures which are always wiped before create
a new partition-table if the argument \fIwhen\fR is not \fBnever\fR. In all
cases detected signatures are reported by warning messages before a new
a new partition-table if the argument \fIwhen\fR is not \fBnever\fR.
The \fBauto\fR mode also does not wipe the first sector (boot sector), it is
necessary to use the \fBalways\fR mode to wipe this area.
In all cases detected signatures are reported by warning messages before a new
partition table is created. See also the
.BR wipefs (8)
command.

View File

@ -230,7 +230,9 @@ static void sfdisk_init(struct sfdisk *sf)
if (!sf->cxt)
err(EXIT_FAILURE, _("failed to allocate libfdisk context"));
fdisk_set_ask(sf->cxt, ask_callback, (void *) sf);
fdisk_enable_bootbits_protection(sf->cxt, 1);
if (sf->wipemode != WIPEMODE_ALWAYS)
fdisk_enable_bootbits_protection(sf->cxt, 1);
if (sf->label_nested) {
struct fdisk_context *x = fdisk_new_nested_context(sf->cxt,
@ -1627,7 +1629,7 @@ static void follow_wipe_mode(struct sfdisk *sf)
if (dowipe) {
if (!fdisk_is_ptcollision(sf->cxt)) {
fdisk_warnx(sf->cxt, _(
"The device contains '%s' signature and it will be removed by a write command. "
"The device contains '%s' signature and it may be removed by a write command. "
"See sfdisk(8) man page and --wipe option for more details."),
fdisk_get_collision(sf->cxt));
fputc('\n', stdout);