CentOS7/Linux 使用本地光驱制作yum源并且永久保存

小编使用的是在ESXI上挂载的虚拟机 (VsPhereClient5.5),挂载光驱比较简单。

 如阅读者使用其它软件安装的虚拟机,请自行百度查询挂载光驱方式。

(小编就不在阐述VsPhere挂载光驱的方式,直接上正文!!!)

 

挂载光驱及永久保存步骤:

[root@localhost ~]# mkdir cdrom    先建立一份空目录
[root@localhost ~]# ls -l /dev/sr*     查询系统是否其它的外置设备   (*):是通配符
brw-rw----. 1 root cdrom 11, 0 Feb 23 10:15 /dev/sr0
[root@localhost ~]# mount /dev/sr0 cdrom/       挂载到cdrom目录下
mount: /dev/sr0 is write-protected, mounting read-only       挂载光驱只有读取的权限
[root@localhost ~]#
[root@localhost ~]# df -T                查询所有磁盘信息包括系统类型
Filesystem              Type     1K-blocks    Used Available Use% Mounted on
/dev/mapper/centos-root xfs       17811456  998352  16813104   6% /
devtmpfs                devtmpfs    930876       0    930876   0% /dev
tmpfs                   tmpfs       941940       0    941940   0% /dev/shm
tmpfs                   tmpfs       941940    8668    933272   1% /run
tmpfs                   tmpfs       941940       0    941940   0% /sys/fs/cgroup
/dev/sda1               xfs        1038336  145828    892508  15% /boot
tmpfs                   tmpfs       188392       0    188392   0% /run/user/0
/dev/sr0                iso9660    4414592 4414592         0 100% /root/cdrom          这个是刚才小编挂载的光驱

系统重新启动后挂载的光驱就会失效,想要一直保存下去,需要更改 /etc/fstab  这份配置文件

[root@localhost ~]# vi /etc/fstab

#
# /etc/fstab
# Created by anaconda on Fri Feb 23 05:21:29 2018
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info
#
/dev/mapper/centos-root /                       xfs     defaults        0 0
UUID=739d0dc5-a0e6-4258-8023-4f0cffd42818 /boot                   xfs     defaults        0 0
/dev/mapper/centos-swap swap                    swap    defaults        0 0
/dev/sr0                /cdrom                    iso9660                    defaults   0  0
外部装置名称      挂载的目录              系统类型                     默认值                          再不济,可以照葫芦画瓢也能画出来O(∩_∩)O哈哈~

目前,永久保存挂载点的信息已经修改完成, 接下来进入使用本地光驱制作yum源

使用本地光驱制作yum源步骤:

1: 建议备份  /etc/yum.repos.d 目录下的所有文件。

2: 删除  /etc/yum.repos.d目录下的所有文件。

3: 在  /ect/yum.repos.d目录下建议一份尾缀名为 .repo的文件,进行编辑。

[root@localhost ~]# cp -r /etc/yum.repos.d/ /
[root@localhost ~]# ls /
bin  boot  dev  etc  home  ifcfg-ens160  lib  lib64  media  mnt  opt  proc  root  run  sbin  srv  sys  tmp  usr  var  yum.repos.d
[root@localhost ~]# rm -rf /etc/yum.repos.d/*
[root@localhost ~]# touch /etc/yum.repos.d/dvd.repo
[root@localhost ~]# vi /etc/yum.repos.d/dvd.repo
[ABC]
name=install ABC
baseurl=file:///cdrom
enabled=1
gpgcheck=0
回到Shell   输入:yum  makecache   刷新repos生成缓存

可是尝试重新启动系统后再shell中输入: df  -T 去查询光驱是否存在

 

[root@localhost ~]# yum install gcc                                      可以安装这个包试试看有没有成功
Loaded plugins: fastestmirror
ABC                                                      | 3.6 kB     00:00
(1/2): ABC/group_gz                                        | 156 kB   00:00
(2/2): ABC/primary_db                                      | 3.1 MB   00:00
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package gcc.x86_64 0:4.8.5-16.el7 will be installed
--> Processing Dependency: cpp = 4.8.5-16.el7 for package: gcc-4.8.5-16.el7.x86_                                                                                                 64
--> Processing Dependency: glibc-devel >= 2.2.90-12 for package: gcc-4.8.5-16.el                                                                                                 7.x86_64
--> Processing Dependency: libmpfr.so.4()(64bit) for package: gcc-4.8.5-16.el7.x                                                                                                 86_64
--> Processing Dependency: libmpc.so.3()(64bit) for package: gcc-4.8.5-16.el7.x8                                                                                                 6_64
--> Running transaction check
---> Package cpp.x86_64 0:4.8.5-16.el7 will be installed
---> Package glibc-devel.x86_64 0:2.17-196.el7 will be installed
--> Processing Dependency: glibc-headers = 2.17-196.el7 for package: glibc-devel                                                                                                 -2.17-196.el7.x86_64
--> Processing Dependency: glibc-headers for package: glibc-devel-2.17-196.el7.x                                                                                                 86_64
---> Package libmpc.x86_64 0:1.0.1-3.el7 will be installed
---> Package mpfr.x86_64 0:3.1.1-4.el7 will be installed
--> Running transaction check
---> Package glibc-headers.x86_64 0:2.17-196.el7 will be installed
--> Processing Dependency: kernel-headers >= 2.2.1 for package: glibc-headers-2.                                                                                                 17-196.el7.x86_64
--> Processing Dependency: kernel-headers for package: glibc-headers-2.17-196.el                                                                                                 7.x86_64
--> Running transaction check
---> Package kernel-headers.x86_64 0:3.10.0-693.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package                Arch           Version                Repository   Size
================================================================================
Installing:
 gcc                    x86_64         4.8.5-16.el7           ABC          16 M
Installing for dependencies:
 cpp                    x86_64         4.8.5-16.el7           ABC         5.9 M
 glibc-devel            x86_64         2.17-196.el7           ABC         1.1 M
 glibc-headers          x86_64         2.17-196.el7           ABC         675 k
 kernel-headers         x86_64         3.10.0-693.el7         ABC         6.0 M
 libmpc                 x86_64         1.0.1-3.el7            ABC          51 k
 mpfr                   x86_64         3.1.1-4.el7            ABC         203 k

Transaction Summary
================================================================================
Install  1 Package (+6 Dependent packages)

Total download size: 30 M
Installed size: 60 M
Is this ok [y/d/N]: y
Downloading packages:
--------------------------------------------------------------------------------
Total                                               64 MB/s |  30 MB  00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : mpfr-3.1.1-4.el7.x86_64                                      1/7
  Installing : libmpc-1.0.1-3.el7.x86_64                                                                                                                                     2/7
  Installing : cpp-4.8.5-16.el7.x86_64                                                                                                                                       3/7
  Installing : kernel-headers-3.10.0-693.el7.x86_64                                                                                                                          4/7
  Installing : glibc-headers-2.17-196.el7.x86_64                                                                                                                             5/7
  Installing : glibc-devel-2.17-196.el7.x86_64                                                                                                                               6/7
  Installing : gcc-4.8.5-16.el7.x86_64                                                                                                                                       7/7
  Verifying  : kernel-headers-3.10.0-693.el7.x86_64                                                                                                                          1/7
  Verifying  : mpfr-3.1.1-4.el7.x86_64                                                                                                                                       2/7
  Verifying  : glibc-headers-2.17-196.el7.x86_64                                                                                                                             3/7
  Verifying  : cpp-4.8.5-16.el7.x86_64                                                                                                                                       4/7
  Verifying  : gcc-4.8.5-16.el7.x86_64                                                                                                                                       5/7
  Verifying  : glibc-devel-2.17-196.el7.x86_64                                                                                                                               6/7
  Verifying  : libmpc-1.0.1-3.el7.x86_64                                                                                                                                     7/7

Installed:
  gcc.x86_64 0:4.8.5-16.el7

Dependency Installed:
  cpp.x86_64 0:4.8.5-16.el7   glibc-devel.x86_64 0:2.17-196.el7   glibc-headers.x86_64 0:2.17-196.el7   kernel-headers.x86_64 0:3.10.0-693.el7   libmpc.x86_64 0:1.0.1-3.el7
  mpfr.x86_64 0:3.1.1-4.el7

Complete!
[root@localhost ~]#

PS:如这篇文章能够帮助到您,请您不要吝啬点个赞吧~~  Thank you!转载时请标明出处及作者!!!

百度查询:Daniu_UnixChina

posted @ 2018-02-23 16:12  蒋大美妞  阅读(1807)  评论(0编辑  收藏  举报