CentOS6.5 将安装光盘作为yum源

前言

  • 网上找适合CentOS6.5的yum源很困难了
  • 替代方案,将安装光盘作为yum源
  • 我用的是VMware虚拟机。嗯,虚拟机还可以挂光盘,那要是云主机呢?可以考虑将文件拷贝到云主机的某个目录,将该目录作为yum源。
  • CentOS6.5 CD: CentOS-6.5-x86_64-bin-DVD1.iso

基本步骤

  1. VMware虚拟机已经添加好光驱,光驱中放上CentOS6.5安装盘。
  2. mount命令查看是否已经挂接了光驱。如果已挂接,直接看
    未挂接是这样的:
 shell> mount
/dev/mapper/VolGroup-lv_root on / type ext4 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")
/dev/sda1 on /boot type ext4 (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)

已挂接是这样的:

shell> mount
/dev/mapper/VolGroup-lv_root on / type ext4 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")
/dev/sda1 on /boot type ext4 (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
/dev/sr0 on /mnt/cdrom type iso9660 (ro)

  1. 创建光驱挂载点
shell> mkdir /mnt/cdrom
  1. 挂载光驱
shell> mount  /dev/sr0  /mnt/cdrom
mount: block device /dev/sr0 is write-protected, mounting read-only
shell> mount
/dev/mapper/VolGroup-lv_root on / type ext4 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw,rootcontext="system_u:object_r:tmpfs_t:s0")
/dev/sda1 on /boot type ext4 (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
/dev/sr0 on /mnt/cdrom type iso9660 (ro)
  1. 配置yum源
    先备份
shell> cd /etc/yum.repos.d/
shell> mv CentOS-Base.repo CentOS-Base.repo.backup
shell> mv CentOS-Debuginfo.repo CentOS-Debuginfo.repo.backup
shell> mv CentOS-Vault.repo CentOS-Vault.repo.backup
shell> cp CentOS-Media.repo CentOS-Media.repo.backup
shell> ls
CentOS-Base.repo.backup       CentOS-Media.repo         CentOS-Vault.repo.backup
CentOS-Debuginfo.repo.backup  CentOS-Media.repo.backup

再修改

shell> vi /etc/yum.repos.d/CentOS-Media.repo
----------------------------
[c6-media]
name=CentOS-$releasever - Media
# 挂载的光盘路径
baseurl=file:///mnt/cdrom/
gpgcheck=1
# 启用此yum源
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
  1. 检查yum源
shell> yum repolist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
repo id                                      repo name                                             status
c6-media                                     CentOS-6 - Media                                      6,364+3
repolist: 6,364

  1. 查看yum源中是否有wget
shell> yum info wget
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Available Packages
Name        : wget
Arch        : x86_64
Version     : 1.12
Release     : 1.8.el6
Size        : 482 k
Repo        : c6-media
Summary     : A utility for retrieving files using the HTTP or FTP protocols
URL         : http://www.gnu.org/software/wget/
License     : GPLv3+ and GFDL
Description : GNU Wget is a file retrieval utility which can use either the HTTP or
            : FTP protocols. Wget features include the ability to work in the
            : background while you are logged out, recursive retrieval of
            : directories, file name wildcard matching, remote file timestamp
            : storage and comparison, use of Rest with FTP servers and Range with
            : HTTP servers to retrieve files over slow or unstable connections,
            : support for Proxy servers, and configurability.
  1. 安装 wget
shell> yum -y install wget
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Available Packages
Name        : wget
Arch        : x86_64
Version     : 1.12
Release     : 1.8.el6
Size        : 482 k
Repo        : c6-media
Summary     : A utility for retrieving files using the HTTP or FTP protocols
URL         : http://www.gnu.org/software/wget/
License     : GPLv3+ and GFDL
Description : GNU Wget is a file retrieval utility which can use either the HTTP or
            : FTP protocols. Wget features include the ability to work in the
            : background while you are logged out, recursive retrieval of
            : directories, file name wildcard matching, remote file timestamp
            : storage and comparison, use of Rest with FTP servers and Range with
            : HTTP servers to retrieve files over slow or unstable connections,
            : support for Proxy servers, and configurability.

[root@localhost yum.repos.d]# ^C
[root@localhost yum.repos.d]# yum -y install wget
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package wget.x86_64 0:1.12-1.8.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==========================================================================================================
 Package              Arch                   Version                       Repository                Size
==========================================================================================================
Installing:
 wget                 x86_64                 1.12-1.8.el6                  c6-media                 482 k

Transaction Summary
==========================================================================================================
Install       1 Package(s)

Total download size: 482 k
Installed size: 1.8 M
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : wget-1.12-1.8.el6.x86_64                                                               1/1
  Verifying  : wget-1.12-1.8.el6.x86_64                                                               1/1

Installed:
  wget.x86_64 0:1.12-1.8.el6

Complete!

参考

https://jingyan.baidu.com/article/425e69e6e033aebe15fc162b.html

上一篇:Arduino ESP6266  几行代码实现简易多任务框架


下一篇:渗透测试实例--Metasploitable2靶机