centOS7和centOS6上通过光盘自动挂载misc来实现yum源的配置

通过misc便捷挂载光盘

CentOS6.8以下的版本默认开启了autofs服务,可使用misc
## CentOS7实现

 #检测autofs
 rpm -qa|grep autofs
 #没安装的话需进行安装
 yum install -y autofs
#开启服务
 systemctl start  autofs
 #加入开机启动项
[264][root@liyong: mnt]# systemctl enable autofs
Created symlink from /etc/systemd/system/multi-user.target.wants/autofs.service to /usr/lib/systemd/system/autofs.service.
# 测试
[265][root@liyong: mnt]# cd /misc/
[266][root@liyong: misc]# ll
total 0
[267][root@liyong: misc]# cd cd
#光盘成功挂载
[268][root@liyong: cd]# ll
total 1550
-rw-r--r--. 1 root root      14 Dec  5 21:02 CentOS_BuildTag
drwxr-xr-x. 3 root root    2048 Dec  5 21:20 EFI
-rw-r--r--. 1 root root     215 Dec 10  2015 EULA
-rw-r--r--. 1 root root   18009 Dec 10  2015 GPL
drwxr-xr-x. 3 root root    2048 Dec  5 21:47 images
drwxr-xr-x. 2 root root    2048 Dec  5 21:20 isolinux
drwxr-xr-x. 2 root root    2048 Dec  5 21:20 LiveOS
drwxrwxr-x. 2 root root 1548288 Dec  5 20:59 Packages
drwxrwxr-x. 2 root root    4096 Dec  5 21:42 repodata
-rw-r--r--. 1 root root    1690 Dec 10  2015 RPM-GPG-KEY-CentOS-7
-rw-r--r--. 1 root root    1690 Dec 10  2015 RPM-GPG-KEY-CentOS-Testing-7
-r--r--r--. 1 root root    2883 Dec  5 21:52 TRANS.TBL

yum源配置文件添加如下仓库

[misc]
name=misc
baseurl=file:///misc/cd
gpgcheck=0

yum clean all

CentOS6实现

#思路大致相同.下面是关键命令
rpm -qa|grep autofs
yum install autofs -y
service autofs start
chkconfig autofs on
chkconfig --list | grep auto
#配置写入yum源
cat>>/etc/yum.repos/base.repo<<EOF
echo [misc]
name=misc
baseurl=file:///misc/cd
gpgcheck=0
EOF

yum clean all

你可能感兴趣的:(linux,yum源)