Package: util-linux
Version: 2.36.1-8
Severity: wishlist
File: /sbin/wipefs

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



-- System Information:
Debian Release: 11.0
  APT prefers stable-updates
  APT policy: (990, 'stable-updates'), (990, 'stable-security'), (990, 
'stable'), (500, 'proposed-updates'), (500, 'unstable'), (500, 'testing'), (1, 
'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 5.10.0-8-amd64 (SMP w/8 CPU threads)
Kernel taint flags: TAINT_PROPRIETARY_MODULE, TAINT_OOT_MODULE, 
TAINT_UNSIGNED_MODULE
Locale: LANG=en_AU.UTF-8, LC_CTYPE=en_AU.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages util-linux depends on:
ii  libaudit1      1:3.0-2
ii  libblkid1      2.36.1-8
ii  libc6          2.32-4
ii  libcap-ng0     0.7.9-2.2+b1
ii  libcrypt1      1:4.4.18-4
ii  libmount1      2.36.1-8
ii  libpam0g       1.4.0-9
ii  libselinux1    3.1-3
ii  libsmartcols1  2.36.1-8
ii  libsystemd0    247.3-6
ii  libtinfo6      6.2+20201114-2
ii  libudev1       247.3-6
ii  libuuid1       2.36.1-8
ii  login          1:4.8.1-1
ii  zlib1g         1:1.2.11.dfsg-2

util-linux recommends no packages.

Versions of packages util-linux suggests:
ii  dosfstools          4.2-1
ii  kbd                 2.3.0-3
ii  util-linux-locales  2.36.1-8

-- no debconf information

Reply via email to