#948125 Please use partx (in essential util-linux) rather than kpartx

Package:
vmdb2
Source:
vmdb2
Submitter:
Josh Triplett
Date:
2021-08-19 15:12:04 UTC
Severity:
normal
Tags:
#948125#3
Date:
2020-01-04 10:55:00 UTC
From:
To:
vmdb2 depends on the kpartx package; could it, instead, use partx from
the essential util-linux package?

#948125#8
Date:
2020-08-09 07:33:36 UTC
From:
To:
On Sat, Jan 04, 2020 at 02:55:00AM -0800, Josh Triplett wrote:
vmdb2 depends on the kpartx package; could it, instead, use partx from
figure out how to replace kpartx with it. If you can show me how to do
that, I'd be happy to make the changes to vmdb2 to use partx and to
drop the kpartx dependency.

#948125#13
Date:
2020-10-01 20:37:47 UTC
From:
To:
partx and kpartx have very similar functionality, just different output.

It looks like you're currently using kpartx to tell the kernel to add
and delete partition devices; you're also parsing the output to see what
device was created.

kpartx output looks like this:
add map loop0p1 (254:1): 0 10483679 linear 7:0 2048
And you're using the third word as the device name.

partx (with the -v option) writes output like this:

partition: none, disk: debian.img, lower: 0, upper: 0
Trying to use '/dev/loop0' for the loop device
/dev/loop0: partition table type 'gpt' detected
range recount: max partno=1, lower=0, upper=0
/dev/loop0: partition #1 added

That's not quite as trivial to parse, but you could look for lines that
match `^\(/dev/[^:]*\): partition #\([0-9]*\) added$`, and construct the
device name as match 1 + "p" + match 2.

#948125#18
Date:
2021-08-19 15:08:20 UTC
From:
To:
#948125#23
Date:
2021-08-19 15:08:20 UTC
From:
To: