4.5 Starting the VM with a batch file
You can create a batch file to start the virtual machine. This makes it easy to start the VM with all the options that you
need every time. From the CLI, start notepad to edit the batch file:
notepad startvm.bat
The batch file only needs a single (long) line (the caret ‘^’ symbol is a line continuation symbol in Windows/DOS):
qemu -M pc -hda hd1.qcow2 -m 256^
-cdrom deblive.iso -boot d -redir tcp:2222:22^
-net nic,vlan=0 -net user,vlan=0,hostname=deblivevm
Let’s take a quick look at the options so that you know how to tweak it:
- -M pc
Do not change this, you need to emulate a PC.
- -m 256
This controls the number of megabytes of RAM for the VM. Specify a larger number only if you have more
physical RAM.
- -cdrom deblive.iso
This tells the emulator to use this file (deblive.iso) as the CD-ROM.
- -boot d
This means to boot from the CD-ROM (from the virtual machine’s perspective).
- -redir tcp:2222:22
Redirect port 2222 of the host environment to port 22 of the VM. This is needed so that you can open up as
many PuTTY sessions to the VM as you like.
- -net nic,vlan=0
The VM will use one virtualized NIC.
- -net user,vlan=0,hostname=deblivevm
The NIC will connect to the host environment using the “user mode”, and have a default host name of
deblivevm.
Unless you know the batch file works, I recommend that you start it from a CLI so that any error will be visible. Once
debugged, you can double click the batch file in Windows Explorer to start the virtual machine.