Linux Installation Kernel Compilation and Kernel Build Dr
Linux Installation, Kernel Compilation, and Kernel Build Dr. Ching-Cheng Lee
Outline n Linux Distributions n Linux Installation n Fedora Core 4 Installation n Kernel Source Installation n Linux kernel Source Tree n Kernel Compilation/Build n Example: New System Call/Kernel
Linux Distributions n Debian GNU/Linux A distribution produced by Debian Project, maintained by volunteers with no commercial intentions. The name came from the founders DEBra and IAN Murdock n Fedora Linux Formally known as Fedora Core Sponsored primarily by Red. Hat with significant community participation. Produced by Fedora Project and was based on the original Red. Hat Distribution and is made entirely of free and open source software
Linux Distributions - Continued n Mandriva Linux Consumer-oriented distribution available in both freely downloadable form and as a boxed retail product. Parent company is Mandriva. n Red Hat Enterprise Linux It is the most successful commercial distribution of Linux. The company offers versions of Red Hat Enterprise Linux (RHEL) for servers and workstations. It also sponsors the non-commercial distribution Fedora. n SUSE Linux It is a family of Linux distributions developed by Novell. It has commercial distributions SLED and free-of-charge open. SUSE (open source community)
Linux Distributions - Continued n Ubuntu A community developed Linux distribution with the slogan “Linux for human beings”. It is one of the most popular Linux distribution for laptops and desktop machines. It is based on Debian GNU/Linux. The name “Ubuntu” is an African word that can be translated as “humanity towards others. ”. n Others There are many other distributions such as: Slackware, Cen. OS, Damn Small Linux, Linspire/Freespire, Linux Mint, PCLinux. OS, etc.
Linux Installation n This presentation shows how to install Fedora Core 4 on a Windows XP as dual boot system n Fedora Core 4 – CDs n Installation size: 2 -3 GB n Installation time: 30 minutes – 1 hr. (average) depending the PC speed. n Microsoft Windows installed first or existing n Backup important data in case corruption n Put the CD (1 st) in the drive
Fedora Core 4 Installation n Insert the CD § To install or upgrade in graphical mode, press <Enter>. . To install………………. . text…type: linux text <Enter>… boot: n Welcome to Fedora Core n Upgrade Examine § Install Fedora Core § Upgrade an existing installation n Language Selection English n Keyboard Configuration U. S. English
Fedora Core 4 Installation - Continue n Installation Type Workstation Server Custom select this to gain complete control and package selection n Disk Partitioning Setup One of the large obstacles for a new user during a Linux installation is partitioning. This process is made easier by selecting automatic Automatic partition? Manually partition with Disk Druid? If you used automatic partitioning, you can either accept the current partition setting (click next) or modify the setup using the manual partitioning tool.
Fedora Core 4 Installation - Continue n Disk Setup Choose where you would like Fedora Core to be installed. n Boot Loader Configuration The GRUB boot loader will be installed on /dev/xxx |Change boot loader| if you do not want to install GRUB n Network Configuration Any network devices you have on the system are automatically detected and shown in the Network Devices list n Firewall Configuration Enable firewall … You can use a firewall to allow access to specific services on your computer from other computer – SSH, HTTP, FTP. .
Fedora Core 4 Installation - Continue n Time Zone Selection Set your time zone such as New York, Pacific region… n Set Root Password n Package Group Selection Select (check) the package groups that you want to install. Once a package group has been selected, click on “Details” to view which are default and add/remove optional ones from that group. n About to Install Click “next” to begin installation…. The Installation log can be found inn /root/install. log (To abort this installation, reset using Control-Alt-Delete) n Will see the following messages on the Screen Installing Packages …. Congratulations, the installation is complete…. reboot your system…
Fedora Core 4 Installation - Continue n Welcome (message) – after reboot There a few more steps to take before your system is ready to use. The setup agent will guide some basic configuration. n License Agreement : Check yes n Date and Time: select and setup n System User Create a system “username”, non- administrative n Additional CDs Insert other CDs for third-party plug-in and applications n Finish Setup Screen show login as follows username:
Kernel Source Installation n Download the kernel source code n Visit http: //kernel. org/ and download the latest source code. File name would be linux-x. y. z. tar. bz 2, where x. y. z is actual version number. For example file inux-2. 6. 23. tar. bz 2 represents 2. 6. 23 kernel version. Use wget command to download kernel source code: n $ cd /tmp $ wget http: //www. kernel. org/pub/linux/kernel/v 2. 6/linuxx. y. z. tar. bz 2 n Note the current kernel version of your Linux can be found: % uname -a n Note: Replace x. y. z with actual version number.
Kernel Source Installation - Continued n Extract tar (. tar. bz 3) file n Type the following command: # tar -xjvf linux-2. 6. 23. tar. bz 2 -C /usr/src # cd /usr/src n # ls (you will see a subdirectory linux-2. 6. 23) n # ln –s linux-2. 6. 23 linux Create soft link “linux” pointing to linux-2. 6. 23 subdirectory Your kernel source subdirectory now will be: /usr/src/linux (Kernel source tree)
Linux Kernel Source Tree n Kernel Source is under /usr/src n n n # cd /usr/src # cd linux # ls (based upon our installation) arch crypto configs Documentation COPYING drivers ipc CREDITS fs n include init Makefile kernel lib net MAINTAINERS README REPORTING-BUGS usr mm scripts # ls kernel acct. c extable. c Makefile profile. c sysctl. c audit. c fork. c module. c ptrace. c sys_ni. c auditsc. c futex. c module-verify. c rcupdate. c time. c capability. c intermodule. c module-verify. h resource. c timer. c …………. . security sound
Kernel Compilation/Build n Kernel Source is under /usr/src n # cd linux (based upon our installation) For other installation, you need to find the subdirectory that has kernel source n # make mrproper This ensure that the kernel source in proper/clean state – usually done in the 1 st time
Kernel Compilation/Build - Continued n Configure the. config File n The. config file contains everything that is specific to the kernel you compile. You must have a starting. config file. For example, you ca use the previous Fedora. config file from the fedora kernel. src. rpm. n If you have another kernel source from another RPM or a previously downloaded kernel source, you can use that. config instead of Fedora's. Bring the. config file up to date to match the new kernel. This will prompt for many new options. If you know what they are, answer them correctly. Otherwise just hit [Enter] even you see no prompts. Usually we suggest that: (this is usually done – especially for our project) n Once done, configure all the necessary options by using any of the following – This step usually can be skipped # make config or (text based) # make oldconfig # make xconfig (GUI based)
Kernel Compilation/Build - Continued n # make all This will compile all the kernel source code using the Makefile and create a compressed kernel image. This step may take between 30 min – 2+ hours depending on the speed of your system. n # make modules compiling kernel modules n # make modules_install Install kernel modules
Kernel Compilation/Build - Continued n # make install Install the kernel. The following files will be installed into the /boot directory System. map-2. 6. x…, config-2. 6. x…. . , vmlinuz-2. 6. x…… (Newly compiled/compressed kernel image) n Edit Grub To set the default to the new kernel, edit /boot/grub. conf. Change the line: default=1 to default=0. This maybe slightly different per each computer. This ensure that the new kernel will be booted by default. n # reboot After reboot, Verify if the new kernel was booted. # uname –a (see the version and date built) If you failed to boot, reboot the old kernel (when powering up the machine, you will see menu selection of kernels to be booted). Otherwise, you must have the original kernel boot image save on a bootable floppy.
Example: New System Call/Kernel n To implement a new system call (i. e. foo), you must modify the kernel source, recompile the kernel, rebuild the kernel. The user program can invoke the new system call with the new kernel n Modify the system call table /usr/src/linux/arch/i 386/kernel/entry. S or (/usr/src/linux/arch/i 386/kernel/syscall_table. S) with new entry: . login SYMBOL_NAME (sys_foo)
Example: New System Call/kernel – Cont. n System Call Stubs for Users § /usr/src/linux/include/asm-i 386/unitstd. h #define __NR_keyctl 288 (last entry) add the following at the end: #define __NR_foo 289 Change the folllowing: #define NR_syscall 289 (changed to 290)
Example: New System Call/Kernel – Cont. n System Call Implementation Routine foo() § Find appropriate subdirectory – let’s say this foo() should be in kernel subdirectory of the source code # cd /usr/src/linux/kernel # vi sys. c (let’s say that we want put this routine in sys. c file) § Follow the same pattern of existing sysall implementation asmlinkage long sys_foo() { …. . printk(KERNEL_EMERG “foo syscall enteredn”); }
Example: New System Call/Kernel – Cont. n Go to /usr/src/linux directory Recompile the kernel source and build new kernel as in previous described steps. n Reboot the new kernel n Verify if the system has the newly build kernel # uname -a n Write a test program to test this new system call
- Slides: 22