centos6.4合并两个DVD作为本地yun源



创建目录将iso文件上传

[root@test ~]# mkdir /iso

创建挂载目录

[root@test ~]# mkdir -p /mnt/cdrom

挂载

[root@test ~]# mount -o loop/iso/CentOS-6.4-x86_64-bin-DVD2.iso /mnt/cdrom/

检查挂载

[root@test ~]# df

Filesystem                        1K-blocks      Used Available Use% Mounted on

/dev/sda1                        51605116   7518012 41465716  16% /

tmpfs                            961340         0   961340   0% /dev/shm

/iso/CentOS-6.4-x86_64-bin-DVD2.iso    1418348  1418348         0 100% /mnt/cdrom

配置yum

备份

[root@test ~]#cd /etc/yum.repos.d/

[root@test yum.repos.d]# ls

CentOS-Base.repo  CentOS-Debuginfo.repo  CentOS-Media.repo  CentOS-Vault.repo [root@test yum.repos.d]#mkdir ./bak

[root@test yum.repos.d]# mv ./*.repo ./bak

[root@test yum.repos.d]# ls

bak

[root@test yum.repos.d]# cd bak

[root@test bak]# ls

CentOS-Base.repo  CentOS-Debuginfo.repo  CentOS-Media.repo  CentOS-Vault.repo

[root@test bak]# cp CentOS-Media.repo../myself.repo

[root@test bak]# cd ..

[root@test yum.repos.d]# ls

bak myself.repo

[root@test yum.repos.d]# vi myself.repo

# CentOS-Media.repo

#

# This repo can be used with mounted DVD media, verify the mount point for

# CentOS-6.  You can use this repoand yum to install items directly off the

# DVD ISO that we release.

#

# To use this repo, put in your DVD and useit with the other repos too:

# yum --enablerepo=c6-media [command]

# 

# or for ONLY the media repo, do this:

#

# yum --disablerepo=\* --enablerepo=c6-media [command]

 

[c6-media]

name=CentOS-$releasever - Media

baseurl=file:///media/CentOS/

       file:///media/cdrom/

       file:///media/cdrecorder/

gpgcheck=1

enabled=0

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

 

将上面内容的baseurl/ gpgcheck/ enabled更改为下面内容

 

baseurl=file:///mnt/cdrom

gpgcheck=0

enabled=1

 

更新yum

[root@test yum.repos.d]# yum clean all

Loaded plugins: fastestmirror, security

Cleaning repos: c6-media

Cleaning up Everything

[root@test yum.repos.d]# yum upgrade

Loaded plugins: fastestmirror, security

Determining fastest mirrors

file:///mnt/cdrom/repodata/repomd.xml:[Errno 14] Could not open/read file:///mnt/cdrom/repodata/repomd.xml

Trying other mirror.

Error: Cannot retrieve repository metadata(repomd.xml) for repository: c6-media. Please verify its path and try again

出现错误的原因为第二个包中没有repomd.xml,这个文件我理解就是yum中包的一个索引以及各个包的详细信息等。也就说第二个包不能单独作为yun源。那么尝试下第一个包。

[root@test yum.repos.d]# umount/iso/CentOS-6.4-x86_64-bin-DVD2.iso

[root@test yum.repos.d]# df

Filesystem           1K-blocks      Used Available Use% Mounted on

/dev/sda1             51605116   7518928 41464800  16% /

tmpfs                   961340         0   961340   0% /dev/shm

[root@test yum.repos.d]#

[root@test yum.repos.d]# mount -o loop/iso/CentOS-6.4-x86_64-bin-DVD1.iso /mnt/cdrom/

[root@test yum.repos.d]# df

Filesystem           1K-blocks      Used Available Use% Mounted on

/dev/sda1             51605116   7518932 41464796  16% /

tmpfs                   961340         0   961340   0% /dev/shm

/iso/CentOS-6.4-x86_64-bin-DVD1.iso

                       4251346   4251346         0 100% /mnt/cdrom

[root@test yum.repos.d]# yum clean all

Loaded plugins: fastestmirror, security

Cleaning repos: c6-media

Cleaning up Everything

Cleaning up list of fastest mirrors

[root@test yum.repos.d]# yum update

Loaded plugins: fastestmirror, security

Determining fastest mirrors

c6-media                                                                                                                                                                                       | 4.0 kB     00:00 ...

c6-media/primary_db                                                                                                                                                                            | 4.4 MB     00:00 ...

Setting up Update Process

No Packages marked for Update

成功了,但是需要注意的是可以yum的包有6000多个,但是真正存在的包只有将近4000个。

[root@test yum.repos.d]# yum list | wc -l

6420

[root@test yum.repos.d]# ls -l/mnt/cdrom/Packages/ | wc -l

3957

 

合并两个iso

创建目录

[root@test cdrom1]# mkdir /mnt/cdrom1

[root@test cdrom1]# mkdir /mnt/cdrom2

[root@test cdrom1]# mkdir /mnt/cdrom3

挂载

[root@test cdrom1]# mount -o loop/iso/CentOS-6.4-x86_64-bin-DVD1.iso /mnt/cdrom1

[root@test cdrom1]# mount -o loop/iso/CentOS-6.4-x86_64-bin-DVD2.iso /mnt/cdrom2

拷贝

[root@test cdrom1]# cp -av /mnt/cdrom1//mnt/cdrom3

[root@test cdrom1]# cp -v/mnt/cdrom2/Packages/*.rpm /mnt/cdrom3/cdrom1/Packages/

合并TRANS.TBL

[root@test cdrom1]# cat/mnt/cdrom2/Packages/TRANS.TBL >> /mnt/cdrom3/cdrom1/Packages/TRANS.TBL

 

mv /mnt/cdrom3/cdrom1/Packages/TRANS.TBL/mnt/cdrom3/cdrom1/Packages/TRANS.TBL.bak

[root@test cdrom1]# sort/mnt/cdrom3/cdrom1/Packages/TRANS.TBL.bak > /mnt/cdrom3/cdrom1/Packages/TRANS.TBL

 

跟新yum配置,完成。

 

你可能感兴趣的:(centos6.4合并两个DVD作为本地yun源)