Hi! I have the following issue with busybox: $ busybox losetup /dev/loop0 /dev/sda $ busybox partprobe /dev/loop0 partprobe: /dev/loop0: Invalid argument While partprobe from libparted works fine. Additionally, `losetup -P /dev/loop0 /dev/sda` from util-linux also works fine; if `busybox losetup` supported -P, it would solve the problem. I think the reason for this issue is stated in https://git.kernel.org/pub/scm/utils/util-linux/util-linux.git/tree/lib/loopdev.c#n899 > - kernels >= 3.2 enable PT scanner only if max_part= is non-zero or if the > LO_FLAGS_PARTSCAN flag is set for the device. The PT scanner is disabled > by default. So, `losetup -P` could set LO_FLAGS_PARTSCAN and solve the issue. As a workaround, I'm currently using `modprobe loop max_part=9`, when loop isn't built-in to the kernel, and `loop.max_part=9` in the kernel cmdline when it is. This indirectly re-enables the PT scanner, but this is a bad workaround, and not always easy to implement. Please allow busybox to handle loop devices with partitions without having to specify max_part.
This happens for blockdev too: $ busybox losetup /dev/loop0 /dev/sda $ busybox blockdev --rereadpt /dev/loop0 blockdev: /dev/loop0: Invalid argument And again the workaround works, i.e. it doesn't happen if `modprobe loop max_part=9` was used before those 2 commands.
commit 726cbb1be8620496cdf05d23bd98bdeb0983b4f0 Author: Jack O'Sullivan <jackos1998@gmail.com> Date: Tue May 28 15:28:27 2019 +0100 losetup: Add partition scanning option Add -P option from util-linux losetup to scan for partitions.
losetup -P was implemented this May. This does not solve partprobe / blockdev --rereadpt examples (in busybox, they both boil down to calling ioctl(BLKRRPART)) - from what I see in strace, partprobe from GNU parted 3.2 does not use this ioctl at all, it does some complicated magic with newer APIs designed to set up arbitrary pertitioning schemes from userspace without having kernel to know anything about partition tables. "blockdev --rereadpt" does not work for util-linux's blockdev as well, since it also simply calls ioctl(BLKRRPART). IOW: "losetup -P" issue is fixed, "extend partprobe" issue is a significantly taller order.
When I saw your commit link in Comment #2, it took me a while to realize how you were able to solve the issue 10 days before the bug report! :) `losetup -P` is more than enough, thank you very much.