In order to bring off one-command or even auto installation, and save time of the installation process, the idea that building an Slackware installation CD/DVD came to my mind.
What to do and how to do, this was a question to me at the beginning. I have no idea about isolinux. Fortunately I found that there is an answer called Cooking Up Some Slack(CUSS). After reading over that, I got to know something and began the process.
1 Prepare the packages
I pulled the -Current repository from rsync://rsync.osuosl.org/slackware/slackware-current to my workstation. Some directories and files are not necessary for the installation, to save bandwidth and time, it is sensible to –exclude them, like source/, pasture/, testing/, and so on.
2 Customize initrd.img
The initrd.img contains the system and scripts for installation. Most things will be customized here.
First, uncompress the initrd.img file to a directory. The initrd.img in -Current now is a gzipped cpio archive, rather than a gzipped image as in former versions(before and include 11.0).
$ gzip -cd initrd.img|cpio -i
Most of the installation scripts are stored in usr/lib/setup directory.
Second, to reduce the size of initrd.img, I deleted some directories, e.g., lib/modules/’kernel-version’(retain the -smp directory, I just use -smp to boot), usr/lib/setup(you need installpkg script at least), usr/man, and some files, e.g., scripts related to LVM in sbin/ directory(I don’t use LVM), odd files in etc/ directory, and so on.
Third, customize the environment and script during installation. The files related are etc/profile, etc/rc.d/rc.S, and also etc/inittab, etc/issue and so on, if you want.
This is some pieces of my setup script:
#!/bin/sh
#
# Copyright (c) 2008, Cherife Li.
# All rights reserved.
#
# Redistribution and use of this script, with or without modification,
# is permitted, and must retain the copyright above.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR “AS IS” AND ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
# INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
# Notice:
# - This script is used for one logical disk(not LVM).
# - The disk will be formatted to reiserfs file system.
# - I don’t care about the keyboard map setting.
#
# Bugs, advise, suggestion, or others, if any, please mail me.
#TMP=/var/log/setup/tmp
SRC=/var/log/setup/src
DEST=/mntKERNEL=”`cut -f 5 -d ‘ ‘ /proc/cmdline|cut -f 2 -d =`”
KNAME=”huge-smp”
KVERSION=”`uname -r`”if [ -d $TMP ]; then
rm -rf $TMP/* 1>/dev/null 2>&1
else
mkdir $TMP
fifor i in $SRC $DEST; do
if [ -d $i ]; then
umount -f $i 1>/dev/null 2>&1
else
mkdir -p $i 1>/dev/null 2>&1
fi
doneecho
echo “+==============================================+”
echo ” Preparing the hard disk for installation …”
echo
sleep 3DISK=`fdisk -l|grep ‘^Disk\ \/’|cut -f 2 -d ‘ ‘|cut -f 1 -d :|head -n1`
# clear existing partition(s), if any
PARTNUM=”`fdisk $DISK -l|tail -n1|cut -f 1 -d ‘ ‘|cut -c 9`”
while [ $PARTNUM -gt 0 ]; do
if [ $PARTNUM -gt 1 ]; then
echo -ne “d\n$PARTNUM\n” >> $TMP/fdisk.del
else
echo -ne “d\nw\n” >> $TMP/fdisk.del
fi
let PARTNUM=PARTNUM-1
done
cat $TMP/fdisk.del|fdisk $DISK# Partition the hard disk into two partitions.
# one for swap with 2000M, the other for root(/) with the left of disk.
echo -ne “n\np\n1\n\n+2000M\n\nn\np\n2\n\n\nt\n1\n82\nw\n”|fdisk $DISK# Active swap partition and add it to fstab temp
SWAP_PART=${DISK}1
mkswap -v1 $SWAP_PART
swapon $SWAP_PART
printf “%-16s %-16s %-11s %-16s %-3s %s\n” “$SWAP_PART” “swap” “swap” “defaults” “0″ “0″ >> $TMP/fstab.tmp# Format root (/) partition, mount it, and add it to fstab temp
ROOT_PART=${DISK}2
echo “y”|mkreiserfs $ROOT_PART 1>/dev/null 2>&1
mount $ROOT_PART $DEST || exit 1
printf “%-16s %-16s %-11s %-16s %-3s %s\n” “$ROOT_PART” “/” “reiserfs” “defaults,noatime” “1″ “1″ >> $TMP/fstab.tmpecho
echo ” The hard disk is ready for installation.”
echo “+=============================================+”
echo
#sleep 3echo
echo “+=============================================+”
echo ” Processing the package installation …”
echo
sleep 3# Mount the Slackware source
for MEDIA in \
/dev/hdc /dev/hdd /dev/hda /dev/hdb \
/dev/hde /dev/hdf /dev/hdg /dev/hdh \
/dev/hdi /dev/hdj /dev/hdk /dev/hdl \
/dev/sr0 /dev/sr1 /dev/sr2 /dev/sr3 \
/dev/pcd0 /dev/pcd1 /dev/pcd2 /dev/pcd3;
do
mount -t iso9660 -o ro $MEDIA $SRC 1>/dev/null 2>&1
if [ $? = 0 ]; then
break
fi
doneif [ "`mount|grep "$SRC"`" = "" ]; then
echo
echo “Couldn’t found the installation source!”
echo “Abort …”
echo
exit 1
else
# Process the installation
echo
echo “Found the installation source.”
echo “Now going to install the packages …”
echo
sleep 3
for series in a ap d l n; # you may do some change here
do
installpkg -root $DEST -priority ADD $SRC/slackware/$series/*.tgz
doneecho
echo ” All packages have been installed.”
echo “+=============================================+”
echo
sleep 3
fi# config system
echo
echo “+==============================================+”
echo ” Configuring the system, wait for a while …”
echo# Permission issue
chmod 755 $DEST $DEST/var/spool/mail 1>dev/null 2>&1# Kernel setting
(cd $DEST/boot
rm -rf vmlinuz config System.map 1>/dev/null 2>&1
cp -a $SRC/kernels/$KERNEL/System.map.gz ./System.map-$KNAME-$KVERSION.gz
cp -a $SRC/kernels/$KERNEL/bzImage ./vmlinuz-$KNAME-$KVERSION
cp -a $SRC/kernels/$KERNEL/config ./config-$KNAME-$KVERSION
gzip -df System.map-$KNAME-$KVERSION.gz
ln -sf vmlinuz-$KNAME-$KVERSION vmlinuz
ln -sf config-$KNAME-$KVERSION config
ln -sf System.map-$KNAME-$KVERSION System.map
)# Boot loader
cat > $DEST/etc/lilo.conf << EOF
boot = $DISK
timeout = 0
change-rules
reset
vga = normal
image = /boot/vmlinuz
root = $ROOT_PART
label = default
read-only
EOF
lilo -r $DEST -C /etc/lilo.conf# Network
for nicm in \
e1000 tg3 eepro100 epic100 8139too 8139cp pcnet32 hp100 ne2k-pci olympic rcpci 3c59x acenic de4x5 dgrs sktr skge tulip via-rhine yellowfin dl2k ns83820;
do
modprobe $nicm 2> /dev/null
grep -q eth /proc/net/dev
if [ $? = 0 ]; then
echo “/sbin/modprobe $nicm” > $DEST/etc/rc.d/rc.netdevice
chmod 755 $DEST/etc/rc.d/rc.netdevice
break
else
rmmod $nicm 2> /dev/null
fi
doneif [ ! -f $DEST/etc/rc.d/rc.netdevice ]; then
echo
echo “Warning: No network interface card found.”
echo “Maybe, you need to check the card(s) or the modules.”
echo
fi[... Network setups, e.g., $DEST/etc/rc.d/rc.inet1.conf, $DEST/etc/networks, \
$DEST/etc/hosts, $DEST/etc/HOSTNAME, $DEST/etc/resolv.conf, here \
snip...]# Time config
cat $DEST/usr/share/zoneinfo/Asia/Shanghai > $DEST/etc/localtime
cat > $DEST/etc/hardwareclocl << EOF
localtime
EOF# The /etc/fstab file
cat $TMP/fstab.tmp > $DEST/etc/fstab
printf “%-16s %-16s %-11s %-16s %-3s %s\n” “#/dev/cdrom” “/mnt/cdrom” “auto” “noauto,owner,ro” “0″ “0″ >> $DEST/etc/fstab
printf “%-16s %-16s %-11s %-16s %-3s %s\n” “#/dev/fd0″ “/mnt/floppy” “auto” “noauto,owner” “0″ “0″ >> $DEST/etc/fstab
printf “%-16s %-16s %-11s %-16s %-3s %s\n” “devpts” “/dev/pts” “devpts” “gid=5,mode=620″ “0″ “0″ >> $DEST/etc/fstab
printf “%-16s %-16s %-11s %-16s %-3s %s\n” “proc” “/proc” “proc” “defaults” “0″ “0″ >> $DEST/etc/fstab
printf “%-16s %-16s %-11s %-16s %-3s %s\n” “tmpfs” “/dev/shm” “tmpfs” “defaults” “0″ “0″ >> $DEST/etc/fstab# Misc
cat > $DEST/etc/sysctl.conf << EOF
[... snip ...]
EOFrm -f $DEST/var/spool/mail/root
sed -i '/^c[2-6].*agetty/s/^/#/' $DEST/etc/inittab
sed -i '/^\/sbin\/modprobe.*[parport_pc|lp|agpgart]/s/^/#/' $DEST/etc/rc.d/rc.modules
echo "blacklist ipv6" >> $DEST/etc/modprobe.d/blacklist
chroot $DEST /sbin/ldconfig
chroot $DEST /usr/bin/passwd root# All finished
echo
echo “+=========================================================+”
echo ” Wooow, all done.”
echo ” Now you may reboot with CTRL-ALT-DELETE, enjoy. ;-)”
echo “+=========================================================+”
echo
cat /etc/wel.come
Last, rebuild the initrd.img.
$ find . | cpio -o -H newc | gzip -9 > /PATH/TO/isolinux/initrd.img
3 Customize the kernel
Re-build the kernel with your own config, then copy System.map.gz, bzImage, config, to the kernels/huge-smp directory, or an new directory in kernels/. I removed the ‘kernel-version’ subdirectory of kernels/, as I just use the -smp kernel.
Then modify isolinux/isolinux.cfg to fit the changes.
4 Specify the packages to install
In the slackware/ directory, I just put the packages needed here, and removed the unneeded packages. (The setup script will install all the packages in the series directories.) It is possible to use tagfile to install packages. But I just want a small ISO to build the installation CD/DVD. Which method to use depends on the need. The former is preferred to my situation. If using the later, slackbasics.org has an intro to the tagfiles.
I also added some packages built by myself. :-)
5 Build the ISO image
At the top directory of the ISO source,
$ mkisofs -o /tmp/slackware-install-cd.iso -R -J -V "Slackware Install CD" -hide-rr-moved -v -d -N -no-emul-boot -boot-load-size 4 -boot-info-table -sort isolinux/iso.sort -b isolinux/isolinux.bin -c isolinux/isolinux.boot -A Slack-CD .(do not forget this dot)
then this ISO image could be used to burn an install CD/DVD.
That’s all.
Notes:
Comments 1
Interesting to know.
Posted 28 Oct 2008 at 00:14 ¶Post a Comment