]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
sfdisk: disable bootbits protection on '--wipe always'
authorKarel Zak <kzak@redhat.com>
Thu, 15 Oct 2020 10:04:15 +0000 (12:04 +0200)
committerKarel Zak <kzak@redhat.com>
Thu, 15 Oct 2020 10:04:15 +0000 (12:04 +0200)
Addresses: https://github.com/karelzak/util-linux/issues/1156
Signed-off-by: Karel Zak <kzak@redhat.com>
disk-utils/sfdisk.8
disk-utils/sfdisk.c

index bd5a2b11d42c0a0fa3074163d3d8516cf6dd6ee8..b993d955ccae1f4c75ef1df93d3c97bbccb7c407 100644 (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.
index 54d3b60e71fa954f62e775f7c6c6ee94593c2750..2e8d7ea0e5e0f9398e00412e1f894cac9604b8fd 100644 (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);