1.配置系统参数
2. 禁用selinux
在开机界面按e可设置
[root@localhost ~]# vi /etc/sysconfig/selinux
SELINUX=disabled
3. 设置ip,网关和dns
[root@localhost network-scripts]# pwd
/etc/sysconfig/network-scripts
[root@localhost network-scripts]# ls
ifcfg-enp1s0
[root@localhost network-scripts]# vi ifcfg-enp1s0
BOOTPROTO=static
NAME=enp1s0
DEVICE=enp1s0
ONBOOT=yes
IPADDR=192.168.0.1
PREFIX=24
GATEWAY=192.168.0.100 ##真机ip
dns1=114.114.114.114
[root@localhost network-scripts]# nmcli connection reload
[root@localhost network-scripts]# nmcli connection down enp1s0
[root@localhost network-scripts]# nmcli connection up enp1s0
4. 设置yum源
[root@localhost yum.repos.d]# vi westos.repo
[root@localhost yum.repos.d]# cat westos.repo
[AppStream]
name=AppStream
baseurl=http://192.168.0.100/rhel8.2/AppStream
gpgcheck=0
[BaseOS]
name=BaseOS
baseurl=http://192.168.0.100/rhel8.2/BaseOS
gpgcheck=0
[root@localhost yum.repos.d]# dnf install bash-* vim lftp -y
[root@localhost yum.repos.d]# vim /etc/hosts
192.168.0.1 server1
192.168.0.2 server2
192.168.0.3 server3
[root@localhost ~]# hostnamectl set-hostname server1
5. 禁用防火墙,测试是否联网
[root@server1 ~]# route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 192.168.0.100 0.0.0.0 UG 100 0 0 enp1s0
192.168.0.0 0.0.0.0 255.255.255.0 U 100 0 0 enp1s0
[root@server1 ~]# cat /etc/resolv.conf
nameserver 114.114.114.114
[root@server1 ~]# ip route
default via 192.168.0.100 dev enp1s0 proto static metric 100
192.168.0.0/24 dev enp1s0 proto kernel scope link src 192.168.0.1 metric 100
[root@server1 ~]# ping www.baidu.com
[root@server1 ~]# systemctl disable firewalld
Removed /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@server1 ~]# poweroff
6. 清理缓存
真机中做以下操作
[root@foundation images]# du -h rhel8.2.qcow2
21G rhel8.2.qcow2
[root@foundation images]# virt-sysprep -d rhel8.2
[root@foundation images]# virt-sparsify --compress rhel8.2.qcow2 rhel8.2-base.qcow2
[root@foundation images]# du -h rhel8.2-base.qcow2
694M rhel8.2-base.qcow2
[root@foundation images]# du -h rhel8.2-base.qcow2
694M rhel8.2-base.qcow2
[root@foundation images]# ls
rhel7.6-base.qcow2 rhel7.6-newbase.qcow2 rhel8.2-base.qcow2 rhel8.2.qcow2 vm1 vm1.qcow2 vm2
[root@foundation images]# rm -fr rhel8.2.qcow2