CS 498 Lecture 1: Installing, Compiling and Configuring Linux Kernel - PowerPoint PPT Presentation

1 / 29
About This Presentation
Title:

CS 498 Lecture 1: Installing, Compiling and Configuring Linux Kernel

Description:

Is stored in the computer's ROM and described as firmware. ... stage boot loader on the partition configured as bootable (/boot partition) ... – PowerPoint PPT presentation

Number of Views:328
Avg rating:3.0/5.0
Slides: 30
Provided by: Universit112
Category:

less

Transcript and Presenter's Notes

Title: CS 498 Lecture 1: Installing, Compiling and Configuring Linux Kernel


1
CS 498 Lecture 1 Installing, Compiling and
Configuring Linux Kernel
  • Jennifer Hou
  • Department of Computer Science
  • University of Illinois at Urbana-Champaign

2
Boot Process
  • Reading
  • 1. Red Hat Linux 9 Read hat Linux Reference
    Guide, Chapter 1 Boot process, Init, and
    Shutdown.

3
Boot Process
  • The basic input/output system (BIOS) starts and
    checks for hardware devices.
  • Is stored in the computers ROM and described as
    firmware.
  • Finds the hardware devices (diskette drives,
    CD-ROM drives, and hard drives) needed by the
    boot process.
  • Loads and initiates the boot program stored in
    the Master Boot Record (MBR, residing in the
    first sector of the device), and passes control
    to the boot program.

4
A Hard Drives Partition Layout
Partition 4 is used as a placeholder for a
potentially large number of logical partitions -?
extended partition.
Boot Code (grub)
Partition 1 definition (16 bytes)
Partition 2 definition (16 bytes)
Partition 3 definition (16 bytes)
Partition 4 definition (16 bytes)
Magic number (2 bytes)
Partition 1 (/dev/hda1 or /boot)
Partition 2 (/dev/hda2)
Partition 3 (/dev/hda3)
Partition 4 (/dev/had4 no
filesystem)
Partition 5 (/dev/had5)
Partition 4 (/dev/had6)
5
First Stage Boot Loader
  • Two boot loaders are available Linux Loader
    (lilo) and Grand Unified Bootloader (grub)
  • The first-stage boot loader
  • reads in the partition table and looks for the
    second-stage boot loader on the partition
    configured as bootable (/boot partition).
  • Launches the second stage boot loader.

6
Second Stage Boot Loader
  • Presents the user with different OS kernels it
    has been configured to boot.
  • Finds the kernel image in the /boot directory.
  • The kernel binary is named /boot/vmlinuz-ltkernel-v
    ersiongt
  • Places the appropriate initial RAM disk image,
    called an initrd, into memory. The initrd is used
    by the kernel to load drivers necessary to boot
    the system.
  • Hands control to the kernel.

7
grub.conf
  • grub.conf generated by anaconda
  • Note that you do not have to rerun grub after
    making changes to this\
  • file
  • NOTICE You have a /boot partition. This
    means that
  • all kernel and initrd paths are
    relative to /boot/, eg.
  • root (hd0,1)
  • kernel /vmlinuz-version ro
    root/dev/hdb3
  • initrd /initrd-version.img
  • boot/dev/hdb
  • default0
  • timeout10
  • splashimage(hd0,1)/grub/splash.xpm.gz
  • title Linux Fedora (2.6.5-1.358smp)
  • root (hd0,1)
  • kernel /vmlinuz-2.6.5-1.358smp ro
    rootLABEL/ rhgb quiet
  • initrd /initrd-2.6.5-1.358smp.img
  • title Linux Fedora-up (2.6.5-1.358)
  • root (hd0,1)

Specifies the default boot image will be the
first hard entry
Grub will wait for 10 seconds for input from the
user before continuing to boot.
The root partition is the second partition on the
first hard drive.
8
The Kernel
  • Initializes and configures the computers memory
    and configures hardware attached to the system
    (processors, I/O subsystems, and storage
    devices).
  • Decompresses and mounts initrd to loads all
    necessary drivers.
  • Mounts the root filesystem in read-only mode and
    frees any unused memory.
  • Starts the init process by running /sbin/init.

9
Initialization Process
  • Init parses the /etc/inittab file to determine
    the specifics of what programs to run and at what
    level.
  • 0 used to halt the system. The system performs
    an init 0 command and the system is halted.
  • 1 Puts he system into single-user mode.
  • 2 Puts the system into a multiuser mode but does
    not support networking.
  • 3 Puts the system into the standard full
    multiuser mode but does not automatically start
    X.
  • 4 Unused.
  • 5 X11 Puts the system into standard multiuser
    mode with a graphical (X-based) login.

10
Inittab
  • id5initdefault
  • Tells the init program what run level to use
    after a reboot.
  • sisysinit/etc/rc.d/rc.sysinit
  • Tells the init program to run the rc.sysinit
    script.
  • Since the second field is empty, the script will
    run at boot time for all run levels.

11
rc.systinit
  • Setting the path and the hostname, and checking
    whether networking is activated.
  • Mounting the /proc filesystem
  • Setting the kernel parameters
  • Setting the system clock
  • Loading keymaps and fonts
  • Starting swapping
  • Initializing the USB controller along with the
    attached devices.
  • Checking the root filesystem.
  • Remounting the root filesystem as read-write.
  • Loading modules as appropriate.

12
Inittab (contd)
  • Starts the /etc/rc.d/rc script with the
    appropriate run level.
  • The rc script executes all of the scripts pointed
    to by the symblic links contained in the
    directory for that run level.
  • For example, if the run level is 3, the scripts
    pointed to by the links in /etc/rc.d/rc3.d are
    run.

13
/etc/rc.d/rc3.d
  • ls
  • K01yum K35vncserver K74ypserv
    S12syslog S28autofs S90xfs
  • K05saslauthd K36lisa K74ypxfrd
    S13irqbalance S40smartd S95anacron
  • K10dc_server K45named K89netplugd
    S13portmap S44acpid S95atd
  • K10psacct K50netdump K99readahead
    S14nfslock S55cups S97messagebus
  • K12dc_client K50snmpd K99readahead_early
    S18rpcgssd S55sshd S97rhnsd
  • K15httpd K50snmptrapd S00microcode_ctl
    S19rpcidmapd S56rawdevices S99local
  • K20nfs K50tux S05kudzu
    S19rpcsvcgssd S56xinetd S99mdmonitor
  • K24irda K50vsftpd S06cpuspeed
    S20random S80sendmail S99mdmpd
  • K25squid K70aep1000 S08iptables
    S24pcmcia S85gpm
  • K34yppasswdd K70bcm5820 S09isdn
    S25netfs S87IIim
  • K35smb K74ntpd S10network
    S26apmd S90crond
  • All the files here are only symbolic links to the
    actual scripts that exist in /etc/rc.d/init.d.
  • The system first runs the scripts whose names
    start with K to kill the associated processes ?
    /etc/rc.d/init.d/ltcommandgt stop
  • The system runs the scripts whose names start
    with S to start the processes ?
    /etc/rc.d/init.d/ltcommandgt start
  • Changing a K name to start with S (e.g., K20nfs ?
    S20nfs) makes Linux start the process rather than
    kill it.

14
Inittab (contd)
  • cactrlaltdel/sbin/shutdown -t3 -r now
  • Sets the CtrlAltDelete key combination to
    indicate a reboot of the system.
  • -t option indicates that the init process waits
    for 3 seconds after sending the warning message
    and before sending the kill signal.
  • pfpowerfail/sbin/shutdown -f -h 2 "Power
    Failure System Shutting Down"
  • pr12345powerokwait/sbin/shutdown -c "Power
    Restored Shutdown Cancelled"
  • 32345respawn/sbin/mingetty tty3
  • Initializes the ttys, provides the lgin and
    retrieve the user-input data, and then starts a
    login process for the user.

15
Building the Kernel
  • Reading
  • 1.http//www.digitalhermit.com/linux/Kernel-Build-
    HOWTO.html
  • 2. Red hat Linux 9 Red Hat Linux Customization
    Guide Appendix A. Building a Custom Kernel.

16
Building the Kernel
  • cd /usr/src/linux-2.4.20-8
  • make xconfig
  • This command runs a X-based configuration tool
    that asks you specific question about every
    kernel configuration.

17
Building the Kernel (Contd)
  • make xconfig
  • Most kernel features have three compilation
    options Y (compiling the option directly into
    the kernel), N (not compiling the option at all),
    and M (compiling the option as a kernel module.
  • After saving the selection, the configuration
    file /user/src/linux-2.4.20-8/.config is created.

18
Building the Kernel (Contd)
  • make dep
  • Creates dependency information, so that the
    compiler knows each components dependencies and
    can compile components as appropriate.
  • make clean
  • Cleans up some miscellaneous object files.
  • make bzImage
  • Compiles the Linux kernel properly.
  • The result is a kernel file called bzImage and
    located in /user/src/linux-2.4.20-8/arch/i386/boot
  • make modules
  • Compiles the kernel modules files

19
Building the Kernel (Contd)
  • make modules_install
  • Installs the kernel modules into the directory
    path /lib/modules/2.4.20-8/kernel/drivers.
  • make install
  • Copies the new kernel and its associated files to
    /boot directory.
  • Builds a new initrd image and adds new entries to
    the boot loader configuration file.
  • Use the command ls -l /boot to make sure the
    initrd-2.4.20-8.img file was created.
  • Confirm that the file /boot/grub/grub.conf
    contains a title section with the same version as
    the kernel package just installed

20
Configuring the Network Interface
  • Reading man pages for ifconf, route, ping,
    netstat, traceroute

21
ifconfig
  • ifconfig interface options address
  • interface network interface, e.g., eth0
  • options up, down, netmask mask
  • address IP address
  • Examples for physical host 1
  • ifconfig eth0 192.168.2.2 ifconfig eth1
    192.168.3.1
  • ifconfig eth0
  • Ifconf eth0 netmask 255.255.255.0 192.168.2.2
  • /sbin/ifup eth0 /sbin/infdown eth0

22
route
  • route add del -net -host target gw
    gateway dev if
  • target is the IP address or network address to
    which the route applies.
  • One special target is the default route ---
    0.0.0.0. or default
  • gw gateway
  • Examples for physical host
  • route add net 192.168.1.0 eth0
  • route add net 192.168.2.0 eth0
  • route add 192.168.3.2 eth0
  • route add default gw 192.168.3.2

23
Making a host to become a router
  • The Linux kernel configuration parameter to
    achieve this is named net.ipv4.ip_forward and can
    be found in the file /etc/sysctl.conf.
  • Enables packet forwarding net.ipv4.ip_forward1
  • This enables packet forwarding only when we
    reboot at which time Linux will create a file in
    one of the subdirectories of the /proc
    filesystem.
  • To activate the feature immediately you have to
    force Linux to read the /etc/sysctl.conf file
    with sysctl p
  • Alternatively, echo 0 gt /proc/sys/net/ipv4/ip_forw
    ard

24
netstat
  • netstat -r displays the kernel routing table in
    the same way as route does.
  • netstat i displays statistics for the network
    interfaces currently configured.
  • If the a option is also given, it prints all
    interfaces present in the kernel, not only those
    that have been configured currently.
  • netstat supports a set of options to display
    active or passive sockets. The options t, u,
    w, and x show active TCP, UDP, RAW, or Unix
    socket connections. If you provide the a flag in
    addition, sockets that are waiting for a
    connection (i.e., listening) are displayed as
    well.

25
Setting up NFS
  • Reading
  • Red Hat Linux 9 Red Hat Linux Reference Guide,
    Chapter 9 NFS
  • Red Hat Linux 9 Red Hat Linux Customization
    Guide, Chapter16 NFS

26
On the Server Side
  • The nfs service must be running on the server
  • /sbin/service nfs status
  • /sbin/service nfs start
  • To start the nfs service at boot time,
  • /sbin/chkconfig level 345 nfs on
  • Edit the /etc/exports file
  • /home flamingo(rw) lion(ro) sal.cs.uiuc.edu(rw)
  • /mnt .cs.uiuc.edu(rw)
  • /opt 192.168.0.0/28(ro)
  • Inform the NFS daemon of the configuration change
  • /sbin/service nfs reload

27
On the Client Side
  • There are three methods
  • Mount -t nfs server/path mountpoint
  • Mount linux.cs.uiuc.edu/linux/redhat
    /misc/myredhat mounts the /linux/redhat from
    linux.cs.uiuc.edu on the client, at
    /misc/myredhat.
  • Add a line in /etc/fstab
  • device mountpoint fs
    operations dump fsck
  • linux/linux/redhat /misc/myredhat nfs
    ro,soft,timeo10 0 0
  • where soft/hard specifies whether the program
    should stop and wait (hard) for the server to
    come back if the server is unavailable or if it
    should report an error (soft).
  • The mount point /myredhat must exist on the
    client machine.
  • After adding the above line to /etc/fstab on the
    client, type mount /myredhat at a shell prompt
    and the mount point will be mounted.

28
On the Client Side
  • Mount NFS using autofs
  • Autofs uses the automount daemon to manage mount
    points by only mounting them dynamically when
    they are accessed.
  • Edit the automounters configuration file,
    /etc/auto.master.
  • Each line contains the base automount point
    (e.g.,/misc), the configuration file for that
    mount point (e.g., /etc/auto.misc) and a timeout
    value.
  • /misc /etc/auto.misc --timeout 60

29
On the Client Side
  • Mount NFS using automount
  • Edit the /etc/auto.misc configuration file.
  • The file lists specific subdirectories within the
    mount point (/misc), filesystem type, and files
    (for each server) to be auto-mounted.
  • myredhat -ro,soft,intr linux.cs.uiuc.edu/linux/
    redhat
  • myfedora -ro,soft,timeo10 linux.cs.uiuc.edu/li
    nux/fedora
  • The /misc/myredhat directory will be automounted
    when accessed.
  • /sbin/service autofs restart
  • /sbin/service autofs status
  • /sbin/service autofs reload
Write a Comment
User Comments (0)
About PowerShow.com