I need to create a disk image with two empty file systems. I have created it using
dd if=/dev/zero of=./disk.img bs=1MiB count=1024
Next, I have created 2 primary partitions using
fdisk disk.img; one is FAT32 and other is EXT3. Now, I have to format both partitions in order to create file-systems to be mounted as
-o loop devices. But I can't understand how to format them? I can't use
disk.img. So I am totally confused.
SOLUTION: Thanks to answer from @pjc50 I found very simple solution:
sudo aptitude install multipath-tools sudo kpartx -a disk.img #it maps (mounts) found partitions to /dev/mapper/loop... sudo mkfs.vfat -F 32 -n boot /dev/mapper/loop0p1 sudo mkfs.ext3 -L rootfs /dev/mapper/loop0p2
A drawback of this solution is requirement of superuser rights.