#995904 Please add wipefs --recursive

Package:
util-linux
Source:
util-linux
Description:
miscellaneous system utilities
Submitter:
"Trent W. Buck"
Date:
2021-10-15 16:45:04 UTC
Severity:
wishlist
Tags:
#995904#5
Date:
2021-10-08 02:31:23 UTC
From:
To:
wipefs is not recursive, which leads to this unexpected behaviour:

    root@dban:~# blkid
    /dev/vda: TYPE="squashfs"
    /dev/vdb1: LABEL_FATBOOT="ESP" LABEL="ESP" UUID="6BE7-C309" BLOCK_SIZE="512" TYPE="vfat" PARTLABEL="ESP" PARTUUID="0dbbd176-3208-4461-a991-9b6b6f9"
    /dev/vdb2: LABEL="root" UUID="2238872e-f5f5-4704-944c-9974c2b41238" BLOCK_SIZE="1024" TYPE="ext4" PARTLABEL="root" PARTUUID="289c1ba2-297b-4b84-ad"

    root@dban:~# wipefs -a /dev/vdb
    /dev/vdb: 8 bytes were erased at offset 0x00000200 (gpt): 45 46 49 20 50 41 52 54
    /dev/vdb: 8 bytes were erased at offset 0x0c1ffe00 (gpt): 45 46 49 20 50 41 52 54
    /dev/vdb: 2 bytes were erased at offset 0x000001fe (PMBR): 55 aa
    /dev/vdb: calling ioctl to re-read partition table: Success

    root@dban:~# pvcreate /dev/vdb
      Physical volume "/dev/vdb" successfully created.
    root@dban:~# vgcreate x /dev/vdb
      Volume group "x" successfully created
    root@dban:~# lvcreate --size=32M --name y x
    WARNING: vfat signature detected on /dev/x/y at offset 82. Wipe it? [y/n]: y
      Wiping vfat signature on /dev/x/y.
    WARNING: vfat signature detected on /dev/x/y at offset 0. Wipe it? [y/n]: y
      Wiping vfat signature on /dev/x/y.
    WARNING: vfat signature detected on /dev/x/y at offset 510. Wipe it? [y/n]: y
      Wiping vfat signature on /dev/x/y.
      Logical volume "y" created.

If wipefs was recursive, this sort of thing wouldn't happen.
I guess libblkid already provides the necessary functionality, and
zeroing out a few extra blocks is a small I/O cost for the large gain in "principle of least surprise".

The manpage implicitly suggests to work around this by doing "wipefs /dev/vdb*".
This works if you are root and the device is visible to the kernel, as above.
However you are working "rootless" and thus cannot e.g. "sudo kpartx -a", you can't do that.
You could pass offsets to "wipefs --offset=$((1024*1024)) /tmp/dummy.img", but that's an error-prone pain.

PS: on rereading the manpage, it sounded like maybe --force also meant
--recursive, but I tested that and it didn't DWIM:

    <resetting everything to initial state>

    root@dban:~# blkid
    /dev/vda: TYPE="squashfs"
    /dev/vdb1: LABEL_FATBOOT="ESP" LABEL="ESP" UUID="C8A7-56D5" BLOCK_SIZE="512" TYPE="vfat" PARTLABEL="ESP" PARTUUID="fdbd4fa2-079b-4a2b-930d-98afded"
    /dev/vdb2: LABEL="root" UUID="4f6d7a44-6274-40df-945f-9323c5be3ae9" BLOCK_SIZE="1024" TYPE="ext4" PARTLABEL="root" PARTUUID="0af92335-b840-4e69-b0"

    root@dban:~# wipefs -fa /dev/vdb
    /dev/vdb: 8 bytes were erased at offset 0x00000200 (gpt): 45 46 49 20 50 41 52 54
    /dev/vdb: 8 bytes were erased at offset 0x0c1ffe00 (gpt): 45 46 49 20 50 41 52 54
    /dev/vdb: 2 bytes were erased at offset 0x000001fe (PMBR): 55 aa

#995904#10
Date:
2021-10-15 16:42:27 UTC
From:
To:
Hello Trent W. Buck,

* Trent W. Buck <trentbuck@gmail.com> [211008 04:36]:
[..]

Thank you for your bug report. However I am not sure what exactly
you are asking for. If its a new feature you are asking for, or a
design change, please discuss it on the upstream mailing list:

      E-MAIL:  util-linux@vger.kernel.org
      URL:     http://vger.kernel.org/vger-lists.html#util-linux
      ARCHIVE: https://lore.kernel.org/util-linux/

I imagine upstream or other upstream contributors will have ideas
then.

Please reply with a link to the upstream discussion once this has
been discussed.

Thanks,
Chris