Table of Contents
Sometimes you may want to do a custom installation of Slackware Linux, for example to get better understanding of how GNU/Linux systems work, or to prepare an automatic installation script. This chapter outlines the steps that are required to install Slackware Linux manually. A sample installation script is also provided in Section 6.5, “Automated installation script”.
If you have performed a normal installation, you should not have any problems partitioning a disk. You can use the fdisk and cfdisk commands to partition disks. If you are scripting the installation of Slackware Linux it is useful to know that you can pipe fdisk commands to fdisk. For example:
# fdisk /dev/hda << EOF
n
p
1
+10000M
n
p
2
+512M
t
2
82
w
EOF
These commands create a primary Linux partition of 10000MB, and a primary Linux swap partition of 512MB. You could store the fdisk commands in different disk profiles, and use one of the profiles based on the specific deployment (e.g. the disk size). For example:
# cat /usr/share/fdisk-profiles/smalldisk | fdisk
After making at least a swap and a Linux partition, you can initialize the filesystem and swap space and make use of this storage. On systems that are short on memory, you should initialize, and use swap first. We will use the partition layout used in the partitioning example listed above in the following examples. To set up and use swap, execute:
# mkswap /dev/hda2 # swapon /dev/hda2
The meaning of these commands is quite obvious. mkswap
initializes the swap space, and swapon puts it to
use. You will only have to execute mkswap once,
but swapon has to be executed during every system
boot. This can be done automatically by adding an entry for the
swap partition to /etc/fstab
For now, it is important to initialize the target partitions. This
can be done with the mkfs command. You can
specify which filesystem should be used by adding the -t parameter. mkfs
will automatically invoke a mkfs.filesystem
command based on the filesystem that you have chosen. Be aware that
the filesystems that can be used depends on the installation
kernel that you have booted. If you have booted the
bare.i kernel, you can use the
ext2, ext3 and
reiserfs filesystems.
To initialize an ext3 filesystem, and mount it, you should execute the following commands:
# mkfs -t ext3 /dev/hda1 # mount /dev/hda1 /mnt
If you have made separate partitions for certain directories
in the root filesystem, e.g. /home
# mkfs -t ext3 /dev/hda2 # mkdir /mnt/home # mount /dev/hda2 /mnt/home
Finally, you will have to mount your source medium. If you use
a CD-ROM, this is easy. Suppose that /dev/hdc
# mount /dev/hdc /var/log/mount
Using NFS as the installation medium requires some more steps. First of all, you will have to load the network disk. You can do this by running the network command and inserting a network disk. You can also load this disk from another medium, for example from an USB memory stick. Suppose that you have mounted a USB memory stick on /var/log/mount, you can load the network disk with: network /var/log/mount/network.dsk. After loading the network disk, you will have to configure the network interface. If the NFS server is on the same network, you will only have to assign an IP address to the network interface. For example, to use the address 192.168.2.201, you could execute the following command:
# ifconfig eth0 192.168.2.201
You can then load the portmapper, which is necessary for the NFS client to function correctly:
# /sbin/rpc.portmap
If the portmapper started correctly, you can mount the
NFS volume. But, first make sure that you unmount any filesystem
that you have previously mounted at /var/log/mount/var/log/mount
# mount -r -t nfs -o nolock 192.168.2.1:/home/pub/slackware-current /var/log/mount
If no errors where printed when the volume was mounted, it should be
accessible through /var/log/mount
Everything is now set up to start installing packages from the
installation medium. Since installpkg is
available from the installation system, you can use it to
install Slackware Linux packages. To install packages to the
target partition(s) mounted on /mnt-root option. The
following command installs all packages from the source medium:
# installpkg -root /mnt /var/log/mount/slackware/*/*.tgz
If you have created tagfiles to define which packages should be
installed, then you can use them now (tagfiles are described
in Section 17.4, “Tagfiles”). Suppose that you have
stored a tagfile for each disk set in
/usr/share/tagfiles/small-desktop
# for p in a ap d e f k kde kdei l n t tcl x xap y; do
installpkg -infobox -root /mnt \
-tagfile /usr/share/tagfiles/small-desktop/$p/tagfile \
/var/log/mount/slackware/$p/*.tgz
done
The next sections describe the bare minimum of configuration that is necessary to get a running system.
One of the necessary configuration steps is to create a fstab
file, so that the system can look up what partitions or volumes have
to be mounted. The format of the /etc/fstab//procdevpts
With the sample partitioning used earlier in this chapter, you
could create a /etc/fstab
# cat > /mnt/etc/fstab << EOF
/dev/hda2 swap swap defaults 0 0
/dev/hda1 / ext3 defaults 1 1
devpts /dev/pts devpts gid=5,mode=620 0 0
proc /proc proc defaults 0 0
EOF
To make the system bootable you will have to configure and install
the Linux Loader (LILO). The configuration of LILO is covered in
Section 19.1, “The bootloader”. For this section we will
just show a sample LILO configuration, that can be used with
the partition layout described in this chapter. The first step
is to create the /etc/lilo.conf
# cat > /mnt/etc/lilo.conf << EOF
boot = /dev/hda
vga = normal
timeout = 50
image = /boot/vmlinuz
root = /dev/hda1
label = Slackware
read-only
EOF
You can then install LILO with /mnt/mnt/etc/lilo.conf
# lilo -r /mnt
The configuration of networking in Slackware Linux is covered in Chapter 22, Networking configuration. This section will cover one example of a host that will use DHCP to get an IP address.
The /etc/networks
# cat > /mnt/etc/networks << EOF
loopback 127.0.0.0
localnet 127.0.0.0
EOF
Although we will get a hostname via DHCP, we will still set up a temporary hostname:
# cat > /mnt/etc/HOSTNAME << EOF
sugaree.example.net
EOF
Now that the hostname is configured, the hostname and
localhost should also be made
resolvable, by creating a /etc/hosts
# cat > /mnt/etc/hosts << EOF
127.0.0.1 localhost
127.0.0.1 sugaree.example.net sugaree
EOF
We do not have to create a /etc/resolv.conf/etc/rc.d/rc.inet1.conf
# cat > /mnt/etc/rc.d/rc.inet1.conf << EOF
IPADDR[0]=""
NETMASK[0]=""
USE_DHCP[0]="yes"
DHCP_HOSTNAME[0]=""
EOF
You may wat to make a backup of the old
rc.inet1.conf
# sed -i 's/USE_DHCP\[0\]=""/USE_DHCP[0]="yes"/' \
/mnt/etc/rc.d/rc.inet1.conf
Depending on the purpose of the system that is being installed, it should be decided which initialization scripts should be started. The number of services that are available depends on what packages you have installed. You can get get a list of available scripts with ls:
# ls -l /mnt/etc/rc.d/rc.*
If the executable bits are set on a script, it will be started, otherwise it will not. Obviously you should keep essential scripts executable, including the runlevel-specific scripts. You can set the executable bit on a script with:
# chmod +x /mnt/etc/rc.d/rc.scriptname
Or remove it with:
# chmod -x /mnt/etc/rc.d/rc.scriptname
GNU/Linux uses a cache for loading dynamic libraries. Besides that
many programs rely on generic version numbers of libraries
(e.g. /usr/lib/libgtk-x11-2.0.so/usr/lib/libgtk-x11-2.0.so.0.600.8
# chroot /mnt /sbin/ldconfig
You may not know the chroot command; it is
a command that executes a command with a different root than
the active root. In this example the root directory is changed
to /mnt
Now that the dynamic library cache and links are set up, you
can execute commands on the installed system. We will make use
of this to set the root password. The
passwd command can be used to set the
password for an existing user (the root
user is part of the initial /etc/passwd
# chroot /mnt /usr/bin/passwd root
On UNIX-like systems it is important to set the timezone correctly,
because it is used by various parts of the system. For instance,
the timezone is used by NTP to synchronize the system time correctly,
or by different networking programs to compute the time difference
between a client and a server. On Slackware Linux the timezone can be
set by linking /etc/localtime/mnt/usr/share/zoneinfo
# cd /mnt # rm -rf etc/localtime # ln -sf /usr/share/zoneinfo/Europe/Amsterdam etc/localtime
After setting the time zone, programs still do not know whether
the hardware clock is set to the local time, or to the Coordinated
Universal Time (UTC) standard. If you use another operating system
on the same machine that does not use UTC it is best to set the
hardware clock to the local time. On UNIX-like systems it is a
custom to set the system time to UTC. You can set what time the
system clock uses, by creating the file
/etc/hardwareclock/etc/hardwareclock
# echo "UTC" > /mnt/etc/hardwareclock
It is easy to combine the steps of a custom installation into one script, which performs the custom steps automatically. This is ideal for making default server installs or conducting mass roll-outs of Linux clients. This sections contains a sample script that was written by William Park. It is easy to add an installation script to the Slackware Linux medium, especially if you use an installation CD-ROM or boot the installation system from an USB flash drive.
The installation system is stored in one compressed image file,
that is available on the distribution medium as
isolinux/initrd.img
# mv initrd.img initrd.img.gz # gunzip initrd.img.gz
After decompressing the image, you can mount the file as a disk, using the loopback device:
# mount -o loop initrd.img /mnt/hd
You can now add a script to the initrd file by adding it to the directory structure that is available under the mount point. After making the necessary changes, you can unmount the filesystem and compress it:
# umount /mnt/hd # gzip initd.img # mv initrd.img.gz initrd.img
You can then put the new initrd.img
#! /bin/sh
# Copyright (c) 2003-2005 by William Park <opengeometry@yahoo.ca>.
# All rights reserved.
#
# Usage: slackware-install.sh
rm_ln () # Usage: rm_ln from to
{
rm -rf $2; ln -sf $1 $2
}
###############################################################################
echo "Partitioning harddisk..."
( echo -ne "n\np\n1\n\n+1000M\n" # /dev/hda1 --> 1GB swap
echo -ne "n\np\n2\n\n+6000M\n" # /dev/hda2 --> 6GB /
echo -ne "t\n1\n82\nw\n"
) | fdisk /dev/hda
mkswap /dev/hda1 # swap
swapon /dev/hda1
mke2fs -c /dev/hda2 # /
mount /dev/hda2 /mnt
###############################################################################
echo "Installing packages..."
mount -t iso9660 /dev/hdc /cdrom # actually, /var/log/mount
cd /cdrom/slackware
for p in [a-z]*; do # a, ap, ..., y
installpkg -root /mnt -priority ADD $p/*.tgz
done
cd /mnt
###############################################################################
echo "Configuring /dev/* stuffs..."
rm_ln psaux dev/mouse # or, 'input/mice' for usb mouse
rm_ln ttyS0 dev/modem
rm_ln hdc dev/cdrom
rm_ln hdc dev/dvd
###############################################################################
echo "Configuring /etc/* stuffs..."
cat > etc/fstab << EOF
/dev/hda1 swap swap defaults 0 0
/dev/hda2 / ext2 defaults 1 1
devpts /dev/pts devpts gid=5,mode=620 0 0
proc /proc proc defaults 0 0
#
/dev/cdrom /mnt/cdrom iso9660 noauto,owner,ro 0 0
/dev/fd0 /mnt/floppy auto noauto,owner 0 0
tmpfs /dev/shm tmpfs noauto 0 0
EOF
cat > etc/networks << EOF
loopback 127.0.0.0
localnet 192.168.1.0
EOF
cat > etc/hosts << EOF
127.0.0.1 localhost
192.168.1.1 node1.example.net node1
EOF
cat > etc/resolv.conf << EOF
search example.net
nameserver 127.0.0.1
EOF
cat > etc/HOSTNAME << EOF
node1.example.net
EOF
## setup.05.fontconfig
chroot . /sbin/ldconfig # must be run before other program
chroot . /usr/X11R6/bin/fc-cache
chroot . /usr/bin/passwd root
## setup.06.scrollkeeper
chroot . /usr/bin/scrollkeeper-update
## setup.timeconfig
rm_ln /usr/share/zoneinfo/Canada/Eastern etc/localtime
cat > etc/hardwareclock << EOF
localtime
EOF
## setup.liloconfig
cat > etc/lilo.conf << EOF
boot=/dev/hda
delay=100
vga=normal # 80x25 char
# VESA framebuffer console:
# pixel char 8bit 15bit 16bit 24bit
# ----- ---- ---- ----- ----- -----
# 1600x1200 796 797 798 799
# 1280x1024 160x64 775 793 794 795
# 1024x768 128x48 773 790 791 792
# 800x600 100x37 771 787 788 789
# 640x480 80x30 769 784 785 786
image=/boot/vmlinuz # Linux
root=/dev/hda2
label=bare.i
read-only
# other=/dev/hda1 # Windows
# label=win
# table=/dev/hda
EOF
lilo -r .
## setup.xwmconfig
rm_ln xinitrc.fvwm95 etc/X11/xinit/xinitrc
###############################################################################
echo "Configuring /etc/rc.d/rc.* stuffs..."
cat > etc/rc.d/rc.keymap << EOF
#! /bin/sh
[ -x /usr/bin/loadkeys ] && /usr/bin/loadkeys us.map
EOF
chmod -x etc/rc.d/rc.keymap
## setup.mouse
cat > etc/rc.d/rc.gpm << 'EOF'
#! /bin/sh
case $1 in
stop)
echo "Stopping gpm..."
/usr/sbin/gpm -k
;;
restart)
echo "Restarting gpm..."
/usr/sbin/gpm -k
sleep 1
/usr/sbin/gpm -m /dev/mouse -t ps2
;;
start)
echo "Starting gpm..."
/usr/sbin/gpm -m /dev/mouse -t ps2
;;
*)
echo "Usage $0 {start|stop|restart}"
;;
esac
EOF
chmod +x etc/rc.d/rc.gpm
## setup.netconfig
cat > etc/rc.d/rc.inet1.conf << EOF
IPADDR=(192.168.1.1) # array variables
NETMASK=(255.255.255.0)
USE_DHCP=() # "yes" or ""
DHCP_HOSTNAME=()
GATEWAY=""
DEBUG_ETH_UP="no"
EOF
cat > etc/rc.d/rc.netdevice << EOF
/sbin/modprobe 3c59x
EOF
chmod +x etc/rc.d/rc.netdevice
## setup.setconsolefont
mv etc/rc.d/rc.font{.sample,}
chmod -x etc/rc.d/rc.font
## setup.services
chmod +x etc/rc.d/rc.bind
chmod +x etc/rc.d/rc.hotplug
chmod +x etc/rc.d/rc.inetd
chmod +x etc/rc.d/rc.portmap
chmod +x etc/rc.d/rc.sendmail
#
chmod -x etc/rc.d/rc.atalk
chmod -x etc/rc.d/rc.cups
chmod -x etc/rc.d/rc.httpd
chmod -x etc/rc.d/rc.ip_forward
chmod -x etc/rc.d/rc.lprng
chmod -x etc/rc.d/rc.mysqld
chmod -x etc/rc.d/rc.pcmcia
chmod -x etc/rc.d/rc.samba
chmod -x etc/rc.d/rc.sshd