centos 制作iso镜像

1.挂在光盘,配置软件源(光盘挂载在/yum)

[root@localhost ~]# mkdir /yum

[root@localhost ~]# mount /dev/cdrom /yum

mount: block device /dev/sr0 is write-protected, mounting read-only

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

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

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

[root@localhost yum.repos.d]# mkdir bak

[root@localhost yum.repos.d]# mv CentOS-* bak/

[root@localhost yum.repos.d]# vim lulin.repo

[root@localhost yum.repos.d]# cat lulin.repo

[lulin]

name=lulin

baseurl=file:///yum

gpgcheck=0

enabled=1

[root@localhost yum.repos.d]#

[root@localhost ~]# yum clean all

[root@localhost ~]# yum repolist

Loaded plugins: fastestmirror, refresh-packagekit, security

Loading mirror speeds from cached hostfile

lulin                                                                               | 4.0 kB     00:00 ...

lulin/primary_db                                                                    | 4.5 MB     00:00 ...

repo id                                            repo name                                         status

lulin                                              lulin                                             6,518

repolist: 6,518

2.安装必要的软件

[root@localhost ~]# yum -y install anaconda repodata createrepo mkisofs rsync

3.拷贝镜像内的文件,除了repodate文件夹

[root@localhost ~]# mkdir /myCentos

 [root@localhost ~]#/usr/bin/rsync -a --exclude=repodata/ /yum/ /myCentos/

4.创建repodata目录

[root@localhost myCentos]# mkdir repodata

5.“*-x86_64-comps.xml”文件拷贝到/myCentos/repodata路径下,并重命名成comps.xml。由于centos6.5下的comps.xml文件名很长,这里“*”为省略符,实际操作时输入完整文件名。

 [root@localhost myCentos]#cp /yum/repodata/*-x86_64-comps.xml /myCentos/repodata/comps.xml

此文件保存的软件分组信息,需要保留并用它生成repodata信息

6.将新添加的软件拷贝到Packages目录

[root@localhost myCentos]# cp /root/ntfs-3g-2017.3.23-1.el6.x86_64.rpm /myCentos/Packages/

7.切换到/myCentos目录

8.获取光盘信息变量

[root@localhost myCentos]# declare -x discinfo=`head -1 .discinfo`

生成新的repodata

[root@localhost myCentos]# createrepo -u "media://$discinfo" -g repodata/comps.xml .

Spawning worker 0 with 4185 pkgs

Workers Finished

Gathering worker results

Saving Primary metadata

Saving file lists metadata

Saving other metadata

Generating sqlite DBs

Sqlite DBs complete

9.cd到家目录,在家目录制作光盘

[root@localhost ~]# mkisofs -o myCentOS.iso -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -R -J -v -T /myCentos/

10.测试

[root@localhost ~]# mkdir /myyum

[root@localhost ~]# mount myCentOS.iso /myyum/ -o loop

[root@localhost ~]# vim /etc/yum.repos.d/lulin.repo

[root@localhost ~]# cat /etc/yum.repos.d/lulin.repo

[lulin]

name=lulin

#baseurl=file:///yum

baseurl=file:///myyum

gpgcheck=0

enabled=1

原光盘

[root@localhost ~]# yum repolist

Loaded plugins: fastestmirror, refresh-packagekit, security

Determining fastest mirrors

lulin                                                                                                                                                | 4.0 kB     00:00 ...

lulin/primary_db                                                                                                                                     | 4.5 MB     00:00 ...

repo id                                                                             repo name                                                                         status

lulin                                                                               lulin                                                                             6,518

repolist: 6,518

新光盘

[root@localhost ~]# yum repolist

Loaded plugins: fastestmirror, refresh-packagekit, security

Determining fastest mirrors

lulin                                                                                                                                                | 3.9 kB     00:00 ...

lulin/primary_db                                                                                                                                     | 3.5 MB     00:00 ...

repo id                                                                             repo name                                                                         status

lulin                                                                               lulin                                                                             4,185

repolist: 4,185

Repolist少了2000+.但事实上,软件包个数没有减少

11.测试安装ntfs-3g

[root@localhost ~]# yum install ntfs-3g

Loaded plugins: fastestmirror, refresh-packagekit, security

Setting up Install Process

Loading mirror speeds from cached hostfile

Resolving Dependencies

--> Running transaction check

---> Package ntfs-3g.x86_64 2:2017.3.23-1.el6 will be installed

--> Finished Dependency Resolution

Dependencies Resolved

============================================================================================================================================================================

 Package                                Arch                                  Version                                            Repository                            Size

============================================================================================================================================================================

Installing:

 ntfs-3g                                x86_64                                2:2017.3.23-1.el6                                  lulin                                250 k

Transaction Summary

============================================================================================================================================================================

Install       1 Package(s)

Total download size: 250 k

Installed size: 718 k

Is this ok [y/N]: y

Downloading Packages:

Running rpm_check_debug

Running Transaction Test

Transaction Test Succeeded

Running Transaction

  Installing : 2:ntfs-3g-2017.3.23-1.el6.x86_64                                                                                                                         1/1

  Verifying  : 2:ntfs-3g-2017.3.23-1.el6.x86_64                                                                                                                         1/1

Installed:

  ntfs-3g.x86_64 2:2017.3.23-1.el6                                                                                                                                          

Complete!

成功

12.测试安装

 

成功

 

测试建立本地源.,安装ntfs-3g

 

因为ntfs-3g是自己导入的,没有认证

所以先测试开启gpgcheck=1是否可以安装

 

经测试,安装失败

gpgcheck=0

测试

 

安装成功.

也就是说,自己增加的软件,因为没有认证.也没有导入key,所以需关闭gpgcheck来安装

 

猜你喜欢

转载自blog.csdn.net/linlin9501/article/details/74390642