kpartx from within a python script as part of a custom OS build I'm trying to do. I'm using python
sh module to run bash commands.
sh.kpartx("-as", image) is how I attach my image.
Then I create partitions and a file system on each partition. Then ofcourse I unmount the image.
The problem is that in my script I use the above attach and detach commands a couple of times and with each time a new
/dev/loopX is used. I would expect that after I detach an image from let's say
/dev/loop0 on the next attachment I would be able to use it again. This is not the case however and
/dev/loop1 is used.
What is going on and why?