KEMBAR78
Linux Kernel Project Guide | PDF | Operating System | Sudo
0% found this document useful (0 votes)
120 views3 pages

Linux Kernel Project Guide

This document provides instructions for building a custom Linux kernel from source and adding a new system call to the kernel. It outlines the steps to: 1. Download and install kernel development tools. Obtain the source code for the current running kernel and for a new kernel version. 2. Configure and compile the new kernel, create a compressed image, install kernel modules and the new kernel. Modify the GRUB configuration file and reboot with the new kernel. 3. Add a simple "helloworld" system call to the kernel that prints a message to syslog. Implement the system call in the kernel and write a user-level program to test it. 4. Write a C program to create a parent process

Uploaded by

giaphuc2004hg
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
120 views3 pages

Linux Kernel Project Guide

This document provides instructions for building a custom Linux kernel from source and adding a new system call to the kernel. It outlines the steps to: 1. Download and install kernel development tools. Obtain the source code for the current running kernel and for a new kernel version. 2. Configure and compile the new kernel, create a compressed image, install kernel modules and the new kernel. Modify the GRUB configuration file and reboot with the new kernel. 3. Add a simple "helloworld" system call to the kernel that prints a message to syslog. Implement the system call in the kernel and write a user-level program to test it. 4. Write a C program to create a parent process

Uploaded by

giaphuc2004hg
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

CT104H – Operating System

CAN THO UNIVERSITY


COLLEGE OF INFORMATION AND COMMUNICATION TECHNOLOGY
DEPARTMENT OF INFORMATION TECHNOLOGY
OPERATING SYSTEMS (CT104H)
PROJECT

Declaration of own work


I, YOUR FULL NAME (ID student) , certify that this assignment is my own work, is not copied from
any other person's work.

Virtual machine: Ubuntu VM

Submission:
- A report describes clearly how did you solve problems
- All programs (in both kernel-level codes and user-level codes for testing) with comments (zip them in
a .RAR file)

PART 1: BUILD THE LINUX KERNEL

*** Note: At the first step, it will be better if you install an old version of OS kernel. Then, the process
of building a new Linux kernel will be clear

You need to be a root user (root user)


$su -

A. GET THE LINUX KERNEL CODE


1. Download and install development tools on your system.
$sudo apt-get install -y gcc libncurses5-dev make wget
$sudo apt-get install -y gcc libssl-dev
$sudo apt-get install bison
$sudo apt-get install flex

2. Obtain the version of your current kernel, type:


# uname –r

you will have something like: 4.4.0-31-generic (Ubuntu)

3. Visit http://kernel.org and download the source code of your current running kernel. Then, download a
new kernel from https://www.kernel.org/ (e.g., 4.16.3) and extract the source:

# wget http://www.kernel.org/pub/linux/kernel/v4.x/linux-4.16.3.tar.gz
# tar xvzf linux-4.16.3.tar.gz

Lecturer: Lam Nhut Khang


1
CT104H – Operating System
B. CONFIGURE YOUR NEW KERNEL
1. Make sure you are at ~/linux-4.16.3 such that the “linux-4.16.3” is the top directory of the kernel source.
2. Generate the configuration file
# make menuconfig
Do not change anything. Press ESC to save and exit the configuration menu. The configuration file will be
generated

C. COMPILE THE KERNEL


1. At ~/linux-4.16.3, create a compressed kernel image
# make –j4

2. To compile kernel modules:


# make modules

D. INSTALL THE KERNEL


1. Install kernel modules
# make modules_install

2. Install the kernel


# make install

E. MODIFY GRUB CONFIGURATION FILE (GRUB CONFIGURATION FILE)


Change the grub configuration file:
# vim /etc/default/grub

Make the following changes:


GRUB_DEFAULT=0
GRUB_TIMEOUT=25

F. REBOOT VM
1. Reboot to the new kernel
# reboot

2. After boot, check if you have the new kernel:


# uname -r
You will see something like: 4.16.3

Lecturer: Lam Nhut Khang


2
CT104H – Operating System

PART 2: ADD A NEW SYSTEM CALL INTO THE LINUX KERNEL

We add a simple system call helloworld to the Linux kernel. The system call prints out a “Hello! My name is
XXX” message to the syslog (XXX is your student name and your student ID). You need to implement the
system call in the kernel and write a program at the user-level to test your created system call.

These are very good articles to start:


- https://www.kernel.org/doc/html/v4.10/process/adding-syscalls.html
- https://brennan.io/2016/11/14/kernel-dev-ep3/
- https://medium.com/@ssreehari/implementing-a-system-call-in-linux-kernel-4-7-1-
6f98250a8c38
- https://medium.com/anubhav-shrimal/adding-a-hello-world-system-call-to-linux-kernel-
dad32875872
- https://linux.die.net/man/2/syscalls

PART 3: PROCESS
Write a program in C to create a parent process P1. The parent process P1 forks a child (named P2) and waits
for the child to complete the program multiplicationtable. The child process prints its pid, executes the
multiplicationtable program and then exits. The multiplicationtable gets an argument arg and prints the arg
times table. When P2 is finished, P1 prints the information of P2 including pid and the exit state, and then exits.
----------------------THE END ----------------------

Lecturer: Lam Nhut Khang


3

You might also like