The orignal CentOS 5 dvd is huge, and it is terrible to use more than 1 cd in which just a few files needed as well. Some people may want a minimal cd
Here is my way which might help you to create a less size DVD/CD
1) Get a copy of CentOS 5 dvd iso. And copy all files including the hidden from it to a local directory.
copydvd.sh
code:
#!/bin/bash
ISOS_PATH=/data/CentOS5/ISOs
FILES_PATH=/data/CentOS5/CentOS5-DVD
for i in $( ls $ISOS_PATH/*.iso ); do
echo item: $i
mount -t iso9660 $i /mnt/iso -o ro,loop
cd /mnt/iso
tar -cf - . | ( cd $FILES_PATH ; tar -xvpf - )
cd $FILES_PATH
umount /mnt/iso
done
And that is where we start our work from.
2) Move all the RPMs to somewhere temporarily. They are in CentOS directory under the DVD path in case you are not knowing that.
in my this case:
mkdir /data/RPMS
mv /data/CentOS5/CentOS5-DVD/CentOS/* /data/RPMS/
3) Get a full list of packages for your required installation. To get this list, we need to make a initial installation base on minimal selection or custom selection. I did it using VMWare, you may just do it just on a real machine. After the installation, there is a install.log under /root directory. That is the file we want, but a few work still need to be done, because it looks like this;
...
Installing libXp - 1.0.0-8.i386
Installing minicom - 2.1-3.i386
Installing mc - 1:4.6.1a-34.el5.i386
(a) generate a better format packages list, it will make the whole line just contain the package name and version. You may need to copy the install.log out in your own way throught ftp, nfs, floppy, email etc whatever.
code:
cat install.log | grep Installing | sed 's/Installing //g' > /data/CentOS5/packages.list
(b) copy the RPMs based on the list to our DVD/CD CentOS path.
copyrpms.sh
#!/bin/bash
DEBUG=0
DVD_CD=/data/CentOS5/CentOS5-DVD
ALL_RPMS_DIR=/data/RPMS
DVD_RPMS_DIR=$DVD_CD/CentOS
packages_list=/data/CentOS5/packages.list
number_of_packages=`cat $packages_list | wc -l`
i=1
while [ $i -le $number_of_packages ] ; do
line=`head -n $i $packages_list | tail -n -1`
name=`echo $line | awk '{print $1}'`
version=`echo $line | awk '{print $3}' | cut -f 2 -d :`
if [ $DEBUG -eq "1" ] ; then
echo $i: $line
echo $name
echo $version
fi
if [ $DEBUG -eq "1" ] ; then
ls $ALL_RPMS_DIR/$name-$version*
if [ $? -ne 0 ] ; then
echo "cp $ALL_RPMS_DIR/$name-$version* "
fi
else
echo "cp $ALL_RPMS_DIR/$name-$version* $DVD_RPMS_DIR/"
cp $ALL_RPMS_DIR/$name-$version* $DVD_RPMS_DIR/
# in case the copy failed
if [ $? -ne 0 ] ; then
echo "cp $ALL_RPMS_DIR/$name-$version* "
cp $ALL_RPMS_DIR/$name* $DVD_RPMS_DIR/
fi
fi
i=`expr $i + 1`
done
Here is is a packages list I already did including the base, core, base-x, dialup-network. It can reduce the whole dvd to 759M, you can remove some images like pxeboot and others to keep the size within 700M (note: I didn't try that, it may cause some problems like could not find the installation cdrom).
Note: There are more packages that we can remove them if they are showed as optional in the repodata/comps.xml file, but I don't have time to do this. If you did, can you share it?
4) Generate the packages information for the yum's installation need.
code:
cd /data/CentOS5/CentOS5-DVD
createrepo -g repodata/comps.xml .
cp .olddata/* repodata/
rmdir .olddata
5) Create the DVD/CD iso
code:
mkisofs -R -J -T -r -l -d -allow-multidot -allow-leading-dots -no-bak -o ../ISOs/CentOS-5.0.ServerDVD-i386.iso -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table .
Now congratulation. All done!
Any comment, bug fixed, please email me at lingxiang.tang at gmail.com
see also: Customize CentOS 5