可利用SSH传输到其他虚拟机vm1执行
1. scp /shellyum.sh root@vm1的IP:/(vm1根目录下)
shell脚本
1. 装机后连接镜像文件 :CentOS7-1804 或其他
2. vim /shellyum.sh
3.编写脚本
4. 运行脚本:sh /shellyum.sh
#!/bin/bash
rm -rf /etc/yum.repos.d/*.repo
#删除其他干扰项
mkdir /dvd
#新建挂载点
echo ' [rhel-packages]
name=centos7
baseurl=file:///dvd
enable=1
gpgcheck=0
' > /etc/yum.repos.d/dvd.repo
#配置yum源
sed -i '$a/dev/cdrom /dvd iso9660 defults 0 0' /etc/fstab
mount -a
#开机自动挂载
yum repolist
#展示仓库软件包数量