Linux系统封装成iso文件

xiaohouye 2019-10-30

#安装所需软件包
yum -y install createrepo mkisofs anaconda-runtime  

根据root下的install.log文件,得到安装的软件包
awk ‘/Installing/{print $2}‘ install.log |sed ‘s/^[0-9]*://g‘ >/root/packages.list

[ www]# mkdir centOS6.32bit
[ html]# rsync -a --exclude=Packages centOS6 centOS6.32bit/
[ html]# pwd
/var/www/html
[ html]# mkdir centOS6.32bit/Packages


复制软件包
for fileRpm in `cat packages.list`; do cp -r /var/www/html/centOS6/Packages/$fileRpm* /var/www/html/centOS6.32bit/centOS6/Packages ; done

按照执行就可以
[ centOS6]# cd /var/www/html/centOS6.32bit/centOS6
[ centOS6]# createrepo -g repodata/*-comps.xml /var/www/html/centOS6.32bit/centOS6
491/491 - Packages/abrt-addon-ccpp-2.0.8-6.el6.centos.i686.rpm                  
Saving Primary metadata
Saving file lists metadata
Saving other metadata
[ centOS6]# declare -x discinfo=`head -1 .discinfo`
[ centOS6]# createrepo -u "media://$discinfo" -g repodata/*-comps.xml /var/www/html/centOS6.32bit/centOS6/
488/488 - Packages/glibc-2.12-1.80.el6.i686.rpm                                 
Saving Primary metadata
Saving file lists metadata
Saving other metadata
[ centOS6]#


[ centOS6]# createrepo -g repodata/*-comps.xml /var/www/html/centOS6.32bit/centOS6/
488/488 - Packages/glibc-2.12-1.80.el6.i686.rpm                                 
Saving Primary metadata
Saving file lists metadata
Saving other metadata
[ centOS6]# echo $?       #测试上条命令是否运行成功

按照执行就可以
mkisofs -R -J -T -r -l -d -joliet-long -allow-multidot  -allow-leading-dots -no-bak -o/home/CentOS-6.3-i386-bin-DVD1.iso  -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot  -boot-load-size 4 -boot-info-table /var/www/html/centOS6.32bit/centOS6

-o 输出iso文件位置

[ home]# /usr/bin/implantisomd5 CentOS-6.3-i386-bin-DVD1.iso
Inserting md5sum into iso image...
md5 = 219c7e289d01cdb84cf99de8b3e04503
Inserting fragment md5sums into iso image...
fragmd5 = a9265bee4498b5e93a2e84a58235458cad3651caa37f41da397155e6abe1
frags = 20
Setting supported flag to 0
[ home]#

二、 linux制作iso镜像方法总结

把/dev/cdrom目录制作为镜像,名字为/root/centos6.3.iso
方法1:dd if=/dev/cdrom of=/root/centos6.3.iso
方法2:#cat /dev/cdrom >;/root/centos6.3.iso
方法3:mkisofs -r -o centos6.3.iso /dev/cdrom
方法4:cp -r /home/user name.iso
生成iso镜像以后,就可以用linux下的DVD进行刻录,刻录为DVD光盘了。

前提是已安装好的linux系统都是rpm包安装,这样才能根据/root/install.log文件定制出iso文件。
 

相关推荐