准備刻一張FreeBSD-7.0-RELEASE的DVD,網上很多介紹都是在Windows下使用什麼iso提取工具的,貌似很麻煩。參考了一些FreeBSD高手的實現,我寫了一個簡單的腳本,主要功能是從3張disc*.iso創建出一個dvd.iso
1,准備工作:
工作目錄 work/ 和 3張disc*.iso, 比如
work/7.0-RELEASE-i386-disc1.iso
work/7.0-RELEASE-i386-disc2.iso
work/7.0-RELEASE-i386-disc3.iso
2,用以下代碼創建腳本文件,比如 mkdvd.sh,放在work目錄下。用root用戶執行,將在work目錄下產生一個7.0-RELEASE-i386-dvd.iso的文件。
QUOTE:#!/bin/sh
disc1=`ls | grep "disc1.iso"`
disc2=`ls | grep "disc2.iso"`
disc3=`ls | grep "disc3.iso"`
dvd=`echo $disc1 | sed "s/disc1/dvd/"`
## Prepare temporary dir to store dvd files
if test -e tmp && test -d tmp
then
rm -fr tmp
fi
mkdir tmp
## Extract contents of each disc*.iso to temporary dir
for disc in $disc3 $disc2 $disc1
do
mdconfig -a -f $disc -u 66
if test -e /dev/md66
then
echo Extract $disc ...
mount -t cd9660 /dev/md66 /mnt
tar -cf - -C /mnt . | tar -xf - -C tmp/
umount /mnt
mdconfig -d -u 66
else
echo Can not create memory disk.
exit -1
fi
done
## Merge index to point to the first disc
echo Merge index ...
cd tmp
cat INDEX | sed "s/||2/||1/g" > index
cat index | sed "s/||3/||1/g" > INDEX
cat INDEX | sed "s/|3/|1/g" > index
mv index INDEX
cd ..
## Make dvd iso file
echo Make $dvd ...
mkisofs -R -no-emul-boot -b boot/cdboot -o $dvd tmp
rm -fr tmp
exit 0