How can I clone an adopted SD card?
Try the following

first copy sd.img to new MicroSD Card (it will finish unsucessful &quot;error writing, not enough space&quot;)

create another sd2.img from new MicroSD Card (the one which ended unsucessful, we just need raw sd2.img with correct size)

run kpartx to map sd.img into /dev/mapper/loop1p1, /dev/mapper/loop1p2 and sd2.img into /dev/mapper/loop2p1, /dev/mapper/loop2p2 (may vary)

create two new block devices for /dev/mapper/loop1p2 and /dev/mapper/loop2p2 (see link in your question)

now lets assume /dev/mapper/loop1p2 is /dev/mapper/crypt1 (= sd.img) and /dev/mapper/loop2p2 is /dev/mapper/crypt2 (= sd2.img)

crypt1 should be mountable as ext4 partition to any mount point (that's your old MicroSD Card)

crypt2 is probably broken because of less size and must be formatted with mke2fs
mke2fs -t ext4 /dev/mapper/crypt2

now crypt2 should be mountable as ext4 too, mount to another mount point

next, copy all files from one mount point to another. make sure you preserve secontext, xattrs, uid and file permissions. this can be done with busybox cp -ac or tar --selinux --xattrs -p


i am on mobile and busy today, will improve that answer later. btw i am not sure that's how it works at all (the dmsetup part)
good luck