51Testing软件测试论坛

 找回密码
 (注-册)加入51Testing

QQ登录

只需一步,快速开始

微信登录,快人一步

手机号码,快捷登录

查看: 6487|回复: 2
打印 上一主题 下一主题

[讨论] 把Redhat的多个CD安装光盘手工合并成1DVD的方法

[复制链接]

该用户从未签到

跳转到指定楼层
1#
发表于 2007-6-14 00:12:54 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
转前PS:合并redhat企业4版比较好弄点,前天在论坛下的5CD的企业5版,怎么合并在启动的时候都是光盘校验失败。刚没事干翻baidu,搞出来一篇老外的帖子,我看这不错,给我自己做的DVD加了校验就通过了。

原文是英文的,我英语是二把刀,只能满足自己的看懂,随便翻译一下,英语牛人的不要BS我。。。。


===========阅读说明============
1.这个颜色的字是转贴内容
这个颜色的字是我搞的。
2.本文提供给有需要的人士。没有研究爱好的可以54此文。
===========阅读说明============



开始转了。。。

这是转载老外的文章,写得不错。不过他的方法里面没有通过光盘自校验的方法。我只是在最后增加
了一步,让自己制作的光盘也能通过光盘安装时的自检验。呵呵。


Creating a custom Red Hat installation DVD

Created on 19th October 2005

How to create a single CD for fast and easy customized installation.


这是标题:创建一个自己的DVD安装光盘。如何创建一个单CD的安装程序去快速简单的安装系统

Setting up the build directory:
The first thing to do is to copy all the cdrom ISOs to one location:


创建一个目录。
首先把所有的ISO里的内容copy到一个目录里。

代码
mkdir -p /mnt/disk{1,2,3,4}
mount -o loop RHEL4-U1-i386-AS-disc1.iso /mnt/disk1
mount -o loop RHEL4-U1-i386-AS-disc2.iso /mnt/disk2
mount -o loop RHEL4-U1-i386-AS-disc3.iso /mnt/disk3
mount -o loop RHEL4-U1-i386-AS-disc4.iso /mnt/disk4


PS:code标识的是需要在终端里输入的命令

We now copy all the files from the directories to a single directory:

现在copy所有的文件到一个目录里。

代码
mkdir -p /data/isobuild
rsync -rv /mnt/disk{4,3,2,1}/* /data/isobuild/


We also need to copy across the .diskinfo file that is not caught by our *:

需要copy这个文件.diskinfo

代码
cp /mnt/disk1/.diskinfo /data/isobuild/



The .diskinfo file identifies the CD as being a correct Red Hat Installer disk
and is checked by anaconda during the start of the install.


这个.diskinfo文件是在安装的时候,用于检测CD内容的必须文件。

We could now build the DVD as it is but we really should have a fiddle first :-)

老外的幽默,54。

Adding more software to the DVD
We could add some of our own rpms to /data/isobuild/RedHat/RPMS; however by just
doing this does not make them available at install time. There is an XML file
that is read and ensures that the packages are installed in the correct order.


可以给这个DVD里增加更多的软件包
可以把需要增加的rpm包放到/data/isobuild/RedHat/RPMS。
需要一个XML文件确保安装自定义RPM包的时候有正确的顺序。

So let us throw a few random packages into the mix:

随便放几个包到那个里面。

代码
Add some java:
cp jre-1_5_0_03-linux-i586.rpm /data/isobuild/RedHat/RPMS/

Some encryption for GAIM:
cp gaim-encryption-2.36-3.rf.i386.rpm /data/isobuild/RedHat/RPMS/


Updating the comps.xml file
We need to ensure that the host computer has anaconda and anaconda-runtime installed:
up2date anaconda anaconda-runtime


更新comps.xml 这个文件
我们需要确保XXXXXXXXXXXXXXXXXXXX(好像在说linux的更新组件)

Before we update the XML dependency file we need to sort out package orders.
If you have added a lot of new packages you may need to remove some old
packages that you have replaced with newer versions to stop conflicts.


在更新xml文件前需要调整安装包的顺序
如果你加了不少的新安装包,就需要删除点旧的安装包,这样避免的新旧版本的冲突。

So the first command is:
命令:
代码
PYTHONPATH=/usr/lib/anaconda /usr/lib/anaconda-runtime/pkgorder \
/data/isobuild/ i386 > /data/isobuild/xander-pkgorder


This creates a list of files in the order it needs to install them
in the file /data/isobuild/xander-pkgorder. Sometimes an occasional
RPM will not provide the information anaconda needs. You can edit
the file manually and insert your RPMs at the end.


他创建了一个新的文件列表在/data/isobuild/xander-pkgorder,有时比较偶然的会有几个RPM包不提供信息给anaconda ,这时你需要手工编辑这个文件,在文件结尾添加你的RPM信息。

Next we need to generate the dependency file:

创建从属文件

代码
/usr/lib/anaconda-runtime/genhdlist --fileorder /data/isobuild/xander-pkgorder \
/data/isobuild/


You will probably have a few hiccoughs the first time you run these commands.
Most may be resolved by adding the missing entries to the pkgorder file or
deleting duplicate packages.


无关紧要

Creating an automated installer
We could *now* if we wanted to build our DVD; however we can make an
automated installer.

So crack open system-config-kickstart and create a kickstart file with
all the packages and partitioning etc you need for your systems.


开始创建DVD了。


copy the resulting file to /data/isobuild/ks.cfg

copy这个结果文件到/data/isobuild/ks.cfg

we can now edit the file /data/isobuild/isolinux/isolinux.cfg

然后编辑这个文件/data/isobuild/isolinux/isolinux.cfg

copy or change the three lines:
label linux
kernel vmlinuz
append initrd=initrd.img ramdisk_size=8192

to
label xander
kernel vmlinuz
append initrd=initrd.img ramdisk_size=8192 ks=cdrom:/ks.cfg



label linux
kernel vmlinuz
append initrd=initrd.img ramdisk_size=8192
这些内容改成
label xander
kernel vmlinuz
append initrd=initrd.img ramdisk_size=8192 ks=cdrom:/ks.cfg

Then change the default at the top of the file to xander. This means that
the default action is to install directly from the DVD using your kickstart file.

Building the DVD iso
Now to build the iso:


创建DVD 的ISO文件

代码
cd /data/isobuild

chmod a+w isolinux/isolinux.bin


代码
mkisofs -r -T -J -V "Custom RHEL4 Build" -b isolinux/isolinux.bin \
-c isolinux/boot.cat -no-emul-boot -boot-load-size 4 \
-boot-info-table -o /data/custom-RHEL4-dvd.iso /data/isobuild/


创建完成!!!


下一步,我们增加光盘自校验操作。这一步可能会花费2-3分钟,请耐心等待。

代码
/usr/lib/anaconda-runtime/implantisomd5 /data/custom-RHEL4-dvd.iso


Inserting md5sum into iso image...

md5 = 135556ca60f1225a265346acab07086f

Setting supported flag to 0


这些都是程序生成


Buring the DVD
Now we can burn the image to the CD. I assume the CD writer is already
set up on your system. We use cdrecord below, but you can use other
programs as well. The command is invoked as:

cdrecord -v speed=4 dev=0,0,0 /data/custom-RHEL4-dvd.iso

The speed and dev options depend on your system. The device for the dev
argument can be determined by using the -scanbus option to cdrecord:

cdrecord -scanbus

Using the DVD

Once the image is burned onto the DVD, insert the DVD into the target
machine and boot the machine. You should get the custom message that
you created earlier. At this point, you can either press Enter at the
boot prompt or let it timeout. When it times out it uses the default
label, which we specified as ks (Kickstart).


刻盘,如果有nero for linux就不需要命令了。。。



以下是转的一个合并linux 企业5版的脚本:


经合并后,在vmware中以该dvd.iso启动,并正常安装了rhel5.
用法: ./script.sh /TheCdIsoPath /home/username/dvd.iso

#!/bin/bash

# by Chris Kloiber

# 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 ""
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏
回复

使用道具 举报

该用户从未签到

2#
发表于 2007-6-14 22:04:44 | 只看该作者
强银~~顶个先sdlkfj3
回复 支持 反对

使用道具 举报

该用户从未签到

3#
发表于 2007-6-14 22:25:30 | 只看该作者
这位帅锅
你太很了!
这代码看的偶晕得快吐了!
牛人!!!!!!!!!!!!!!!!!!!!!11
回复 支持 反对

使用道具 举报

本版积分规则

关闭

站长推荐上一条 /1 下一条

小黑屋|手机版|Archiver|51Testing软件测试网 ( 沪ICP备05003035号 关于我们

GMT+8, 2024-11-14 14:44 , Processed in 0.066596 second(s), 27 queries .

Powered by Discuz! X3.2

© 2001-2024 Comsenz Inc.

快速回复 返回顶部 返回列表