this script attempts to do the following for
img=working.img device=/dev/working0
img=broken.img device='/dev/broken 0'
- create a file $img
- partition it with sfdisk
- losetup a device pointing to $img
- kpartx -a -v -p -part $LODEV
run the script and you can see, it will work for 'working0' and fail for 'broken 0'
$ sudo ./show
=== img=working.img devname=/dev/working0 lodev=/dev/loop1 ===
add map working0-part1 (252:0): 0 202752 linear /dev/working0 2048
=== 0 ==
brw-rw---- 3 root disk 7, 1 Jun 3 20:46 /dev/working0
=== img=broken.img devname=/dev/broken 0 lodev=/dev/loop0 ===
device-mapper: reload ioctl on broken\x200-part1 failed: Invalid argument
create/reload failed on broken 0-part1
add map broken 0-part1 (0:0): 0 202752 linear /dev/broken 0 2048
=== 1 ==
brw-rw---- 2 root disk 7, 0 Jun 3 20:46 /dev/broken 0
failed kpartx to /dev/broken 0
that is basically the same way the multipath-boot setup fails.
this script attempts to do the following for /dev/working0
img=working.img device=
img=broken.img device='/dev/broken 0'
- create a file $img
- partition it with sfdisk
- losetup a device pointing to $img
- kpartx -a -v -p -part $LODEV
run the script and you can see, it will work for 'working0' and fail for 'broken 0'
$ sudo ./show /dev/working0 lodev=/dev/loop1 ===
=== img=working.img devname=
add map working0-part1 (252:0): 0 202752 linear /dev/working0 2048
=== 0 ==
brw-rw---- 3 root disk 7, 1 Jun 3 20:46 /dev/working0
=== img=broken.img devname=/dev/broken 0 lodev=/dev/loop0 ===
device-mapper: reload ioctl on broken\x200-part1 failed: Invalid argument
create/reload failed on broken 0-part1
add map broken 0-part1 (0:0): 0 202752 linear /dev/broken 0 2048
=== 1 ==
brw-rw---- 2 root disk 7, 0 Jun 3 20:46 /dev/broken 0
failed kpartx to /dev/broken 0
that is basically the same way the multipath-boot setup fails.