A Kernel Compiling Adventure By Grant Nelson
By Grant Nelson Goals Virtual Ubuntu Compiling a New Kernel - - PowerPoint PPT Presentation
By Grant Nelson Goals Virtual Ubuntu Compiling a New Kernel - - PowerPoint PPT Presentation
A Kernel Compiling Adventure By Grant Nelson Goals Virtual Ubuntu Compiling a New Kernel Complications Installing Ubuntu on WinXP Building a Block Scheduler Conclusion 2 Read entire document before performing the
- Goals
- Virtual Ubuntu
- Compiling a New Kernel
- Complications
- Installing Ubuntu on WinXP
- Building a Block Scheduler
- Conclusion
2
Read entire document before performing the
steps laid out in this document.
Note that the methods in this document
worked on my person computers but are not guaranteed to work on your own.
3
- Goals
- Virtual Ubuntu
- Compiling a New Kernel
- Complications
- Installing Ubuntu on WinXP
- Building a Block Scheduler
- Conclusion
4
Install Ubuntu Compile a new kernel Change the scheduler
5
Since the scheduling algorithm is O(n), a large
number of processes (~400) will cause each process duration (quantum) to be less than the schedule time. (May 2008)
One option is to lengthen the quantum value,
but that can cause I/O processes to be slow.
Another is overhaul the scheduling algorithm,
but that would take more work and knowledge
- f the system than I have.
(Scheduler was overhauled around Sept 2008)
6
Block scheduling uses the current scheduling
method but increases the speed by a magnitude, therefore it is still O(n), but it allows around 4000 processes instead of 400.
More on that later…
7
- Goals
- Virtual Ubuntu
- Compiling a New Kernel
- Complications
- Installing Ubuntu on WinXP
- Building a Block Scheduler
- Conclusion
8
Don’t have a computer which you can install
Ubuntu onto? Or don’t want to risk messing up your current system?
Use a virtual machine. I was going to install Ubuntu in a VM (Virtual
Machine) on my Dell laptop with Vista.
9
Visit www.ubuntu.com Download the latest version of Ubuntu
Desktop Disk Image and save it. (I used 8.04)
This will take a while. (1-2 hours) Continue while download is completing.
10
Go to FileHippo.com and click on the
Development Tools group.
Locate VirtualBox (typically x86) and
download newest version.
Install VirtualBox just like any other Window
application.
11
Startup the
VirtualBox
Click
- n New
12
Click Next Enter a Name
for the new VM
- I used Ubuntu, why not?
And select Ubuntu
as the OS Type
13
Select RAM for
the new VM (~1GB)
14
Click New Create a
Dynamically Expanding VHD (~10G)
15
Once done
setting up a new Virtual Machine the Guest OS needs to be installed.
16
Click on
Settings
Select
CD/DVD-Rom
Set the
recently downloaded Ubuntu Image
17
Click Start Click on
Start or install Ubuntu
18
Once Ubuntu starts
click on the Install icon to begin install.
19
Go through install
- ptions.
Most are straight
forward.
Use default if
answer is unknown.
20
The install will take
about an hour.
When complete don’t
- restart. Select to
continue working with the LiveCD, then shut down completely.
21
Go into
Settings and remove Ubuntu CD Image.
Click start to
boot up the newly installed Virtual Ubuntu.
22
- Goals
- Virtual Ubuntu
- Compiling a New Kernel
- Complications
- Installing Ubuntu on WinXP
- Building a Block Scheduler
- Conclusion
23
Log in as root for session Avoid a possible problem
▪ Some versions have a problem with the symbolic link /bin/sh pointing to /bin/dash
Update package database
24
su rm –f /bin/sh ln –s /bin/bash /bin/sh apt-get update
Install needed packages Go shopping for your kernel source
- www.kernel.org/pub/linux/kernel/v2.6/
- I went with 2.6.24.1, because I could.
- Download it using the release number.
25
apt-get install kernel-package libncurses5-dev fakeroot wget bzip2 cd /usr/src wget http://www.kernel.org/pub/linux/kernel/ v2.6/linux-2.6.24.1.tar.bz2
Unpack kernel sources Create symbolic link Then go to sources Copy the existing configuration
26
tar xjf linux-2.6.24.1.tar.bz2 ln –s linux-2.6.24.1 linux cd /usr/src/linux cp /boot/config-’uname –r’ ./.config
To configure First load an
Alternate Configuration File: “.config”.
I found it is best not
to make changed from the current configuration.
On Exit, Save.
27
make menuconfig
To make a clean start
- This will remove object files and cause a compile to take longer.
To compile the kernel
- The first compile might take around 5 hours
- On a virtual machine it can take up to twice as long.
- You may replace “custom” with any ID for the new kernel as long as it
doesn’t contain whitespace.
28
make-kpkg clean fakeroot make-kpkg --initrd --append-to-version=
- custom kernel_image kernel_headers
Discover the newly built packages Install new kernel packages Check grub, the boot menu
29
cd /usr/src ; ls -l dpkg –i linux-image-2.6.24.1-custom_2.6.24.1- custom-10.00.Custom_i386.deb dpkg –i linux-headers-2.6.24.1-custom_2.6.24.1- custom-10.00.Custom_i386.deb Vi /boot/grub/menu.lst
Reboot Ubuntu While restarting, select the new kernel.
- If installed correctly it should load properly.
Check that the new kernel is running.
30
shutdown –r now uname -r
- Goals
- Virtual Ubuntu
- Compiling a New Kernel
- Complications
- Installing Ubuntu on WinXP
- Building a Block Scheduler
- Conclusion
31
The after one successful compile, I added
printk that would show up while booting.
The kernel compiled correctly but wouldn’t
- boot. I removed the printk recompiled but it
still wouldn’t boot. Something was wrong with the configuration.
That is when I noticed another problem…
32
While compiling Ubuntu in a VM, on my Dell
laptop, the compiler used 100% CPU and the Disk I/O became very high.
The compile lasted for 5 hours the first time.
After that it took 4 hours. Making it hard to test changes.
This also caused my computer to become
incredibly hot … way too hot.
33
I got an over-temp shutdown. I didn’t want to damage my laptop, so I
decided to install Ubuntu onto my older desktop with XP.
34
- Goals
- Virtual Ubuntu
- Compiling a New Kernel
- Complications
- Installing Ubuntu on WinXP
- Building a Block Scheduler
- Conclusion
35
Burn the previously downloaded Ubuntu CD
Image to a CD. (I used Alcohol 120)
Backup your XP data, just incase. Reboot computer Startup into Ubuntu LiveCD
36
Click Start
- r install
Ubuntu
Select
Language, Location, and Keyboard
37
Give about
10.0GB for Linux
It might
take a while to move Windows.
38
Finish setting up
personal options.
Once install is done,
the CD will eject, remove it then restart.
Log into Ubuntu
39
If all when well during boot Grub will show up given the
- ption to boot into either Windows XP or Ubuntu.
I repeated “Compiling a New Kernel” This time it worked instantly, even after I added the
printk.
The first compile took 3 hours, all subsequent compiles
took about 30 minutes to an hour.
And with better cooling the computer didn’t get as hot.
40
- Goals
- Virtual Ubuntu
- Compiling a New Kernel
- Complications
- Installing Ubuntu on WinXP
- Building a Block Scheduler
- Conclusion
41
The scheduler contains a linked list of scheduling
groups: real-time, fair, and idle.
- sched_rt.c, sched_fair.c, sched_idletask.c
When one group returns a non-null process that
process it placed into the ready to run queue.
- Idle is always last, since it will always return a non-null: the idle process.
The real-time and fair groups have a linked list of
- processes. (pseudo-code similar to line 3631 sched.c)
42 *group = static &sched_rt; while(1) { pid = group->pick_next_task(); if(pid!=null) schedule(pid); group = group->next; }
The left shows the current
scheduler with all static groups.
The right shows a block
scheduler which just brakes the fair group into several
- groups. These groups are
sorted by their max and min processes.
43
real-time static fair idle real-time fair idle fair fair
Make the fair scheduler no longer static and
allocate memory for it when the fair scheduler is added to real-time scheduler.
At this point the scheduler should still work the
exact same way.
Next add a max-nice and min-nice level which
contains the current max and min “nice” (priority) levels.
44
I would like to
say everything continued working perfectly…
However,
everything got fubar.
45
Three weeks ago (around Nov 23rd) my desktop stopped
- functioning. While the Bios is starting up it fails to
detect a keyboard.
This has no relation to the changes to the Linux
scheduler.
I have tried all I could to recover my code and get my
computer to startup, but I ran out of time.
If only I hadn’t started on a VM, if only my desktop
hadn’t failed, or if only I had a whole year.
46
- Goals
- Virtual Ubuntu
- Compiling a New Kernel
- Complications
- Installing Ubuntu on WinXP
- Building a Block Scheduler
- Conclusion
47
DON’T COMPILE LINUX
…unless you have way too much free time.
48
www.ubuntu.com
www.filehippo.com
www.psychocats.net/ubuntu/virtualbox
- reilly.com/catalog/linuxkernel/chapter/ch10.html
www.howtoforge.com/kernel_compilation_ubuntu
www.kernel.org/pub/linux/kernel/v2.6/
apcmag.com/how_to_dual_boot_windows_xp_and_linux_xp_installed_first.htm
49