linux--封装redhat镜像

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

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值