Currently, there are three popular full-virtualization PC Simulation Software Systems: VMware Workstation software of VMware, virtual PC of Microsoft, and bochs of open source code. These three types of software can be used to virtualize or simulate the intel X86 hardware environment, allowing us to run a variety of other "customer" operating systems on the system platform that runs these software.
The three simulation software are different in terms of scope of use and running performance. Bochs simulates the x86 hardware environment (CPU commands) and its peripheral devices, so it is easy to be transplanted to many operating systems or platforms with different architectures. Because of the main use of simulation technology, its operation performance and speed are much slower than the other two software. The performance of Virtual PC is between bochs and VMWare Workstation. It simulates most of the x86 commands, while others use virtual technology. VMware Workstation only simulates some I/O functions, while all other functions are directly executed on x86 real-time hardware. That is to say, when the customer's operating system requires to execute a command, VMWare does not simulate this command using a simulation method, but "passes" this command to the hardware of the actual system for completion. Therefore, VMWare has the highest running speed and performance among the three types of software.
From the application perspective, if the simulation environment is mainly used for application development, VMWare Workstation and Virtual PC may be a good choice. But if you need to develop some underlying system software (such as operating system development and debugging, compilation system development, etc.), bochs is a good choice. With bochs, you can know the specific status and exact sequence of the program in the simulation hardware environment, rather than the results of the actual hardware system execution. This is why many operating system developers prefer to use bochs.
OK. Let's talk nonsense.
My operating system is ubuntu10.10 64-bit (development code: maverickmeerkat ).
If you are using the Ubuntu operating system, run the following command to install bochs:
$sudo apt-get install vgabios bochs bochs-x bximage
Enter this line of command in the terminal, and the system will help you install it later.
This installation is easy, but there is a drawback that the default bochs installation has no debugging function. Oh my Lady Gaga, this will not work. So the best method is to install it from the source code.
Refer from bochs's official website.
The installation process is similar to this:
$tar vxzf bochs-2.4.5.tar.gz$cd bochs-2.4.5$./configure --enable-debugger --enable-disasm$make$sudo make install
Explain the above commands:
1. decompress the source code package bochs-2.4.5.tar.gz to generate a folder bochs-2.4.5;
2. Go to the bochs-2.4.5 directory;
3. Run the configure script to test your machine, C/C ++ compiler, and some libraries to determine which configuration is suitable for your machine. The command line parameter -- enable-debugger -- enable-disasm is used to enable the debugging function. After the configure script is successfully executed, a MAKEFILE file is generated in each source code directory;
4. Make compiles the entire bochs from the source code based on the MAKEFILE file generated in step 3;
5. After the whole bochs is compiled successfully, execute make install to copy the executable files, help files, and other necessary files of bochs to the corresponding directory of the system to run bochs. By default, some necessary files will be put in the following directory, which is subject to my installation directory:
Table 1
/Usr/local/bin/bochs |
Bochs Startup Program |
/Usr/local/bin/bximage |
Bochs built-in tool for creating disk image files |
/Usr/local/bxcommit |
Interactive tool that puts redolog into the flat disk image file |
// Usr/local/share/doc/bochs/bochsrc-sample.txt |
Bochs configuration file example |
/Usr/local/share/bochs/BIOS-bochs -* |
BiOS image file (usually BIOS-bochs-Latest) |
/Usr/local/share/bochs/vgabios -* |
Vga bios image file (usually vgabios-lgpl-Latest) |
Here we will add another supplement to Step 1 if you encounter the following problems when executing the configure script:
Error 1:Configure: Error: C ++ Preprocessor "/lib/CPP" fails sanity check
Because bochs are written in C ++, the GNU gcc/g ++ compiler must be installed here.
Solution:Sudo apt-Get install build-essential
Sudo apt-Get install g ++
Error 2: Checking for default GUI on this platform... X11
Error: X Windows GUI was selected, but X Windows libraries were not found.
Solution:Sudo apt-Get install Xorg-Dev
Error 3:Error: PKG-config was not found, or unable to access the GTK +-2.0 package.
Solution:Sudo apt-Get install libgtk2.0-Dev
OK. bochs has been installed. Now we have a computer (bochs) and a boot floppy disk. Since all computers can be virtualized, floppy disks can also be used. In the newly installed bochs component, there is a tool called bximage (see Table 1's second item) that can generate both a virtual floppy disk and a virtual hard disk, they are also called Disk Images. The process of creating a floppy disk image is as follows:
[email protected]:~$ bximage======================================================================== bximage Disk Image Creation Tool for Bochs $Id: bximage.c,v 1.34 2009/04/14 09:45:22 sshwarts Exp $========================================================================Do you want to create a floppy disk image or a hard disk image?Please type hd or fd. [hd] fdChoose the size of floppy disk image to create, in megabytes.Please type 0.16, 0.18, 0.32, 0.36, 0.72, 1.2, 1.44, 1.68, 1.72, or 2.88. [1.44]I will create a floppy image with cyl=80 heads=2 sectors per track=18 total sectors=2880 total bytes=1474560What should I name the image?[a.img]Writing: [] Done.I wrote 1474560 bytes to a.img.The following line should appear in your bochsrc: floppya: image="a.img", status=inserted[email protected]:~$
A. imgfile will be generated in the current directory. This is our floppy disk image.
A disk image file is a complete image of information on a floppy disk or hard disk and is saved as a file. The storage information in the disk image file is in the same format as the storage Information on the corresponding disk. An empty disk image file is a file with the same size as the disk we created but with 0 content. These empty disk image files are like new floppy disks or hard disks. They must be partitioned and formatted before they can be used.
Create a new file named bochsrc in the current directory (note that there is no suffix ).
############################################################### # Configuration file for Bochs(Linux) ################################################################=======================================================================# filename of ROM images #=======================================================================romimage: file=$BXSHARE/BIOS-bochs-latest #=======================================================================# VGAROMIMAGE# You now need to load a VGA ROM BIOS into C0000.#=======================================================================vgaromimage: file=$BXSHARE/VGABIOS-lgpl-latest#=======================================================================# what disk images will be used #=======================================================================floppya: 1_44=/home/mayuan/a.img, status=inserted#=======================================================================# choose the boot disk. #=======================================================================boot: floppy#=======================================================================# where do we send log messages? #=======================================================================log: bochsout.txt#=======================================================================# disable the mouse#=======================================================================mouse: enabled=0#=======================================================================# enable key mapping, using US layout as default.#=======================================================================keyboard_mapping: enabled=0, map=#=======================================================================# how much memory the emulated machine will have#=======================================================================megs: 32
Everything is ready. Enter the current directory from the terminal (assuming/home/Mayuan, bochsrc and A. IMG are also in this directory) and enter the command:
$bochs
If the configuration file is not specified on the command line when bochs is started, bochs searches for the default configuration file in the following order:
. Bochsrcin the current directory
Bochsrcin the current directory
Bochsrc.txt in the current directory
(Win32 only) bochsrc. bxrc in the current directory
(Unix only). bochsrc in the user's home directory
(Unix only) bochsrc in the/etcdirectory
Press enter, and the prompt is:
1. Restore factory default configuration2. Read options from...3. Edit options4. Save options to...5. Restore the Bochs state from...6. Begin simulation7. Quit nowPlease choose one: [6]
Press enter again, enter C, and then press Enter. bochs starts successfully.