This happens to be one of the most asked questions here. A FAQ in fact.
First, did you see
https://wiki.osdev.org/Disk_Images?
One of the first things an OS Developer must do is create a disk image on some form of bootable media. To do so, he/she must understand the media as well as, and more importantly, the file system or storage array of the media. Where is my boot code? Where is my second stage code? Where is my kernel? etc.
Another very important part of media creation is how long and how difficult is it to change a file upon that media? For example, I have created my boot code, second/third/etc stage loader code, my kernel code, and some drivers, and have put them all on my media (which could simply be a hard drive image on the local host machine). However, I have made a simple change to the X-stage loader code and need to update the image file. Do I need to recreate the whole image or just the file in question? How many utilities do I need to do so?
Lots of questions.
So, here are a few solutions:
1) You need to following utilities to create/modify a FAT hard drive image:
a) A utility to create an empty image
b) A utility to create an empty FAT image on that image (format)
c) A utility to copy files to that formatted image
Utilities a) and b) can be combined as one if needed.
Now, when you make a modification to one of the files on the hard drive image, you only need utility c).
There are many utilities already created for this, or you can create your own.
I have created many myself, specifically for my specific needs. An older version of this set is at
http://www.fysnet.net/mtools.htm, it comes with source code and hopefully can be mostly portable. I targeted Window XP since that is my development platform.
Those whom have a copy of one of my books, specifically Volumes 1 and 2 (
http://www.fysnet.net/osdesign_book_series.htm), also have more detailed and updated utilities to do this.
For example, my current work involves a FAT12 image for testing and I use the mkdosfs utility from the latter URL above.
For your question, as far as placing Grub on that image, there are utilities, including the GRUB utility itself (I presume) that will do this.
Ben
-
http://www.fysnet.net/osdesign_book_series.htm
P.S. I am not a Linux user, though I have dabbled with it on occasion, though I have found that you don't need full access to the host development machine, i.e.: sudo, to simply modify an image file and execute an emulator, do you?