You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

In order to run QEMU Image on Windows, DOS Shell scripts are useful which helps doing the necessary things easily.

List of content


Example 1. Creating CentOS 7 image in qcow2 on Windows

create_centos7_vm.bat
@echo off
if exist centos7.img (
	echo Image already exists on your current diretory
	pause
) else (
	"C:\Program Files\qemu\qemu-img.exe" create -f qcow2 centos7.img 1024G
	"C:\Program Files\qemu\qemu-system-x86_64.exe" -m 8G -smp cores=2,threads=2  -cdrom CentOS-7-x86_64-Everything-1908.iso -hda centos7.img
	pause
)


Example 2. Run CentOS 7 image without displaying nothing on Windows

run_centos7_with_no_display.bat
@echo off
rem "C:\Program Files\qemu\qemu-system-x86_64.exe" -m 4G -enable-kvm -cpu host -smp cores=2,threads=4 -drive file=centos8.raw,format=raw
rem "C:\Program Files\qemu\qemu-system-x86_64.exe" -m 4G -smp cores=2,threads=4 -hda centos8.img
rem "C:\Program Files\qemu\qemu-system-x86_64.exe" -m 4G -smp cores=2,threads=4 -hda centos8.img -net user,hostfwd=tcp::8080-:80
rem 
rem https://www.linux-kvm.org/page/Networking
rem
rem "C:\Program Files\qemu\qemu-system-x86_64.exe" -m 4G -smp cores=2,threads=4 -hda centos8.img -netdev user,id=user.0 -device e1000,netdev=user.0
rem
rem https://www.browserling.com/tools/random-mac
rem
echo RAM 8G / 2 cores x 2 threads / HDD 1T
echo SSH 20022, HTTP 80
"C:\Program Files\qemu\qemu-system-x86_64.exe" -m 8G -smp cores=2,threads=2 -hda centos7.img -device e1000,netdev=user.0 -netdev user,id=user.0,hostfwd=tcp::80-:80,hostfwd=tcp::20022-:22 -display none
pause


  • No labels