Upgrade Linux Kernel

Source: Internet
Author: User
Upgrade the Linux kernel-general Linux technology-Linux programming and kernel information. See the following for details. My PIII Dell machine runs the RedHat of kernel 2.6, and has been trying to upgrade the system to kernel 2.6 since the release of Linux kernel. After a lot of hardships, I finally succeeded. In order to experience the process of writing multi-threaded programs in Linux, we also updated the GCC and C language libraries. I would like to share this experience with you and your friends.
(There may be record Errors for your reference only ).
The procedure includes the following:
1. Specific steps to upgrade the kernel
2. Update GCC
3. Use glibc2.3.5
4. Programming Using NPTL threads

Before that, let's briefly introduce the improvements and new features of Linux kernel 2.6.
Linux2.6 has made great improvements in the following 10 aspects, which are briefly summarized as follows. For more information, see relevant materials.
1) Improve the system's processing capability by improving the parallel processing capability and adopting POSIX Threads, so that Linux truly has the performance required by large information systems.
2) Improve the output/Input Capability of the file system and improve the utilization efficiency of large-capacity memory, so that Linux is more competent to process data in large information systems.
3) Enhanced support for database applications.
4) improves the system's ability to withstand high loads.
5) improves system availability, including support for replacing hardware functions during Backup and non-stop.
6) enhanced network support, and added support for Ipv6, SCTP, IPSec, and so on.
7) the security of the system is improved by adding access control and kernel code.
8) enhanced power management.
9) Enhanced support for Embedded CPUs and systems.
10) added more hardware drivers.

1. Upgrade the kernel
1. Download linux-2.6.3.tar.bz2 (which can be an updated version) to/usr/src.
Bzcat linux-2.6.3.tar.bz2 | tar xvf?
Cd linux-2.6.3
Read the README and Changes files and confirm the necessary tools and software. Because it is not a laptop or laptop-related software, you can ignore it.
Module-init-tools must be updated.
2. Download module-init-tools-0.9.13.tar.bz2
Bzcat module-init-tools-0.9.13.tar.bz2 | tar xvf?
Cd module-init-tools-0.9.13
./Configure -- prefix =/usr/local/module-init
Make
Make moveold
Make install
/Usr/local/module-init/sbin/generate-modpobe.conf>/etc/modprobe. conf
Successful.
3. Compile the Linux Kernel
Cd/usr/src/linux-2.6.3
Make menuconfig
It is too troublesome, and many options are available on the cloud. Exit the program.
Run make oldconfig to disable or default the unfamiliar options added by kernel2.6.
Make bzImage
Make modules modules_install
Pwd
/Usr/src/linux-2.6.3
Mv arch/i386/boot/bzImage/boot/bzImage2.6.3
Mv System. map/boot/System. map-2.6.3
Cd/boot
Mv System. map oldSystem. map
Ln? S System. map-2.6.3 System. map
4. Create a sys directory
Mkdir/sys
5. Modify related files to add support for sys
Added support for sys in the/etc/rc. d/rc. sysinit file.
1) Find mount? F/proc line, under which, add mount? F/sys
2) Find action $ "Mounting proc filesystem:" mount? N? T proc/proc under it, add
Action $ "Mounting sysfs filesystem:" mount? N? T sysfs/sys
3) Change ksyms in the file to kallsyms.
Add a line to the/etc/fstab file
None/sys sysfs defaults 0 0
Added support for sys in/etc/rc. d/init. d/halt.
Set awk '$2 ~ /^/$ | ^/Proc | ^/dev/{next} becomes
Awk '$2 ~ /^/$ | ^/Proc | ^/sys | ^/dev/{next}
6. Start
Modify/etc/lilo. conf and add the following settings.
...
Image =/boot/bzImange2.6.3
Label = Linux2.6.3
Read-only
Root =/dev/hda3 (determined by your PC settings)
Successful.

2. Update GCC (unable to compile glibc-2.3.5 because gcc2.95.3)
Download gcc-3.4.4.tar.bz2
Bzcat gcc-3.4.4.tar.bz2 | tar xvf?
Cd gcc-3.4.4
./Configure? Prefix =/usr/local/gcc344? Enable-shared? Enable-threads? Enable-threads = posix? Enable-languages ages = c, c ++, f77
Make bootstrap (omitted because an error occurred while using the CFLAGS option)
Make install
Ln? S/usr/local/gcc344/bin/gcc/usr/bin/gcc

3. Use glibc-2.3.5
1), through the investigation found that to compile the glibc-2.3.5, binutils requirements in more than 2.13. So you must install binutils-2.14
Download binutils-2.14.tar.gz
Tar zxpvf binutils-2.14.tar.gz
Mkdir binutils-build
Cd binutils-build
Binutils-2.14/configure? Prefix =/usr? Enable-shared
Make tooldir =/usr
Make check
Make tooldir =/usr install
Cp ../binutils-2.14/include/libiberty. h/usr/include
2) install glibc-2.3.5
Download glibc-2.3.5.tar.gz and glibc-2.3.5-fix_test-1.patch
Tar zxpvf glibc-2.3.5.tar.gz
Patch? Np1? I ../glibc-2.3.5-fix_test-1.path
Mkdir glibc-build
Cd glibc-build
Glibc-2.3.5/configure? Prefix =/usr/local/glibc235? Enable-add-ons = linuxthreads? Enable-kernel = 2.6.0 (if installed in the/usr directory, it is dangerous and may damage your system)
Make
Make check (a required step)
Make localedata/install-locales (corresponding to national text)
Mkdir/usr/man/man3 (man installation path)
Make? C ../glibc-2.3.5/linuxthreads/man install
After the above installation is complete, it is best to add/usr/local/glibc235/lib and/usr/local/glibc235/include to the system path, so that during program compilation, you do not need to specify the path of the library and header file.

4. Use NPTL for Thread Programming
# Include
# Include
# Include
# Include
Void thread_fun (void * arg );
Char message [] = "I am created thread ";
Int main (){
Int rnt;
Pthread_t new_thread;
Void * thread_result;
Rnt = pthread_create (& new_thread, NULL, thread_fun, (void *) message );
If (rnt! = 0 ){
Perrer ("thread creation failed ");
Exit (EXIT_FAILURE );
}
Printf ("Waiting for other thread to finish...
");
Rnt = pthread_join (new_thread, & thread_result );
If (rnt! = 0 ){
Perrer ("thread join failed ");
Exit (EXIT_FAILURE );
}
Printf ("Thread join, it returned % s
", (Char *) thread_result );
Printf ("message now % s
", Message );
Exit (EXIT_SUCCESS );
}
Void * thread_fun (void * arg ){
Printf ("the new thread is running. Argument was % s
", (Char *) arg );
Sleep (3 );
Strcpy (message, "Bye ");
Pthread_exit ("Thank you for the test ");
}
Compile
Gcc-D_REENTRANT test_thread.c-o test_thread-lpthread
./Test_thread
Succeeded.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.