I'm trying to follow the script in https://jvns.ca/blog/2021/01/27/day-47--using-device-mapper-to-manage-firecracker-images/?hmsr=joyk.com&utm_source=joyk.com&utm_medium=referral but getting an error. To diagnose my understanding of devicemapper, I tried to construct a plain passthrough, but it's not working.
BASEIMAGE=hello-rootfs.ext4
LOOP=$(sudo losetup --find --show --read-only $BASEIMAGE)
$ # mounting the loop device works correctly
$ mkdir -p mnt
$ sudo mount "$LOOP" mnt
$ # prints "bar", as expected for this filesystem
$ sudo ls mnt/root
> bar
$ sudo umount mnt
$ # try creating a passthrough via devicemapper
$ printf "0 `sudo blockdev --getsz $LOOP` linear $LOOP 0" | sudo dmsetup create mybase
$ sudo mount /dev/mapper/mybase mnt
> mount: /home/od/vm1/mnt: can't read superblock on /dev/mapper/mybase.
as you can see, the loopback device mounts normally, but when it goes through the devicemapper, suddenly the superblock can't be read.
Why is that? The devicemapper setup should be mapping 0 -> sizeof(loop device) to 0 -> sizeof(loop device) on the loop device. That seems like it should be a passthrough.
Is devicemapper doing something else in between?