Page 1 of 1
mkfat - Create a FAT image from a directory
Posted: Mon Feb 10, 2014 5:05 pm
by jnc100
I ran into a small problem when playing around with UEFI in that a FAT filesystem image is required. This can be problematic on some systems (e.g. Windows) where a loopback device is not possible (yes I know there are other ways with virtual disks etc), and is even a problem on e.g. linux as loopback devices need superuser privileges. So I went looking for a utility to create a FAT image from a directory in the current filesystem (in the same way that mkisofs creates a ISO9660 volume from a directory) but couldn't find one, so wrote this utility instead.
I release it here in the hope it is useful. MIT licensed.
It is based upon
fatfs and will build with g++ on a system with the Boost libraries. Usage is simple:
to create 'image_name' from 'directory' (or can output to stdout if -o not specified).
Download
pre-alpha, no warranty etc. Please report bugs/feature requests.
Regards,
John.
Re: mkfat - Create a FAT image from a directory
Posted: Mon Feb 10, 2014 7:58 pm
by Brynet-Inc
The traditional way to handle DOS/FAT filesystems on Unix is with
mtools.
It seems to be reinvented often, someone else posted a similar utility here a few months ago.
Re: mkfat - Create a FAT image from a directory
Posted: Thu Feb 13, 2014 11:14 am
by jnc100
Brynet-Inc wrote:The traditional way to handle DOS/FAT filesystems on Unix is with
mtools.
Yes, I used to use mtools, however it has certain limitations for the particular task I was trying to do, namely create a reasonably large (~30 MiB) hard drive image for use with UEFI. Namely, it requires: 1) a way of creating a file of a particular size (e.g. dd), 2) knowing in the first place how big the file needs to be (which has to be hard wired into the build script or calculated with complex shell trickery), 3) need to supply the geometry of any non-standard disk (i.e. anything which isn't a floppy) and 4) the need for 'mtools_skip_check=1' in a ~/.mtoolsrc file on the users system for anything non-standard. As I am trying to have my build script work automatically on most systems (unix + windows), these limitations were becoming a bit of a headache, and so I created this instead.
tl;dr yes, there are other tools which work just as well in many situations. This is provided if anyone needs it.
Regards,
John.
Re: mkfat - Create a FAT image from a directory
Posted: Thu Feb 13, 2014 1:30 pm
by Brynet-Inc
For such a simple utility, all the dependencies seem to be a bit overkill. No?
C++, fatfs.. and Boost?
The license for the FAT library appears to be permissive, but custom.. and surprisingly difficult to find, being stashed in a DOS formatted 00readme.txt file.
Regardless though, good luck with your project!
Re: mkfat - Create a FAT image from a directory
Posted: Tue Apr 25, 2017 1:15 am
by mduebon
Hello John,
I have a question about fatfs and I guess you could point me in the right direction.
I have several partitions on a SD card, let's say partition A (e.g. user data) and partition B (e.g. read only data). I am trying to find out if it is possible to replace the partition A with an FatFs image (e.g. created with your tool). My idea is to update the complete user data by providing just one (image) file.
regards
Matthias