2018-10-29 Redhat 7使用安装光盘做yum源

首先用VMware12虚拟机,光驱载入redhat7安装光盘iso文件。

创建挂载点

[root@localhost ~]#mkdir /mnt/cdrom
[root@localhost ~]# mount -lv /dev/sr0 /mnt/cdrom
mount: /dev/sr0 is write-protected, mounting read-only
mount: /dev/sr0 mounted on /mnt/cdrom.
[root@localhost ~]# ls /mnt/cdrom
addons  images      Packages                 RPM-GPG-KEY-    redhat-release
EFI     isolinux    release-notes            TRANS.TBL
EULA    LiveOS      repodata
GPL     media.repo  RPM-GPG-KEY-redhat-beta

编辑yum配置文件

[root@localhost ~]# vim /etc/yum.repos.d/rhcsa.repo
[rhcsa]
name=rhcsa
baseurl=file:///mnt/cdrom
enable=1
gpgcheck=0

保存退出,然后yum clean all, yum makecache 就OK了

[root@localhost ~]# yum clean all
Loaded plugins: fastestmirror, product-id, subscription-manager
This system is not registered to Red Hat Subscription     Management. You can use subscription-manager to register.
Cleaning repos: base extras rhcsa updates
Cleaning up everything
Maybe you want: rm -rf /var/cache/yum, to also free up space taken by orphaned data from disabled or removed repos
Cleaning up list of fastest mirrors
[root@localhost ~]# yum makecache
Loaded plugins: fastestmirror, product-id, subscription-manager
This system is not registered to Red Hat Subscription     Management. You can use subscription-manager to register.
base                                                     | 3.6 kB     00:00     
extras                                                   | 3.4 kB     00:00     
rhcsa                                                    | 4.1 kB     00:00     
updates                                                  | 3.4 kB     00:00     
(1/17): base/x86_64/group_gz                               | 166 kB   00:05     
(2/17): base/x86_64/filelists_db                           | 6.9 MB   00:10     
(3/17): base/x86_64/other_db                               | 2.5 MB   00:02     
(4/17): base/x86_64/primary_db                             | 5.9 MB   00:08     
(5/17): extras/x86_64/filelists_db                         | 603 kB   00:04     
(6/17): extras/x86_64/prestodelta                          | 100 kB   00:04     
(7/17): extras/x86_64/primary_db                           | 204 kB   00:00     
(8/17): rhcsa/group_gz                                     | 134 kB   00:00     
(9/17): rhcsa/filelists_db                                 | 3.0 MB   00:00     
(10/17): rhcsa/other_db                                    | 1.3 MB   00:00     
(11/17): rhcsa/primary_db                                  | 3.4 MB   00:00     
(12/17): rhcsa/productid                                   | 1.6 kB   00:00     
(13/17): extras/x86_64/other_db                            | 126 kB   00:02     
(14/17): updates/x86_64/prestodelta                        | 675 kB   00:05     
(15/17): updates/x86_64/filelists_db                       | 3.4 MB   00:06     
(16/17): updates/x86_64/other_db                           | 576 kB   00:00     
(17/17): updates/x86_64/primary_db                         | 6.0 MB   00:46     
Determining fastest mirrors
Metadata Cache Created

最后写入/etc/fstab 开机启动,增加一句

/dev/sr0 /mnt/cdrom iso9660 defaults 0 0 

或者直接

echo "/dev/sr0 /mnt/cdrom iso9660 defaults 0 0" >> /etc/fstab

你可能感兴趣的:(2018-10-29 Redhat 7使用安装光盘做yum源)