Now learn to use qemu
The installation steps are as follows:
1. Install qemu.
Download directly from the official website here:
QEMUhttps://www.qemu.org/ Note that after the installation, write the installation path to the environment variable.
2. Download ubuntu image:
I downloaded ubuntu-20.04 3-desktop-amd64. ISO, the latest version.
Download Ubuntu Desktop | Download | Ubuntuhttps://ubuntu.com/download/desktop
3. Installation started:
Find an empty folder, open cmd and cd to the responding Directory:
Create a 32G system disk:
qemu-img.exe create ubuntu.img 32G
Load:
qemu-system-x86_64w.exe -drive file=ubuntu.img,index=0,media=disk,format=raw -cdrom ubuntu-20.04.3-desktop-amd64.iso -m 4G -smp 4 -L Bios -usbdevice mouse -usbdevice keyboard -boot menu=on -rtc base=localtime,clock=host -parallel none -serial none -name ubuntu-no-acpi -no-hpet -no-reboot --accel tcg,thread=multi
Note that it takes a long time to wait, and the downloaded iso should also be placed in this folder.
Run QEmu on the installed image. Note – this maps port 22 (SSH) to port 2222 on the host. In this way, you can use SSH or WinSCP to access the machine
qemu-system-x86_64w.exe -drive file=ubuntu.img,index=0,media=disk,format=raw -m 4G -smp 4 -L Bios -usbdevice mouse -usbdevice keyboard -boot menu=on -rtc base=localtime,clock=host -parallel none -serial none -name ubuntu -no-acpi -no-hpet -no-reboot -device e1000,netdev=user.0 -netdev user,id=user.0,hostfwd=tcp::2222-:22 --accel tcg,thread=multi
It is too laggy to install normally inside.
Command options:
-m 4G set memory
-smp 4 setting the number of CPU s seems to have no effect!
-device e1000,netdev=user.0 -netdev user,id=user.0,hostfwd=tcp::2222-:22: map the 22 port number of the virtual machine to the 2022 port of the local host.
--Accel, tcg, thread = multi: use tcg for acceleration. Multithreading is still very slow, even if it's not heard.
4. Use HAXM for acceleration
Previously, it seems that kqemu was used to accelerate on window s, but at present, kqemu is no longer updated, and 64 bit support is also the debug version.
Let me briefly introduce what I saw. linux uses KVM for acceleration. This is built-in linux and can achieve almost native effect. I heard that the effect of starting window under linux is good. But it can't be used on window.
So how does a VM run smoothly?
The answer is to use the virtual expansion of CPU. Here, Intel and Amd play their own virtual expansion.
HAXM is used by Intel. It is supported in qemu, and all newer Intel products support this. Some may be more.
Detection of whether HAXM can be used:
Check tool v1 0.0 · mirror / Intel / hacktham · GIT code (gitcode.net)https://gitcode.net/mirrors/intel/haxm/-/releases/checktool-v1.0.0 Direct download execution:
.\checktool.exe --verbose
The results are similar as follows:
CPU vendor * GenuineIntel Intel64 supported * Yes VMX supported * Yes VMX enabled * Yes EPT supported * Yes NX supported * Yes NX enabled * Yes Hyper-V disabled * Yes OS version * Windows 6.1.7601 OS architecture * x86_64 Guest unoccupied * Yes. 0 guest(s)
If they are all * signs, it means they can be used. If there is - sign, it may be necessary to modify the board setting or it is not supported.
I don't quite understand the options inside. I only know that Hyper-V is window's own virtualization mechanism. If it is enabled, it will occupy the virtual expansion of CPU.
HAXM installation:
Releases · intel/haxm · GitHubhttps://github.com/intel/haxm/releases The installation of HAXM is very simple. You only need to open exe by default.
After installation, you can use:
qemu-system-x86_64w.exe -drive file=ubuntu.img,index=0,media=disk,format=raw -m 4G -smp 4 -L Bios -usbdevice mouse -usbdevice keyboard -boot menu=on -rtc base=localtime,clock=host -parallel none -serial none -name ubuntu -no-acpi -no-hpet -no-reboot -device e1000,netdev=user.0 -netdev user,id=user.0,hostfwd=tcp::2222-:22 --accel hax
You'll find that I just
--accel tcg,thread=multi
Replace with:
--accel hax
I wanted to use thread=multi here, but I found no response.
Acceleration effect: it's much better than not accelerating, but it still feels a little worse than other commercial virtual machines,.