3.6 Running the emulator to install the guest operating system
In a command line interface, run the following commands. You can also enter all the commands in a text file, called it
startvm.bat, and run the batch file instead. This can save you a lot of typing!
e:
cd \qemu-0.10.5-windows
qemu -hda hd1.qcow2 -m 256 -cdrom \\\\.\\d: -net nic,vlan=0 -net user,vlan=0,hostname=emu -boot d -L .
If you have an ISO file that is not burned to a DVD, use the following command instead (assuming the ISO file is called
binary.iso and it is in the same folder as the main QEMU folder):
e:
cd \qemu-0.10.5-windows
qemu -hda hd1.qcow2 -m 256 -cdrom binary.iso -net nic,vlan=0 -net user,vlan=0,hostname=emu -boot d -L .
Let’s disect the last long command:
- qemu: this is the name of the command.
- -hda hd1.img: this tells the emulator to use the file hd1.qcow2 as the image file of the first hard disk drive.
- -m 256: this tells the emulator to allocate 256MB of RAM to the virtual machine.
- -cdrom \\\\.\\d:: this tells the emulator to use the ‘D’ drive as the CDROM drive of the virtual machine.
In the case of using an ISO file, change \\\\.\\d to the name/path of the ISO file instead.
- -net user,vlan=0,hostname=emu: this tells the emulator to pretend the virtual machine has a NIC. user
means that this NIC uses the host operating system as a bridge so that the guest operating system can reach
the Internet via the host operating system. vlan stands for “virtual LAN”, this dictates the number of the NIC
in the virtual machine. emu is the name as reported by the built-in DHCP server.
- -boot d: this tells the emulator to boot from the ‘D’ drive, which is the emulated CDROM drive.
- -L .: this tells the emulator where to find important BIOS files (the same folder as the qemu executable).
This should start the virtual machine. You should see a window that represents the virtual machine, and it should
bootstrap as if the window itself is a real PC. The actual steps to install Linux in a virtual machine will be discussed
later.