I have a program which creates partitions and filesystems on a disk. To test it, I have created an image file:
dd if=/dev/zero of=disk.img bs=1M count=100
and mounted:
sudo losetup /dev/loop0 disk.img
The partitioning process seemingly works, I get an error from mkfs:
mkfs.vfat: unable to open /dev/loop0p2: No such file or directory
I can see the partitions with fdisk -l:
sudo fdisk -l /dev/loop0
Disk /dev/loop0: 1000 MiB, 1048576000 bytes, 2048000 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: B2CB131D-0091-4102-89E1-1D94EC49484A
Device         Start     End Sectors  Size Type
/dev/loop0p1    2048   10239    8192    4M BIOS boot
/dev/loop0p2   10240  272383  262144  128M EFI System
/dev/loop0p3  272384 1320959 1048576  512M Linux swap
/dev/loop0p4 1320960 2047966  727007  355M Linux filesystem
but not with lsblk:
sudo lsblk
NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
loop0    7:0    0  1000M  0 loop 
sda      8:0    0 465,8G  0 disk 
├─sda1   8:1    0   512M  0 part /boot/efi
├─sda2   8:2    0 457,3G  0 part /
└─sda3   8:3    0     8G  0 part [SWAP]
What am I doing wrong?
losetup --partscan? kernel / distro version?