Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I tell you my problem: I want to create a FAT file system and save it into a file so I can mount it in linux using something like:

sudo mount -t msdos <file> <dest_folder>

Maybe I'm wrong and this cannot be done.

Anyway, the problem is this: I'm trying to create the file containing a FAT file system, and I'm running this command:

sudo mkfs.vfat  -F 32 -r 112 -S 512 -v -C "test.fat" 100

That, accordingly to the mkfs man page, will create a FAT32 file system with 112 rootdir entries, logical sector size of 512 bytes, 100 blocks in total, and save it into "test.fat".

But it fails, and the bash tells me:

mkfs.vfat: unable to create test.fat

What is going on? I think I am misunderstanding how mkfs works and how to use it. It is possible to write a filesystem into a file?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

You have a file of 0 bytes in size. You can only create a filesystem on a file that has a specified size.

Here is how to do it properly:

  1. dd if=/dev/zero of=fat.fs bs=1024 count=SIZE how big do you want the filesystem; specify it as SIZE * 1024.
  2. mkfs.vfat fat.fs formats the file as the filesystem FAT.
  3. mount -o loop fat.fs /mnt mounts fat.fs to /mnt.
share|improve this answer
    
Thank you josten, I didnt know about the first step. Now I can create the file and mount it :) –  RubenT Nov 1 '13 at 23:57
    
Glad I could help. –  josten Nov 2 '13 at 0:58

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.