Page 1 of 1

Creating and writing to hd and fd images

Posted: Wed May 05, 2004 11:09 am
by newguy
Hi! Does anybody know how I can write and format a disk image created with the bochs disk image creation tool?

Re:Creating and writing to hd and fd images

Posted: Wed May 05, 2004 11:36 am
by Schol-R-LEA
That depends on what you mean to write to it, but assuming you mean to copy a boot image into the disk image's sector 0, any raw-writing utility should do the trick; some debuggers will do this as well. Under Windows, you can use the DOS DEBUG utility, or any of several tools such as RawWrite or partcopy; I find partcopy to be the most useful, but it's a matter of personal preference. Under Unix and Linux, you can use the dd(1) utility for this. See this thread for more details.

Re:Creating and writing to hd and fd images

Posted: Wed May 05, 2004 11:39 am
by newguy
But how do you write to a non-physical disk with debug? I know how to do it with real floppys, but with an image?

Re:Creating and writing to hd and fd images

Posted: Wed May 05, 2004 11:39 am
by srg
I managed to use partcopy to take my test machine's 850MB hard disk and make an image file of it that just ran on bochs first time.

Very nice, although I had a bit of trouble getting the drive size perfectly correct. Win2k said that is was 815MB when it was 814MB (formatted capacity).

srg

Re:Creating and writing to hd and fd images

Posted: Wed May 05, 2004 11:40 am
by Neuromancer
Do you mean a hard disk image?

Bochs needs to have a hard disk image which contains both MBR and the partitions.
You need to have 2 separated files, the MBR part and the partition.

First of all, create the disk image with bximage.
The fdisk it and set a partition, set the partition type flags and save it to the image.
Then you have to separate the MBR part and the partition. MBR is AFAIK 63 sectors long.
To separate them you can use "dd if=image.bin of=mbr.bin count=63" to create the MBR image and then "dd if=image.bin of=partition.bin skip=63" to create the partition.
Format the partition file with your file system tools (i.e. mke2fs partition.bin).
Now you can mount the partition.bin and copy the files on it.

You need to re-create the disk image to run it on bochs. Type "cat mbr.bin partition.bin > image.bin" et voil?, the image is ready.

Re:Creating and writing to hd and fd images

Posted: Wed May 05, 2004 11:49 am
by newguy
Thanks. But I am using windows xp, because linux doesn't support my wireless card(I have used linux, though, throug a lan-connection wih my notebook.)And, for the beginnig I want to edit a floppy-image.

Re:Creating and writing to hd and fd images

Posted: Wed May 05, 2004 11:51 am
by Neuromancer
And, for the beginnig I want to edit a floppy-image.
;D Sorry.

I don't know how to do this on Window$. :-\

Re:Creating and writing to hd and fd images

Posted: Wed May 05, 2004 11:55 am
by DennisCGc
MBR is AFAIK 63 sectors long.
Not entirely true, the MBR is 1 sector, but it's used to begin on the next track, so it's going to take (depending on your logical HD geo)64*63 = 4032 sectors :o .
And not 63 sectors ;) as you claim.

Re:Creating and writing to hd and fd images

Posted: Wed May 05, 2004 12:04 pm
by srg
Neur0m'ancer wrote: Do you mean a hard disk image?

Bochs needs to have a hard disk image which contains both MBR and the partitions.
You need to have 2 separated files, the MBR part and the partition.

First of all, create the disk image with bximage.
The fdisk it and set a partition, set the partition type flags and save it to the image.
Then you have to separate the MBR part and the partition. MBR is AFAIK 63 sectors long.
To separate them you can use "dd if=image.bin of=mbr.bin count=63" to create the MBR image and then "dd if=image.bin of=partition.bin skip=63" to create the partition.
Format the partition file with your file system tools (i.e. mke2fs partition.bin).
Now you can mount the partition.bin and copy the files on it.

You need to re-create the disk image to run it on bochs. Type "cat mbr.bin partition.bin > image.bin" et voil?, the image is ready.

Actually, the MBR is only 1 sector (512 bytes) is size. The rest of that region before the first partition wasn't used. Well, saying that, things like EZ-Drive or Ontrack Disk Manager, known as Dynamic Drive Overlay software and some viruses used it (a bit of a loophole!).

hope this helps!
srg

Re:Creating and writing to hd and fd images

Posted: Wed May 05, 2004 12:23 pm
by DennisCGc
newguy wrote: Thanks. But I am using windows xp, because linux doesn't support my wireless card(I have used linux, though, throug a lan-connection wih my notebook.)And, for the beginnig I want to edit a floppy-image.
Use Winimage :)
Just search on google and you'll find it ;D

Re:Creating and writing to hd and fd images

Posted: Wed May 05, 2004 11:06 pm
by newguy
Thank you very much! WinImage is great! Thanks for posting y'all.