CentOS 6 包含2个ISO文件,使用起来不方便;可以使用如下的脚本来合并成一个ISO文件.
使用方式为Usage:`basename $0` source /destination/DVD.iso"
需2个参数:$1 指定待合并的ISO文件所在的目录$2 指定输出ISO文件的绝对路径和文件名
注意两个变量:
$LOOP 指定源ISO的挂载点,缺省/tmp/loop;
$DVD 指定中间文件临时目录(注意保证剩余空间)
http://wiki.centos.org/TipsAndTricks/CDtoDVDMedia
#!/bin/bash # by Chris Kloiber <ckloiber@redhat.com> # Mods under CentOS by Phil Schaffner<pschaff2@verizon.net> # A quick hack that will create a bootable DVD iso of a RedHat Linux # Distribution. Feed it either a directory containing thedownloaded # iso files of a distribution, or point it at a directorycontaining # the "RedHat", "isolinux", and"p_w_picpaths" directories. # This version only works with "isolinux" basedRed Hat Linux versions. # Lots of disk space required to work, 3X the distributionsize at least. # GPL version 2 applies. No warranties, yadda, yadda. Havefun. # Modified to add sanity checks and fix CentOS4 syntaxerrors # TODO: # Add checks foravailable disk space on devices holding output and # temp files. # Add optional 3rdparameter to specify location of temp directory. # Create .discinfoif not present. # 取得OS版本号 OS_VER=\ $((test -e /etc/fedora-release && rpm -qf/etc/fedora-release --qf "FC%{VERSION}") \ || (test -e /etc/redhat-release && rpm -qf/etc/redhat-release --qf "EL%{VERSION}") \ || echo OS_unknown) # case "$OS_VER" in EL[45]*|FC?) IMPLANT=/usr/lib/anaconda-runtime/implantisomd5 if [ ! -f$IMPLANT ]; then echo"Error: $IMPLANT Not Found!" echo"Please install anaconda-runtime and try again." exit 1 fi ;; EL6*|FC1?) IMPLANT=/usr/bin/implantisomd5 if [ ! -f $IMPLANT ]; then echo"Error: $IMPLANT Not Found!" echo"Please install isomd5sum and try again." exit 1 fi ;; OS_unknown) echo"Unknown OS." exit 1 ;; *) echo "Fixthis script for $OS_VER" exit 1 esac if [ $# -lt 2 ]; then echo"Usage: `basename $0` source /destination/DVD.iso" echo"" echo" The 'source' can be eithera directory containing a single" echo" set of isos, or an explodedtree like an ftp site." exit 1 fi DVD_DIR=`dirname $2` DVD_FILE=`basename $2` echo "DVD directory is $DVD_DIR" echo "ISO file is $DVD_FILE" if [ "$DVD_DIR" = "." ]; then echo"Destinaton Directory $DVD_DIR does not exist" exit 1 else if [ ! -d"/$DVD_DIR" ]; then echo "Destinaton Directory $DVD_DIRmust be an absolute path" exit 1 else if ["$DVD_FILE" = "" ] || [ -d "$DVD_DIR/$DVD_FILE"]; then echo"Null ISO file name." exit 1 fi fi fi which mkisofs >&/dev/null if [ "$?" != 0 ]; then echo "mkisofsNot Found" echo "yuminstall mkisofs" fi which createrepo >&/dev/null if [ "$?" != 0 ]; then echo"createrepo Not Found" echo "yuminstall createrepo" fi if [ -f $2 ]; then echo "DVD ISOdestination $2 already exists. Remove first to recreate." exit 1 fi # Make sure there is enough free space to hold the DVD p_w_picpathon the filesystem # where the home directory resides, otherwise change~/mkrhdvd to point to # a filesystem with sufficient free space. cleanup() { [${LOOP:=/tmp/loop} = "/" ] && echo "LOOP mount point =\/, dying..." && exit [ -d $LOOP ]&& rm -rf $LOOP [${DVD:=/mnt/mkrhdvd} = "/" ] && echo "DVD data locationis \/, dying..." && exit [ -d $DVD ]&& rm -rf $DVD } cleanup mkdir -p $LOOP mkdir -p $DVD ls $1/*.iso &>/dev/null if [ "$?" = 0 ]; then echo "FoundISO CD p_w_picpaths..." CDS=`expr 0` DISKS="1" [ -w / ] || { # Very portable, but perhaps not perfect,test for superuser. echo "Only'root' may use this script for loopback mounts" 1>&2 exit 1 } for f in `ls$1/*.iso`; do mount -o loop$f $LOOP cp -av $LOOP/*$DVD if [ -f$LOOP/.discinfo ]; then cp -av$LOOP/.discinfo $DVD CDS=`expr $CDS + 1` if [ $CDS!= 1 ] ; then DISKS=`echo ${DISKS},${CDS}` fi fi umount $LOOP done else if [ -f$1/isolinux/isolinux.bin ]; then echo"Found FTP-like tree..." if [ -e $1/.discinfo ]; then cp -av$1/.discinfo $DVD else # How does one construct a legal .discinfo file if none isfound? echo"Error: No .discinfo file found in $1" cleanup exit 1 fi cp -av $1/*$DVD else echo"Error: No CD p_w_picpaths nor FTP-like tree found in $1" cleanup exit 1 fi fi if [ -e $DVD/.discinfo ]; then awk '{ if ( NR ==4 ) { print disks } else { print ; } }' disks="ALL" $DVD/.discinfo> $DVD/.discinfo.new mv $DVD/.discinfo.new $DVD/.discinfo else echo "Error: No .discinfo file found in$DVD" cleanup exit 1 fi rm -rf $DVD/isolinux/boot.cat find $DVD -name TRANS.TBL | xargs rm -f cd $DVD createrepo -g repodata/comps.xml ./ #导入group定义信息 #mkisofs : ISO9660不支持长文件名, -T在每个目录生成TRANS.TBL进行长短文件名映射;-R/J表示Rock Ridge和Joliet扩展 # -b boot_p_w_picpath -cboot_catalog mkisofs -J -R -v -T -o $2 -b isolinux/isolinux.bin -cisolinux/boot.cat -no-emul-boot -boot-load-size 8 -boot-info-table $DVD if [ "$?" = 0 ]; then echo "" echo "Imagecomplete, create md5sum..." # $IMPLANT --force $2 # Don't like forced mediacheck? Try this instead. $IMPLANT--supported-iso --force $2 echo "Startcleanup..." cleanup echo "" echo "ProcessComplete!" echo "WroteDVD ISO p_w_picpath to $DVD_DIR/$DVD_FILE" echo "" else echo "ERROR:Image creation failed, start cleanup..." cleanup echo "" echo "Failedto create ISO p_w_picpath $DVD_DIR/$DVD_FILE" echo "" fi