Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
I'm trying to create a blank disk image with a single FAT32 partition in Ubuntu (to test my bootloader). None of the instructions I can find online seem to work. It fails when trying to mount the image. Here's the code I use to create it:
singerng wrote:I'm trying to create a blank disk image with a single FAT32 partition in Ubuntu (to test my bootloader). None of the instructions I can find online seem to work. It fails when trying to mount the image. Here's the code I use to create it:
1. Use DD to create a raw disk image.
2. Using fdisk, create the necessary information.
3. Using DD again, use [count] and [skip] on the disk image to create an MBR.img and a fs.img. You'll want the MBR image to be somewhere between 63 and 2047 sectors long. The fs.img should skip over this amount.
4. Create the FS (FAT/EXT whatever) on fs.img.
5. Using cat, [cat mbr.img fs.img > disk.img]
That should work. It works for a GRUB/GRUB2 install, so by any means it should work for your purposes.
Again, this is what works for me, I'm simply trying to offer something useful here.
I'm not exactly clear on what I'm supposed to be doing, but isn't this basically what I did? The loopback device (/dev/loop0) is basically the same as fs.img, isn't it?
singerng wrote:I'm not exactly clear on what I'm supposed to be doing, but isn't this basically what I did? The loopback device (/dev/loop0) is basically the same as fs.img, isn't it?
Oh, whoops, I didn't notice the offset flag. In that case... I know that this method definitely works under OS X, so I'm not sure what Linux is doing over here. I have in fact tried this on Ubuntu (12.04) before and it worked to my knowledge...
singerng wrote:Well, your technique worked ... I'm not sure why mine didn't!
Glad to be of service
Also, your first DD command looked a little weird with the extra 'c', although I do admit I didn't do the math.
It looks like your losetup command uses (2048*512) as an offset -- AFAIK, the first reserved sectors usually stretch to 2047 sectors.
IIRC Windows gives 63 sectors, most Unix utilities do 2047.