I need to create an img disk image (using mkfs.fat) that will contain only one file. I know I need to do this:

dd if=/dev/zero of=disk.img bs=1 count=SIZE
mkfs.fat disk.img
sudo mkdir /tmp/bla
sudo mount -o loop disk.img /tmp/bla
cp myfile /tmp/bla
sudo umount /tmp/bla
sudo rmdir /tmp/bla

My question is, how do I determine SIZE so that the disk.img is just big enough to hold myfile?

Also, is there a way to avoid using sudo?

  • 3
    Why not just transport the file rather than an image containing the file? – DopeGhoti May 2 '17 at 22:46
  • 1
    ... or use trial and error. Your should need at least 700MB as a minimum; as per the actual size, your are not giving us enough data. – Rui F Ribeiro May 2 '17 at 22:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.