You can do so by first mounting your partitions to /dev/loop?
using losetup
with the -o
option to specify a suitable offset to your partition. The offset can be calculated based on the output of fdisk -l disk.img
(start_sector * sector_size
).
For example:
losetup -o32256 /dev/loop1 ./disk.img # mount first partition
Once mounted, you can then proceed to format the partition using mkfs.*
:
mkfs.vfat -F32 /dev/loop1
For more details and examples, see the following articles: