ARM アーキテクチャに基づく openEuler システムは、qemu シミュレータを通じて ARM アーキテクチャの openEuler 仮想マシンを自動的にインストールして起動します。

[元のリンク] ARM アーキテクチャに基づく openEuler システムは、qemu シミュレータを通じて ARM アーキテクチャの openEuler 仮想マシンを自動的にインストールして起動します

1. 基本的な準備

(1) ARM アーキテクチャの openEuler オペレーティング システム イメージをダウンロードします。

mkdir -p /opt/os
cd /opt/os
wget https://repo.openeuler.org/openEuler-22.03-LTS/ISO/aarch64/openEuler-22.03-LTS-aarch64-dvd.iso --no-check-certificate
chmod 777 /opt/os/openEuler-22.03-LTS-aarch64-dvd.iso


(3) ARM アーキテクチャをダウンロードするためのEFIパスは /usr/share/AAVMF/AAVMF_CODE.fd です。

yum install -y http://mirror.centos.org/altarch/7/os/aarch64/Packages/AAVMF-20180508-6.gitee3198e672e2.el7.noarch.rpm

(4) 基本的な依存関係をインストールする

yum install -y kvm qemu virt-viewer virt-manager libvirt libvirt-python python-virtinst
yum install libguestfs-tools -y
yum install virt-install.noarch -y
systemctl enable libvirtd
systemctl start libvirtd
usermod -aG libvirt $(whoami)
yum install virt-install virt-viewer virt-manager -y

(5) 設定ファイルを変更し
、以下の 2 行のコメントを解除します。

vi /etc/libvirt/qemu.conf


次に、nvram を検索し、次の行をコメントします。

それから再起動します

reboot

(6) qemuのダウンロード

cd /opt
wget https://download.qemu.org/qemu-4.2.0.tar.xz

(7) 基本的な依存関係をインストールする

yum install zlib-devel glib2-devel pixman-devel gcc -y

(8) qemuを解凍する

cd /opt/
tar xf qemu-4.2.0.tar.xz

(9) qemuのインストール

cd qemu-4.2.0/
./configure --target-list=aarch64-softmmu --prefix=/usr
make -j8
make install

2. dhcp に基づいて IP アドレスを自動的に取得する openEuler 仮想マシンを自動的に作成します。

(1) ディスクを作成する

rm -rf /var/lib/libvirt/images/test.qcow2
systemctl restart libvirtd
qemu-img create -f qcow2 /var/lib/libvirt/images/test.qcow2 30G

(2) ksファイルの作成

rm -rf /opt/openEuler/dhcp/ks.cfg
mkdir -p /opt/openEuler/dhcp/
vi /opt/openEuler/dhcp/ks.cfg

ks ファイルの内容は次のとおりです。

#version=DEVEL
# System authorization information
auth --enableshadow --passalgo=sha512
# Use CDROM installation media
cdrom
# Use graphical install
text
# Run the Setup Agent on first boot
firstboot --enable
ignoredisk --only-use=sda
# Keyboard layouts
keyboard --vckeymap=cn --xlayouts='cn'
# System language
lang zh_CN.UTF-8
# Network information
network  --bootproto=dhcp
network  --hostname=test
# Root password
rootpw --iscrypted $6$iqWsh8SEbDTI2rvb$ri6nTjR79jQ9MDrzcKGkEhy6k8TQg2jV3P8JJ4E.WNaIfL1kFSUlIWBtA5bDjCajH213TKUeBQT6SaYbtnKzN/
# System services
services --enabled="chronyd"
# System timezone
timezone Asia/Shanghai --isUtc
# System bootloader configuration
bootloader --append=" crashkernel=auto" --location=mbr --boot-drive=sda
# Partition clearing information
clearpart --none --initlabel
# Disk partitioning information
part /boot --fstype="xfs" --ondisk=sda --size=1024
part /boot/efi --fstype="efi" --ondisk=sda --size=600 --fsoptions="umask=0077,shortname=winnt"
part pv.252 --fstype="lvmpv" --ondisk=sda --size=18050
volgroup centos --pesize=4096 pv.252
logvol swap  --fstype="swap" --size=2048 --name=swap --vgname=centos
logvol /  --fstype="xfs" --size=16000 --name=root --vgname=centos
%packages
@^minimal-environment
@standard
@core
chrony
kexec-tools
%end
reboot
%anaconda
pwpolicy root --minlen=6 --minquality=1 --notstrict --nochanges --notempty
pwpolicy user --minlen=6 --minquality=1 --notstrict --nochanges --emptyok
pwpolicy luks --minlen=6 --minquality=1 --notstrict --nochanges --notempty
%end

(3) virt-install による仮想マシンの起動

virt-install\
     --name test\
     --memory 2048\
     --vcpus=1\
     --os-type linux\
     --location /opt/os/openEuler-22.03-LTS-aarch64-dvd.iso \
     --disk path=/var/lib/libvirt/images/test.qcow2,size=20,format=qcow2  \
     --graphics=none \
     --console pty,target_type=serial \
     --initrd-inject ks.cfg --extra-args "inst.ks=file:/ks.cfg console=ttyS0,115200n8"

3. 静的 IP アドレスを使用して openEuler 仮想を自動的に作成します

(1) ディスクを作成します。ディスクが存在する場合は削除してから作成します。

rm -rf /var/lib/libvirt/images/test.qcow2
qemu-img create -f qcow2 /var/lib/libvirt/images/test.qcow2 30G

(2) ks.cfgファイルの作成

rm -rf /opt/openEuler/static/ks.cfg
mkdir -p /opt/openEuler/static/
vi /opt/openEuler/static/ks.cfg

次に、以下の内容を ks.cfg に書き込みます。

#version=DEVEL
# System authorization information
auth --enableshadow --passalgo=sha512
# Use CDROM installation media
cdrom
# Use graphical install
text
# Run the Setup Agent on first boot
firstboot --enable
ignoredisk --only-use=sda
# Keyboard layouts
keyboard --vckeymap=cn --xlayouts='cn'
# System language
lang zh_CN.UTF-8

# Network information
network  --bootproto=static --device=ens3 --gateway=192.168.1.1 --ip=192.168.1.100 --nameserver=8.8.8.8 --netmask=255.255.255.0
network  --hostname=test

# Root password
rootpw --iscrypted $6$iqWsh8SEbDTI2rvb$ri6nTjR79jQ9MDrzcKGkEhy6k8TQg2jV3P8JJ4E.WNaIfL1kFSUlIWBtA5bDjCajH213TKUeBQT6SaYbtnKzN/
# System services
services --enabled="chronyd"
# System timezone
timezone Asia/Shanghai --isUtc
# System bootloader configuration
bootloader --append=" crashkernel=auto" --location=mbr --boot-drive=sda
# Partition clearing information
clearpart --none --initlabel
# Disk partitioning information
part /boot --fstype="xfs" --ondisk=sda --size=1024
part /boot/efi --fstype="efi" --ondisk=sda --size=600 --fsoptions="umask=0077,shortname=winnt"
part pv.252 --fstype="lvmpv" --ondisk=sda --size=19455
volgroup centos --pesize=4096 pv.252
logvol swap  --fstype="swap" --size=2048 --name=swap --vgname=centos
logvol /  --fstype="xfs" --size=17404 --name=root --vgname=centos

%packages
@^minimal-environment
@standard
@core
chrony
kexec-tools

%end
reboot

%anaconda
pwpolicy root --minlen=6 --minquality=1 --notstrict --nochanges --notempty
pwpolicy user --minlen=6 --minquality=1 --notstrict --nochanges --emptyok
pwpolicy luks --minlen=6 --minquality=1 --notstrict --nochanges --notempty
%end

(3) 次に、virt-install コマンドで仮想マシンを起動します。

virt-install \
     --name test \
     --memory=1024 \
     --vcpus=1 \
     --os-type linux \
     --location /opt/os/openEuler-22.03-LTS-x86_64-dvd.iso \
     --disk path=/var/lib/libvirt/images/test.qcow2,size=20,format=qcow2  \
     --graphics=none \
     --console pty,target_type=serial \
     --initrd-inject ks.cfg --extra-args "inst.ks=file:/ks.cfg console=ttyS0,115200n8"

(4) たとえば、作成した仮想マシンの IP アドレスが 192.168.1.100 に設定されている場合、仮想マシンの作成後、ログインして IP を確認する必要はなく、その IP を使用して直接 ping を実行できます。またはssh。

おすすめ

転載: blog.csdn.net/redrose2100/article/details/128206555