I need to create filesystem with just one partition from nothing (/dev/zero).
I tried this sequence of commands:
dd if=/dev/zero of=mountedImage.img bs=512 count=131072
fdisk mountedImage.img
n
p
2048
131072
Basically, I need to create 64MB image file filled with zeroes. Then I use fdisk to add a new partition for new filesystem (which should finally be FAT32), starting at sector 2048 and using all remaining sectors.
losetup /dev/loop1 mountedImage.img
mkfs -t vfat /dev/loop1
But here I'm hitting problems. If I set up a loop device and format it using mkfs -t vfat, partition table is overwritten and filesystem (FAT32) is placed to disk. I don't need whole disk formatted with FAT32, I just need my primary partition to be so.
Does anybody know how can I format only one partition of raw disk image, not whole image?