配置yum源,把光盘镜像文件(/dev/cdrom)挂载到/cd下,并利用yum查看镜像文件

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了配置yum源,把光盘镜像文件(/dev/cdrom)挂载到/cd下,并利用yum查看镜像文件相关的知识,希望对你有一定的参考价值。

参考技术A 1. 挂载的命令为mount,光驱设备文件名是/dev/cdrom。要想挂载光驱可以使用以下命令: mount /dev/cdrom /cdrom (意思是把光驱挂在到/cdrom目录中,这个目录要事先存在) 2. 挂载U盘的方式和这个是一个的,但是当你把U盘插入之后首先要通过fdisk...

CentOS配置本地yum源

配置本地yum源的方法  
  
1.利用光驱挂载镜像配置  
  
1.1首先把光盘放在光驱中,若此时光驱已经挂载请用umount命令先把光驱umount掉  
  
1.2建立相关目录,创建local.repo 文件  
[[email protected] ~]# mkdir /mnt/yum/  
[[email protected] ~]# mount  /dev/hdc  /mnt/yum
[[email protected] ~]# vi /etc/yum.repos.d/local.repo   
 
#添加以下内容  
  
[iso]
name=CentOS-$releasever - iso
baseurl=file:///mnt/yum
gpgcheck=0
enabled=1
 
  
1.3 查看配置的yum源  
[[email protected] ~]# yum  clean all
 [[email protected] ~]# yum repolist
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
repo id                                                          repo name                                                               status
iso                                                              CentOS-5 - iso                                                          2,791
repolist: 2,791


[[email protected] ~]# yum  list   
Loaded plugins: rhnplugin, security  
This system is not registered with RHN.  
RHN support will be disabled.  
base                                                                       | 1.3 kB     00:00       
base/primary            ####################################                                               
  
  
这样 yum仓库就建好了  
  
  
  
2.利用本地文件目录建立yum 仓库  
  
2.1把光盘放入光驱  
mount  /dev/hdc  /mnt  
[[email protected] ~]# mount /dev/hdc  /mnt/  
mount: block device /dev/hdc is write-protected, mounting read-only  
  
注意:存放YUM源的目录必须有可写权限,不然在createrepo时会报错。  
  
2.2将光盘文件复制到YUM目录  
[[email protected] ~]# umount /dev/hdc  
[[email protected] ~]# mount /dev/hdc  /mnt/  
mount: block device /dev/hdc is write-protected, mounting read-only  
[[email protected] ~]# mount  
/dev/sda1 on / type ext3 (rw)  
proc on /proc type proc (rw)  
sysfs on /sys type sysfs (rw)  
devpts on /dev/pts type devpts (rw,gid=5,mode=620)  
/dev/sda2 on /home type ext3 (rw)  
tmpfs on /dev/shm type tmpfs (rw)  
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)  
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)  
/dev/hdc on /mnt type iso9660 (ro)  
  
[[email protected] ~]# cd /mnt/  
[[email protected] mnt]# ls -ld Server/  
dr-xr-xr-x 3 root root 217088 05-19 05:11 Server/  
  
2.2 拷贝Server目录  
[[email protected] mnt]# cp -r Server/ /yum/  
  
2.3安装createrepo  
[[email protected] ~]# cd /yum/Server/  
[[email protected] Server]# rpm  -ivh createrepo-0.4.11-3.el5.noarch.rpm   
warning: createrepo-0.4.11-3.el5.noarch.rpm: Header V3 DSA signature: NOKEY, key ID 37017186  
Preparing...                ########################################### [100%]  
        package createrepo-0.4.11-3.el5.noarch is  installed  
  
2.4创建本地源  
# createrepo  -g  /yum/Server/repodata/comps-rhel5-server-core.xml  /yum/Server  
  
[[email protected] ~]# vi /etc/yum.repos.d/local.repo   
  
[base]  
name=local  
baseurl=file:///yum/Server  
gpgcheck=0  
enabled=1  
  
  
[[email protected] ~]# yum  list  
Loaded plugins: rhnplugin, security  
This system is not registered with RHN.  
RHN support will be disabled.  
base                                                                       | 1.3 kB     00:00       
base/primary            ####################################                         
  
以同样的方式建立VT,CLUSTER,CLUSTERSTORAGE的yum源  
要注意baseurl后为file:/// “三个斜杠”  

 

以上是关于配置yum源,把光盘镜像文件(/dev/cdrom)挂载到/cd下,并利用yum查看镜像文件的主要内容,如果未能解决你的问题,请参考以下文章

Linux 配置本地 YUM 镜像源

linux配置本地yum源

CentOS配置本地yum源

Centos6.5 使用光盘镜像系统源安装数据库mysql5.7

centos挂载光驱ISO并配置本地yum源

CentOS 7环境下配置镜像为本地源yum