Format a disk image as MS-DOS?
I have a bootable flash drive that boots one of my favorite DOS-based bootdisks. However, if I use dd to make an image of the disk, it also copies over the free space, which is not what I intended. So, I decided to try to mount a hard disk image and my existing USB image under qemu (so I an copy the files from my bootable USB image to my new hard drive image.
OK. I'm trying to make a hard disk image that is able to boot into DOS. OK, here's what I've tried (keep in mind, I really don't know what I'm doing): 1) I'm working with a RAW disk image created with qemu-img as I don't know how to resize an existing disk image. The image is 77M. I used the command: qemu-img -f raw disk.img 77M 2a) I've tried this so many ways and the drive image will never boot in qemu. I've tried booting into FreeDOS, but using the SYS command installs the Syslinux bootloader and files, which is not what I need to use. I need to use the original DOS loader and files - I have the files from a boot disk which should be all I need as I understand. I've set up the drive in FreeDOS, but I don't see a way to make it bootable. 2b) I've used `ms-sys -d -f disk.img` to install what I believe is the proper MBR and then used the CFDISK utility in FreeDOS to set up the partitions and then the FORMAT C: (the disk image under qemu) to format the partition as a DOS partition. I then copied the files from my usable/bootable usb image. I've tried many other methods that I can't think of at the moment. I'm starting to get extremely frustrated at this. I need a quick and dirty solution if it's possible, but I'm willing to try anything. Githlar |
2c) Oh, I also tried extracting the MBR of my bootable USB drive with FDISK in FreeDOS and replacing the C: drive's (the disk image I'm trying to manipulate) MBR, but that didn't work either.
|
I must confess that I can't really follow your explanation and I don't have experience with qemu. For what it is worth, here is a link for a thorough explanation of the dd command, I hope it can help:
http://www.linuxquestions.org/questi...d.php?t=362506 |
I figured it out. It's about time haha.
I had tried this: dd if=/dev/sdc of=mbr bs=512 count=1 dd if=/dev/sdc1 of=partition1 cat mbr partition1 > finalimage.img But that didn't work. I found out later that it was looking for the partition on sector 63, and after using the above commands, the final result was the partition was on sector 2. Of course, that caused problems =) So, I just copied the disk from sector 1 straight to the end of the partition I wanted to keep: dd if=/dev/sdc of=smallerdisk.img bs=512 count=[end sector] That worked =) |
Glad you solved it. Still, you might want to have a look at the link I posted above in a quiet moment. Exactly your difficulty is treated there. Good luck.
|
Perhaps I haven't solved it. Now Memdisk is telling me that the image has a fractional last cylinder.
I think I have to set the c/h/s, but I don't know what it should be. Surely the cylinders shouldn't be the same number that's on my flash drive, because the file is not the same size? |
Perhaps the image has to be rounded off to the nearest cylinder.
Well, I did that and Memdisk doesn't complain about the image anymore, however it does still hang right after it says its booting. "Loading boot sector... booting... j" That 'j' is what throws me. That's what was showing up sometimes when the disk was not working. That is the output under both Qemu and the actual output from booting. But that's also really odd, because using Qemu, the image itself boot, but when it's run as an argument to Memdisk, it fails. Here's the full output of Memdisk: Quote:
|
Probably unhelpful, but it says exactly: "97440 K", which is to my mind about 97 M ... :D ;)
As already said I have no experience with qemu... |
Well. I think my problem was that it was a hard disk image. I had the MBR and boot record set all correctly on it, but something still went wrong.
So, I had to make a way oversized floppy image of the partition basically. Here's how I did it: 1. Download a 1.44MB floppy image of some boot disk and the mkfloppyimg.sh script from http://people.cs.uchicago.edu/~gmura...downloads.html 2. Modify the necessary values in mkfloppyimg.sh and run it. You should now end up with an oversized image formatted as a floppy with all of the files of the original boot disk as well as the C/H/S values. Very cool. Make note of that command line given to you. 3. Mount the floppy image: Code:
losetup /dev/loop0 oversizefloppy.img 5. Unmount: Code:
umount /mnt/point syslinux.cfg: Code:
LABEL test That sure was a helpful script. It took me long enough to find it though haha *Literally has about 50 Firefox tabs open*. That was the part I was having problems with: getting a correct CHS values to pass to memdisk. I wonder if I could use those values I got from mkfloppyimg.sh and use them on my hard disk image... |
I got it to boot, but the io.sys file is different than the one I need, and when I try to inject it using a hex editor, dd, and cat, it doesn't like it very much haha.
|
Quote:
|
Well, the BootCD I'm using has a custom edited IO.SYS. I found that I can boot into DOS on the CD and use the SYS command to write that custom IO.SYS to a bootable floppy. However, now that script I mentioned above doesn't work. I need to find out where the size info is on the floppy image so I can leave it out when I copy it to the bigger floppy image.
|
All times are GMT -5. The time now is 12:35 AM. |