现在的位置: 首页 > 综合 > 正文

制作可以启动的DVD ISO文件

2013年09月29日 ⁄ 综合 ⁄ 共 3005字 ⁄ 字号 评论关闭
这篇文章介绍了如何制作ISO image文件,同时介绍如何从5个FC6的CD iso image,制作可以启动的DVD image。
1。 如何制作iso文件。
如果要将资料备份,存成iso文档是个很不错的选择。因为这是所有系统上共用的格式。iso文件的制作分为两种,一种为一般资料,即不可bootable的,这比较简单,一般用来,保存文档,其功能和tar差不多,iso格式文档可以用于虚拟机的host和guest之间传递数据;另一种就是可以开机的iso文档,这种文档比较复杂,暂时没有去作。
假设要保存的资料存放在/mnt/cdrom中,要将该目录中的文件制作成一个iso文档,要执行下面的命令:

#mkisofs -o /tmp/data.iso -R /mnt/cdrom

其中,-o指定output file的path + filename, -R则表示保留长文档名的格式。

2。将几个CD ISO image合并成DVD image
一般的Linux或Unix的ditribution都分为CD格式和DVD格式,有时候,手头只有CD格式的image,而需要DVD image的时候,下面这个脚本是比较有用的:

FileName: mkdvd
Formate: /bin/sh shell
Contributor: RedHat
Usage:
        mkdvd source /destination/DVD.iso

        The 'source' can be either a directory containing a single
        set of isos, or an exploded tree like an ftp site.

注意:
(1) mkdvd依赖于两个rpm软件包:anaconda-runtime mkisofs,运行之前确认该软件包已经安装。
#rpm -qa | grep anaconda-runtime
anaconda-runtime-11.1.2.34-2
# rpm -qa | grep mkisofs
mkisofs-2.01-10
(2)source可以是保存CD image的目录,也可以是保存DVD安装目录树的地方(本地或网络)。
(3)DVD.iso必须使用绝对路径名。
(4)做完的DVD image可以使用Xen或者VMware来测试一下,对于Redhat,可以使用installer的Media Check来检查。
(5)可以使用dos2unix命令来转换Window和Unxi下的字符。
# dos2unix text.txt > /tmp/text.txt
# mv /tmp/text.txt ./

下面附上该脚本的内容:

#!/bin/bash
# by Chris Kloiber <ckloiber@redhat.com>
# A quick hack that will create a bootable DVD iso of a Red Hat Linux
# Distribution. Feed it either a directory containing the downloaded
# iso files of a distribution, or point it at a directory containing
# the "RedHat", "isolinux", and "images" directories.
# This version only works with "isolinux" based Red Hat Linux versions.
# Lots of disk space required to work, 3X the distribution size at least.
# GPL version 2 applies. No warranties, yadda, yadda. Have fun.

if [ $# -lt 2 ]; then
        echo "Usage: `basename $0` source /destination/DVD.iso"
        echo ""
        echo "        The 'source' can be either a directory containing a single"
        echo "        set of isos, or an exploded tree like an ftp site."
        exit 1
fi

cleanup() {
[ ${LOOP:=/tmp/loop} = "/" ] && echo "LOOP mount point = //, dying!" && exit
[ -d $LOOP ] && rm -rf $LOOP
[ ${DVD:=~/mkrhdvd} = "/" ] && echo "DVD data location is //, dying!" && exit
[ -d $DVD ] && rm -rf $DVD
}

cleanup
mkdir -p $LOOP
mkdir -p $DVD

if [ !`ls $1/*.iso 2>&1>/dev/null ; echo $?` ]; then
        echo "Found ISO CD images..."
        CDS=`expr 0`
        DISKS="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
        if [ -e $DVD/.discinfo ]; then
                awk '{ if ( NR == 4 ) { print disks } else { print ; } }' disks="$DISKS" $DVD/.discinfo > $DVD/.discinfo.new
                mv $DVD/.discinfo.new $DVD/.discinfo
        fi
else
        echo "Found FTP-like tree..."
        cp -av $1/* $DVD
        [ -e $1/.discinfo ] && cp -av $1/.discinfo $DVD
fi

rm -rf $DVD/isolinux/boot.cat
find $DVD -name TRANS.TBL | xargs rm -f

cd $DVD
mkisofs -J -R -v -T -o $2 -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table .
/usr/lib/anaconda-runtime/implantisomd5 --force $2

cleanup
echo ""
echo "Process Complete!"
echo ""

抱歉!评论已关闭.