mkfat - Create a FAT image from a directory

This forums is for OS project announcements including project openings, new releases, update notices, test requests, and job openings (both paying and volunteer).
Post Reply
jnc100
Member
Member
Posts: 775
Joined: Mon Apr 09, 2007 12:10 pm
Location: London, UK
Contact:

mkfat - Create a FAT image from a directory

Post 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:

Code: Select all

mkfat [-o image_name] directory
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.
Last edited by jnc100 on Thu Feb 13, 2014 11:15 am, edited 1 time in total.
User avatar
Brynet-Inc
Member
Member
Posts: 2426
Joined: Tue Oct 17, 2006 9:29 pm
Libera.chat IRC: brynet
Location: Canada
Contact:

Re: mkfat - Create a FAT image from a directory

Post 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.
Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.
jnc100
Member
Member
Posts: 775
Joined: Mon Apr 09, 2007 12:10 pm
Location: London, UK
Contact:

Re: mkfat - Create a FAT image from a directory

Post 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.
User avatar
Brynet-Inc
Member
Member
Posts: 2426
Joined: Tue Oct 17, 2006 9:29 pm
Libera.chat IRC: brynet
Location: Canada
Contact:

Re: mkfat - Create a FAT image from a directory

Post 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!
Image
Twitter: @canadianbryan. Award by smcerm, I stole it. Original was larger.
mduebon
Posts: 1
Joined: Tue Apr 25, 2017 1:04 am

Re: mkfat - Create a FAT image from a directory

Post 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
Post Reply