OSDev.org
https://forum.osdev.org/

mkfat - Create a FAT image from a directory
https://forum.osdev.org/viewtopic.php?f=2&t=27721
Page 1 of 1

Author:  jnc100 [ Mon Feb 10, 2014 5:05 pm ]
Post subject:  mkfat - Create a FAT image from a directory

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

Author:  Brynet-Inc [ Mon Feb 10, 2014 7:58 pm ]
Post subject:  Re: mkfat - Create a FAT image from a directory

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.

Author:  jnc100 [ Thu Feb 13, 2014 11:14 am ]
Post subject:  Re: mkfat - Create a FAT image from a directory

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.

Author:  Brynet-Inc [ Thu Feb 13, 2014 1:30 pm ]
Post subject:  Re: mkfat - Create a FAT image from a directory

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!

Author:  mduebon [ Tue Apr 25, 2017 1:15 am ]
Post subject:  Re: mkfat - Create a FAT image from a directory

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

Page 1 of 1 All times are UTC - 6 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/