Allow specifying a partition or an offset with an image file
Brought to you by:
henca
Would it be possible to allow specifying a partition or offset? Then I could create a raw image file for a virtual machine, first write the mbr, then the bootsector on the first partition and then use mcopy to copy the files to it.
This is possible with floppies already, but it would be nice to have it with harddisk images as well.
Thanks in advance!
Adding support to specify a partition from an image file would require rather big new functionality in ms-sys, needing to parse different kinds of partition tables.
Adding support for offset would require rather deep knowledge from the user, the wrong offset could break the file system.
The easiest way to accomplish the thing you want to do today with an image file for a virtual machine is to boot your virtual machine from a live CD with ms-sys together with the image file. There are some links to such rescue CDs with ms-sys at http://ms-sys.sourceforge.net/ but there are also others to choose from. You could boot your virtual machine from an iso-file.
If you for some reason still would prefer to work with offsets it is also possible to work with partitions from disk image files by using dd to copy a partition from a disk image file to a file of its own, then use ms-sys on the partition image file and finally use dd again to copy the partition image back to the right position in the disk image. But again, this requires deep knowledge about offsets taken from the partition table of the image file.
I'd like to use this in a script. In my scenario I have a complete system in a directory which I'd like to put into a raw image file. I can already create this image file with qemu-img, create one partition with parted, format it with mtools, copy the files in there with mtools and set a valid mbr with ms-sys. I just need to put valid boot code on the first partition as well. The offset for the first partition should always be the same, so if there would be an offset option I could just add that to the script and I'm done.
I'm doing a lot of testing with DOSEMU2 now and sometimes it's not clear whether the issues I'm running into are due to DOSEMU or due to my installation. If I could have a script to quickly move a drive_c directory from DOSEMU into an image file suitable for VMs/emulators, that would make testing a lot easier.
Having to use a live CD to put just that boot code in place each time would make that a significant hassle.
If you feel convenient in handling offsets to your partition in an image file please add something like this to your script:
However I fear that adding this kind of functionality as a built in feature into ms-sys would result in support requests and angry mails about broken file systems.