Bochs is an open source PC (x86) emulator that runs on a variety of platforms, including GNU/Linux and Mac OS X. One of the first things that you need to do to get started is to create a disk image. There is a utility that comes with Bochs, that does much of the work for you called bximage. Simply run it, and answer the questions:
srv-5:/Applications/Bochs-2.1.1-Carbon usr4$ ./bximage ======================================================================== bximage Disk Image Creation Tool for Bochs $Id: bximage.c,v 1.19 2003/08/01 01:20:00 cbothamy Exp $ ======================================================================== Do you want to create a floppy disk image or a hard disk image? Please type hd or fd. [hd] What kind of image should I create? Please type flat, sparse or growing. [flat] Enter the hard disk size in megabytes, between 1 and 32255  500 I will create a 'flat' hard disk image with cyl=1015 heads=16 sectors per track=63 total sectors=1023120 total size=499.57 megabytes What should I name the image? [c.img] Writing:  Done. I wrote 523837440 bytes to c.img. The following line should appear in your bochsrc: ata0-master: type=disk, path="c.img", mode=flat, cylinders=1015, heads=16, spt=63
Follow the instructions and put the above line in your Bochs rc script (usually bochsrc, but it might also be bochsrc.txt. If you want to initialize this correctly for Windows, it is probably best to initialize the partitions within the emulator. Here is how to initialize the above image for an ext2 filesystem:
[root@srv-1 usr-1]# /sbin/fdisk c.img last_lba(): I don't know how to handle files with mode 81a4 Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel Building a new DOS disklabel. Changes will remain in memory only, until you decide to write them. After that, of course, the previous content won't be recoverable. You must set cylinders. You can do this from the extra functions menu. Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite) Command (m for help): x Expert command (m for help): h 16 Number of heads (1-256, default 255): 16 Expert command (m for help): s Number of sectors (1-63, default 63): 63 Warning: setting sector offset for DOS compatiblity Expert command (m for help): c Number of cylinders (1-1048576): 1015 Expert command (m for help): r Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): 1 First cylinder (1-1015, default 1): Using default value 1 Last cylinder or +size or +sizeM or +sizeK (1-1015, default 1015): Using default value 1015 Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. WARNING: Re-reading the partition table failed with error 25: Inappropriate ioctl for device. The kernel still uses the old table. The new table will be used at the next reboot. Syncing disks. [root@srv-1 usr-1]# [root@srv-1 usr-1]# /sbin/fdisk -l -u c.img last_lba(): I don't know how to handle files with mode 81a4 You must set cylinders. You can do this from the extra functions menu. Disk d.img: 0 MB, 0 bytes 16 heads, 63 sectors/track, 0 cylinders, total 0 sectors Units = sectors of 1 * 512 = 512 bytes Device Boot Start End Blocks Id System d.img1 63 1023119 511528+ 83 Linux [root@srv-1 usr-1]# /sbin/losetup -o 32256 /dev/loop0 d.img
The offset (-o) is 512*63=32256.
[root@srv-1 usr-1]# /sbin/mkfs /dev/loop0 mke2fs 1.35 (28-Feb-2004) Filesystem label= OS type: Linux Block size=1024 (log=0) Fragment size=1024 (log=0) 128016 inodes, 511528 blocks 25576 blocks (5.00%) reserved for the super user First data block=1 Maximum filesystem blocks=67633152 63 block groups 8192 blocks per group, 8192 fragments per group 2032 inodes per group Superblock backups stored on blocks: 8193, 24577, 40961, 57345, 73729, 204801, 221185, 401409 Writing inode tables: done Writing superblocks and filesystem accounting information: done This filesystem will be automatically checked every 22 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override. [root@srv-1 usr-1]#
For more information on transferring data to the image, see this article.