Use Qemu to simulate the arm platform on Windows and install the localized operating system

Use Qemu to simulate the arm platform on Windows and install the localized arm operating system (Kylin V10)

November 17, 2022

background introduction

The PCs we usually use are generally Intel CPUs with x86 architecture. If we need to use an arm-based operating system for some reasons, we cannot use some virtual machine software (such as vmware workstation, virtual box, etc.) to install, because this type The virtual machine software can only be installed on a system with the same architecture as the host's CPU. However, we can use qemu software, which can be understood as a simulator that can simulate an arm-based virtual machine. Qemu is sometimes called virtual machine software.

This article briefly introduces how to install and use qemu to install the kylinV10 system of the arm architecture in the windows system (other similar operating systems can also be referred to, only the ISO image used for installation is different), and the arm architecture can be run on the windows of the x86 architecture The virtual machine, so that the operating system of other cpu architecture can be used on windows to develop, compile, verify problems and other operations. For reference only by those who need it.

What is Qemu

QEMU is an open source emulator and virtual machine monitor (Virtual Machine Monitor, VMM). QEMU mainly provides two functions for users to use. One is to use the dynamic code translation mechanism as a user state simulator to execute codes different from the host architecture . The second is to act as a virtual machine supervisor, simulate the entire system, use other VMMs (Xen, KVM, etc) to use the virtualization support provided by the hardware, and create a virtual machine with performance close to that of the host.

Documentation

After this installation, the virtual machine uses the tap mode to access the Internet, so the startup command and Internet configuration are both in the tap mode. If you use other modes, the installation and startup commands may be slightly different.

Host system : windows10, windwos11 (the host in this document uses windows11 system)

Qemu software : qemu-w64-setup-20220831.exe

Kylin V10 operating system installation package : Kylin-Server-10-SP2-aarch64-Release-Build09-20210524.iso (the installation package needs to be provided by the manufacturer, and those who need it can also find it online)

Kylin boot file (EFI file) : qemu-kylin EFI file

Virtual network card software : openvpn-connect-3.3.6.2752_signed.msi

The main steps

  1. Install Qemu software;
  2. Install a virtual network card
  3. Use the qemu-img command to create a qemu virtual machine;
  4. Use the qemu-system-aarch64 command to install the kylin system
  5. Use the qemu-system-aarch64 command to start the kylin system
  6. Network configuration in kylin system

Install qemu software

install qemu

After downloading the qemu installation package, just double-click to execute it. It is the same as installing other software, so I won’t repeat it here. Please remember the installation path during the installation process, which will be used when configuring environment variables later.

Configure environment variables

Right-click on "My Computer" and find "Properties":
insert image description here
the "Settings" interface will pop up, as shown in the figure below:
insert image description here
Click "Advanced System Settings", and the system properties interface will pop up, as shown in the figure below:
insert image description here
Click the "Environment Variables" button to pop up The environment variable editing interface, as shown in the figure below:
insert image description here
open cmd, execute qemu-system-aarch64 -version, and the version information can be displayed, as shown below:

qemu-system-aarch64 -version
QEMU emulator version 7.1.0 (v7.1.0-11925-g4ec481870e-dirty)
Copyright (c) 2003-2022 Fabrice Bellard and the QEMU Project developers

Install a virtual network card

install openvpn

Double-click the downloaded openvpn-connect-3.3.6.2752_signed.msi software, just like installing other software, you can install it step by step.

Note: It is not necessary to install this software, other vpn software can also be installed, as long as a virtual network card can be created.

Modify the network card name

After the installation is complete, you can see that a new network card has been added on the network connection interface, as shown in the figure below:
insert image description here
Note: the network card in the big red box is newly added, and the name in the yellow box is modified by me. It may not be the name after openven. The operation of modifying the name of the network card will be described below. Just pay attention to whether the network card type in the small red box is "TAP-Windows Adapter". If you find this type of network card, it is a newly added network card. And the connection state is also unconnected state, don't pay attention, it will change to normal state after starting the virtual machine. The "Ethernet" under the red box is the real physical network card of my computer.

Right-click the newly added network card and rename the network card, as shown in the figure below:
insert image description here
Note: I changed it to tap0 here, and other names are also acceptable. It is recommended to change it to tapXX, and it is best not to use the Chinese name.

Networks that share physical NICs

Right-click the local physical NIC, as shown in the figure below:
insert image description here

Click the "Properties" button, and select the "Sharing" option in the pop-up interface, as shown in the figure below:
insert image description here
Select the "Allow other networks to connect through this computer's Internet connection" check box, and select the newly added item for "Home Network Connection" The network card (and the name after the name has been modified), select "Allow other network users to control or disable shared Internet connections", and then confirm.

Create a qemu virtual machine

Open the cmd interface, create a directory for the virtual machine and use the qemu-img.exe command to create a virtual machine, as follows:

C:\Users\>mkdir D:\virtual-machines\qemu\kylinV10
C:\Users\>D:
D:\>cd D:\virtual-machines\qemu\kylinV10
D:\virtual-machines\qemu\kylinV10>qemu-img.exe create -f qcow2 kylindisk.qcow2 120G
Formatting 'kylindisk.qcow2', fmt=qcow2 cluster_size=65536 extended_l2=off compression_type=zlib size=128849018880 lazy_refcounts=off refcount_bits=16

Note : The image size can be modified according to your needs.

There will be a kylindisk.qcow2 file in the specified directory.

 D:\virtual-machines\qemu\kylinV10 的目录

2022/11/16  15:45    <DIR>          .
2022/11/16  15:31    <DIR>          ..
2022/11/16  15:43           198,656 kylindisk.qcow2
2022/11/10  13:07         2,097,152 QEMU_Kylin_EFI.fd
               2 个文件      2,295,808 字节
               2 个目录 318,376,022,016 可用字节

Install the kylin system

Copy the previously downloaded EFI file to the created mirror directory (you can not copy it, use the -bios option to specify it, the copy is for the convenience of finding the file later, and preventing the file from being accidentally deleted).

In the cmd interface, use the qemu-system-aarch64.exe command to install the Kylin operating system:

D:\virtual-machines\qemu\kylinV10>qemu-system-aarch64.exe -m 8192 
-cpu cortex-a72 -smp 8,sockets=4,cores=2 -M virt 
-bios D:\virtual-machines\qemu\kylinV10\QEMU_Kylin_EFI.fd 
-device VGA -device nec-usb-xhci -device usb-mouse -device usb-kbd 
-drive if=none,file=D:\virtual-machines\qemu\kylinV10\kylindisk.qcow2,id=hd0 
-device virtio-blk-device,drive=hd0 
-drive if=none,file=D:\softwares\Kylin-Server-10-SP2-aarch64-Release-Build09-20210524.iso,id=cdrom,media=cdrom 
-device virtio-scsi-device -device scsi-cd,drive=cdrom 
-net nic -net tap,ifname=tap0

Note: Note: Please remove the line break when executing the command. In -net tap, ifname=tap0, please change tap0 to the name of the network card modified by yourself in the previous steps. Please replace the -bios parameter with your own path. -drive if-none,file=xxx Please replace it with the mirror path created by yourself. -drive if=none,file=xxx/Kylin-Server-10-SP2-aarch64-Release-Build09-20210524.iso Please replace it with your own mirror path.

The main parameters are described as follows

-m 虚拟机内存的大小,单位是MB
-cpu cpu类型,可以使用qemu-system-aarch64 -M help命令查看支持的类型。
-bios 引导文件的路径

At this time, a graphical interface will be started, as shown in the figure below:
insert image description here
After selection, it will enter the operating system installation interface, as shown in the figure below:
insert image description here
Just like installing other linux systems, you can configure it step by step according to your needs. It is recommended to install as small as possible and only select necessary components, because it may take a long time to install too many functions.

Start the kylin system

In the cmd interface, use the qemu-system-aarch64.exe command to start the Kirin operating system

D:\virtual-machines\qemu\kylinV10>qemu-system-aarch64.exe -m 8192 
-cpu cortex-a72 -smp 8,sockets=4,cores=2 -M virt 
-bios D:\virtual-machines\qemu\kylinV10\QEMU_Kylin_EFI.fd 
-device VGA -device nec-usb-xhci -device usb-mouse -device usb-kbd 
-drive if=none,file=D:\virtual-machines\qemu\kylinV10\kylindisk.qcow2,id=hd0 
-device virtio-blk-device,drive=hd0 
-device virtio-scsi-device -net nic -net tap,ifname=tap0

Note: Please remove the newline character when executing the command. In -net tap, ifname=tap0, please change tap0 to the name of the network card modified by yourself in the previous steps. Please replace the -bios parameter with your own path. -drive if-none,file=xxx Please replace it with the mirror path created by yourself.

For the convenience of starting in the future, you can save this command as a bat file, and then double-click it to execute it.

Configure the network in the kylin system

Check the IP address of the newly added tap0 network card in the host machine, right-click the network card, and select "Status" > "Details", as shown in the figure below: You can see the IP address of the tap0 network card after the host machine shares the
insert image description here
network The address has changed to 192.168.137.1, which is the gateway address of the network in the virtual machine system, and the mask is the subnet mask of the network in the virtual machine system. After entering the kylinV10 virtual machine, you can configure the network address through the command line or the graphical interface. In this experiment, I set the IP address in the kylinV10 virtual machine to 192.168.137.101, the mask to 255.255.255.0, and the gateway to 192.68.137.1. The DNS is 114.114.114.114. Your own environment can be modified according to your own needs.

set up ssh connection

Open sshd service in kylinV10

After installing the kylinV10 system, the SSH connection is enabled by default. If it is not enabled, first determine whether ssh is installed:

yum list installed | grep openssh
[root@localhost ~]# yum list installed | grep openssh
openssh.aarch64                             8.2p1-9.p03.ky10                @anaconda        
openssh-clients.aarch64                     8.2p1-9.p03.ky10                @anaconda        
openssh-server.aarch64                      8.2p1-9.p03.ky10                @anaconda

If there is the above display, it means that openssh has been installed, if not, execute the following command to install openssh:

yum install openssh

Execute the systemctl status sshd command to check whether the sshd service has been enabled:

[root@localhost ~]# systemctl status sshd
● sshd.service - OpenSSH server daemon
   Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: enabled)
   Active: active (running) since Wed 2022-11-16 18:55:19 CST; 16h ago
     Docs: man:sshd(8)
           man:sshd_config(5)
 Main PID: 1303 (sshd)
    Tasks: 1
   Memory: 24.2M
   CGroup: /system.slice/sshd.service
           └─1303 sshd: /usr/sbin/sshd -D [listener] 0 of 10-100 startups

If the above display is displayed, it means that the sshd service has been enabled. If it is not enabled, use the following command to enable the ssh service:

systemctl start sshd

Use systemctl is-enabled sshd to check whether sshd is set to start

[root@localhost ~]# systemctl is-enabled sshd
enabled

If disabled is displayed, set ssh to start at boot through the following command:

systemctl enable sshd

Connect kylinV10 via ssh in windows

If you just want to connect to kylinV10 through ssh in the current windows system, you only need ssh user@ip. The ip address is the ip address configured in kylinv10. This environment uses 192.168.137.101, and you can connect directly by ssh [email protected].

If you want to access kylinV10 through ssh on other machines, you need to set port mapping in the current windows system. The specific method can be searched through the Internet.

disable graphical desktop

If you did not choose a graphical interface during installation, you can ignore this step.

systemctl isolate graphical.target 切换为图形模式

systemctl isolate multi-user.target 切换为命令行模式

systemctl set-default graphical.target  设置图形界面为默认模式

systemctl set-default multi-user.target 设置命令行模式为默认模式

Just execute systemctl set-default multi-user.target and restart the system.

common problem

After restarting the qemu virtual machine, the external network cannot be connected

This problem may be caused by Windows network sharing. Right-click the physical network card of the host machine, click the "Properties" button, select the "Sharing" option in the pop-up interface, cancel the sharing first, click OK, and then choose sharing again.

reference

Install qemu under Windows Server2008 to simulate arm architecture CPU and install Galaxy Kirin v4

Desktop Galaxy Kirin V10 Character Interface Mode and Graphical Interface Mode Switching- Xinchuang Technology Alliance

Galaxy Kirin server operating system V10 SP1 to enable SSH service - my life is up to me - hao - 博客园

Running Virtual Machines with qemu-system-ARCH | Virtualization Guide | SUSE Linux Enterprise Server 15 SP3

Galaxy Kirin server operating system V10 SP1 to enable SSH service - my life is up to me - hao - 博客园

Guess you like

Origin blog.csdn.net/EmptyStupid/article/details/127949231