本次介绍在window系统x86机器上安装国产系统 arm 系统的详细教程。
注:ubuntu 的arm系统安装是一样的流程。
1.安装环境准备。
- 首先,你得有台电脑,配置别太差,至少4核8G内存,安装window10或者11都行(为啥不能是Window7,你要用也不是不行,你先解决win7补丁更新问题)。
- 准备虚拟机工具软件QUME,官网下载地址:QEMU for Windows -- Installers (64 bit)
选择最新版本下载即可。
3.准备 QEMU UEFI固件文件。
下载地址:https://releases.linaro.org/components/kernel/uefi-linaro/latest/release/qemu64/QEMU_EFI.fd
4.准备系统安装镜像。(麒麟arm 或者 统信arm 或者 ubuntu arm).iso系统镜像。(这里统一都选择的是桌面版本)
麒麟系统官网:国产操作系统、银河麒麟、中标麒麟、开放麒麟、星光麒麟------麒麟软件官方网站
填好您的申请信息,提交后则跳转到下载界面了。

统信官网:统信软件 -- 打造操作系统创新生态

ubuntu版本下载地址:Index of /

这里我测试选择的是麒麟 ARM系统(您自己选择,则选择arm64版本都行):
镜像名称:Kylin-4.0.2-desktop-sp2-17090118.Z1-arm64.iso

2.安装QUEM工具。
双击安装下载的 qemu-w64-setup-20231224.exe 文件。

选择您的安装路径,路径中不要有中文。记住这个路径,后面配置环境要用。

然后install,直到完成。

继续配置系统的环境变量:
打开 环境变量

找到 path

添加您安装的路径(我选择的是D:\QEMU),这里选择您自己安装的目录:

3.安装文件及脚本准备。
选择您需要保存虚拟机文件的地方,不能有中文路径。
我选择的保存的木兰是: F:\VM\Test_Kylin_arm
将下载的 QEMU UEFI固件文件 复制进文件夹中。

创建启动批处理文件:

将如下代码复制进去,然后保存:
@echo off
echo.
echo ---------------注意事项---------------
echo 1.路径中不要又中文。
echo 2.文件名称请勿取中文。
echo.
echo ---------------开始执行脚本---------------
echo.
echo 当前路径:请检查此路径是否包含中文。
echo %CD%
echo.
set efi_path=""
for /f "tokens=*" %%a in ('dir /b %CD%') do (
for %%I in (%%a) do (
if %%~xI == .qcow2 (
set img_path=%%a
) else if %%~xI == .fd (
set efi_path=%%a
)
)
)
if %efi_path% == "" (
echo 未检索到配置文件,请检查后再试!
echo.
goto :over_err
)
echo 检索到配置文件:%efi_path%
:input_img_name
set /p img_name=请输入镜像名称(请输入英文或数字):
:remove_blank_img
if "%img_name:~0,1%"==" " (
set "img_name=%img_name:~1%"
goto :remove_blank_img
)
if "%img_name%" == "" (
echo 输入的文件名错误,请重新输入!
echo.
goto :input_img_name
)
echo.
:input_img_size
set /p img_size=请输入镜像大小/GB:
:remove_blank_size
if "%img_size:~0,1%"==" " (
set "img_size=%img_size:~1%"
goto :remove_blank_size
)
if %img_size% == "" (
echo 输入的文件大小错误,请重新输入!
echo.
goto :input_img_size
)
set /a check_size=%img_size%
if %check_size% GTR 0 (
echo 镜像大小%img_size%/GB.
) else (
echo 输入的文件大小错误,请重新输入!
echo.
goto :input_img_size
)
echo.
echo 即将创建镜像:%img_name%.qcow2
echo.
qemu-img.exe create -f raw %CD%\%img_name%.qcow2 %img_size%G
echo.
if EXIST %CD%/%img_name%.qcow2 (
echo 生成文件成功:%CD%\%img_name%.qcow2
echo.
) else (
echo 生成镜像文件失败,请检查后再试!
echo.
goto :over_err
)
echo.
echo ----------是否开始启动安装----------
echo ---------------1.启动安装---------------
echo ---------------2.结束脚本---------------
echo.
:input_select_go
set /p select_num=请输入你的选择:
if %select_num% == 1 (
echo 启动安装!
echo.
)else if %select_num% == 2 (
echo 结束脚本!
echo.
goto :over_err
)else (
echo 选择错误,请重新输入!
echo.
goto :input_select_go
)
:input_isoPath_go
set isoPath=""
for /f "delims=" %%a in ('mshta "%~f0"') do SET isoPath=%%a
if "%isoPath%" == "" (
echo 选择文件错误,请重新选择!
echo.
goto :input_isoPath_go
)
set sub_name=.iso
setlocal EnableDelayedExpansion
if "x!isoPath:%sub_name%=!"=="x%isoPath%" (
echo 选择文件错误,请重新选择!
echo.
goto :input_isoPath_go
)
echo 选择镜像:%isoPath%
echo.
echo --------------执行安装程序中,请勿关闭--------------
qemu-system-aarch64.exe ^
-m 4G ^
-cpu cortex-a72 ^
-smp 4 -M virt ^
-bios %efi_path% ^
-device VGA ^
-device nec-usb-xhci ^
-device usb-mouse -device usb-kbd ^
-drive if=none,file=%CD%\%img_name%.qcow2,id=hd0 ^
-device virtio-blk-device,drive=hd0 ^
-drive if=none,file=%isoPath%,id=cdrom,media=cdrom ^
-device virtio-scsi-device ^
-device scsi-cd,drive=cdrom ^
-net user,hostfwd=tcp::2222-:22 -net nic
echo --------------结束安装,下一次启动请执行 start.bat --------------
:over_err
pause
<input type=file id=f>
<script>
f.click();new ActiveXObject('Scripting.FileSystemObject').GetStandardStream(1).Write(f.value);close();
</script>
修改文件后缀为.bat
如果未显示后缀,则需要设置一下即可:

选择 是

4.开始执行安装脚本。
双击 create_install.bat 执行脚本。
如果cmd出现乱码情况,则是编码问题。
如图:

则需要转下编码,安装 notepad++ 工具,然后打开文件:

然后点击 编码=>转换为ANSI码 保存 即可:

然后再次 双击 create_install.bat 执行脚本:

输入生成的系统名称:英文或数字
比如我输入:kylin

输入生成的系统大小:建议国产系统都必须 大于等于 60 G
比如我输入的:66

然后选择输入: 1
启动安装,选择您刚刚下载的.iso的 arm 镜像文件。

然后等待安装,需要按enter时,按一下确认即可,不要关闭命令窗口。

等待安装界面,挺慢的。。。。
选择 安装kylin






继续,等待安装完成

安装完成后,不要点击 现在重启 ,直接关闭cmd命令窗口,或者直接关闭 QEMU窗口 。

或者

5.安装完成后,启动系统脚本。
在保存目录下新建 start.txt 文件。

打开txt文件,并复制粘贴以下代码模块:
同理,如果出现乱码,请转下编码,安装 notepad++ 工具,然后打开文件,然后点击 编码=>转换为ANSI码 保存 即可。
@echo off
echo.
setlocal EnableDelayedExpansion
echo ----------开始检索配置文件----------
set img_path=""
set efi_path=""
for /f "tokens=*" %%a in ('dir /b %CD%') do (
for %%I in (%%a) do (
if %%~xI == .qcow2 (
set img_path=%%a
) else if %%~xI == .fd (
set efi_path=%%a
)
)
)
if %efi_path% == "" (
echo 未检索到配置文件,请检查后再试!
echo.
goto :over_err
)
echo 检索到配置文件:%efi_path%
if %img_path% == "" (
echo 未检索到镜像文件,请检查后再试!
echo.
goto :over_err
)
echo 检索到镜像文件:%img_path%
echo 启动中,请勿关闭..!
qemu-system-aarch64.exe ^
-m 4096 ^
-cpu cortex-a72 ^
-smp 4 -M virt -bios %CD%\%efi_path% ^
-device VGA -device nec-usb-xhci ^
-device usb-mouse -device usb-kbd ^
-drive if=none,file=%CD%\%img_path%,id=hd0 ^
-device virtio-blk-device,drive=hd0 ^
-drive if=none,file=,id=cdrom,media=cdrom ^
-device virtio-scsi-device ^
-device scsi-cd,drive=cdrom ^
-net user,hostfwd=tcp::2222-:22 -net nic
:over_err
pause
保存后,修改后缀未.bat文件。

然后双击 start.bat 执行启动:

在需要按 Enter 到地方按一下进入系统:

启动成功界面:

6.kylin系统开root登陆,并开机自动登陆root。
Kylin麒麟系统设置开机自动登录roo账户_kylin怎么设置root账户-CSDN博客
7.打开ssh服务,设置ssh开机启动。
首先安装 ssh 环境:
sudo apt-get install net-tools
sudo apt-get install ssh
sudo apt-get install openssh-server
sudo apt-get install openssh-client
安装完成后,重新启动ssh服务:
sudo systemctl restart sshd
查看ssh服务是否启动
ps -e | grep ssh

设置ssh服务开机启动:
sudo systemctl enable ssh

然后执行 reboot重启电脑。
reboot
8.使用工具连接ssh。
启动您的ssh连接工具。

输入地址 127.0.0.1 端口 2222 因为在脚本中,本地2222端口映射到了虚拟机22端口。


输入账号 密码

连接成功界面:
