Difference between revisions of "Linux kernel"

From Christoph's Personal Wiki
Jump to: navigation, search
(Check if your kernel is 32- or 64-bit)
 
(11 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
The '''kernel''' is the core piece of the [[Linux]] operating system.
 
The '''kernel''' is the core piece of the [[Linux]] operating system.
*Current (stable version): '''3.2.1''' (2012-01-12)[http://www.kernel.org]
+
*Current (stable version): '''[http://www.kernel.org 3.4.7]''' (2012-07-29)
  
 
==Resources==
 
==Resources==
Line 91: Line 91:
 
#Check to make sure your <code>/etc/lilo.conf</code> is pointing to the correct kernels and images.
 
#Check to make sure your <code>/etc/lilo.conf</code> is pointing to the correct kernels and images.
 
#Then, try rebooting.
 
#Then, try rebooting.
 +
 +
==Check if your kernel is 32- or 64-bit==
 +
 +
$ uname -a
 +
 +
If 32-bit, it will look something like:
 +
 +
Linux hostname 3.8.0-33-generic #48-Ubuntu SMP Wed Oct 23 17:26:34 UTC 2013 i686 i686 i686 GNU/Linux
 +
 +
If 64-bit:
 +
Linux hostname 3.8.0-33-generic #48-Ubuntu SMP Wed Oct 23 17:26:34 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
 +
 +
$ file /sbin/init
 +
/sbin/init: ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV)...
 +
# ~OR~
 +
/sbin/init: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV)...
 +
 +
$ uname -m
 +
i686    # <- 32-bit
 +
# ~OR~
 +
x86_64  # <- 64-bit
 +
 +
$ arch
 +
$ getconf LONG_BIT
 +
32
 +
# ~OR~
 +
64
 +
 +
if <nowiki>[[</nowiki> $(getconf LONG_BIT) = "64" <nowiki>]]</nowiki>; then echo "64-bit kernel"; else echo "32-bit kernel"; fi
  
 
==Kernel files==
 
==Kernel files==

Latest revision as of 10:20, 17 November 2014

The kernel is the core piece of the Linux operating system.

  • Current (stable version): 3.4.7 (2012-07-29)

Resources

The kernel manages the resources of the Linux OS; such as the following:

  • File management
  • Multitasking
  • Memory management
  • I/O management
  • Process management: /proc/
  • Device management: /dev/
  • Networking support (including IPv4 and IPv6)
  • Virtual memory, shared libraries, demand loading, etc.

The kernel decides who will use these resources, for how long, and when.

Rebuilding kernel from SRPM

Note: some of the paths below include $TOPDIR, which is distribution-dependent and can be further redefined by user. To find out the proper location on your system, issue this command:

rpm --eval "%{_topdir}"

openSUSE 10.2 returns:

/usr/src/packages

Mandriva Linux 2007.1 returns:

/usr/src/rpm

Example kernel update protocol

For this example, I will be using Mandriva Linux and updating/upgrading from kernel kernel-smp-2.6.8.1.12mdk-1-1mdk to kernel-smp-2.6.12.31mdk-1-1mdk.

The first thing you should do before updating your kernel is to backup your /sbin/*25 files (some distributions omit the "-25" at the end of each name) to a floppy disc (handy for quickly restoring them). These would include:

/sbin/depmod-25
/sbin/insmod-25
/sbin/lsmod-25
/sbin/modinfo-25
/sbin/modprobe-25
/sbin/rmmod-25

It wouldn't hurt to also backup your entire /etc directory.

Then, update your old kernel's related rpms:

rpm -Uvh fbgrab-1.0-1mdv2007.0.i586.rpm
rpm -Uvh libgtk-linux-fb-2.0_0-2.4.14-6mdk.i586.rpm
rpm -Uvh bootsplash-3.1.12-0.2.20060mdk.i586.rpm
rpm -Uvh mkinitrd-4.2.17-17.2.20060mdk.i586.rpm
rpm -Uvh module-init-tools-3.2-0.pre8.2.1.20060mdk.i586.rpm
rpm -Uvh aumix-text-2.8-12mdk.i586.rpm
rpm -Uvh sound-scripts-0.35-1mdk.noarch.rpm
rpm -Uvh hotplug-2004_09_23-7mdk.i586.rpm
# Returns clashing dependencies (possible problem source):
#rpm -Uvh udev-068-34mdk.i586.rpm

Now, install (not "upgrade") your new kernel rpm:

# Note: I am NOT using "rpm -Uvh", as I wish to _keep_ the old kernel
# The "smp" RPM is for multi-processor systems
rpm -ivh kernel-smp-2.6.12.31mdk-1-1mdk.i586.rpm

Notes:

# Linux kernel RPM:
# - kernel (/boot/vmlinux-2.X.XX-X);
# - modules (/lib/modules/2.X.XX-X/...);
# - /boot/System.map-2.X.XX-X; and
# - /boot/module-info-2.X.XX-X

Now, create the initrd image:

/sbin/mkinitrd /boot/initrd-2.6.12.31mdksmp.img 2.6.12.31mdk-1-1mdk

Edit /etc/lilo.conf and add new/old kernel boots (you want to keep your old kernel, just in case anything goes wrong you can boot your old, working kernel). For an example,

image=/boot/vmlinuz-2.6.12-31mdksmp
        label="linux-2.6.12-31mdksmp"
        root=/dev/sda1
        initrd=/boot/initrd-2.6.12-31mdksmp.img
        append="acpi=ht resume=/dev/sda5 splash=silent"
        vga=788
        read-only
image=/boot/vmlinuz-2.6.8.1-12mdksmp
        label="linux-2.6.8.1-12mdksmp"
        root=/dev/sda1
        initrd=/boot/initrd-2.6.8.1-12mdksmp.img
        append="acpi=ht resume=/dev/sda5 splash=silent"
        vga=788
        read-only

Now commit the changes to lilo:

lilo -v

Reboot:

shutdown -r now

And that should do it.

Possible problems/fixes

If you have problems with any kernel (old, new, or both), here are some possible troubleshooting steps you can take:

  1. Boot in a rescue disk (e.g. Mandrake 10.1 installation CD)
  2. Restore your old /sbin/*25 files from the floppy disc (see above)
  3. Check to make sure your /etc/lilo.conf is pointing to the correct kernels and images.
  4. Then, try rebooting.

Check if your kernel is 32- or 64-bit

$ uname -a

If 32-bit, it will look something like:

Linux hostname 3.8.0-33-generic #48-Ubuntu SMP Wed Oct 23 17:26:34 UTC 2013 i686 i686 i686 GNU/Linux

If 64-bit:

Linux hostname 3.8.0-33-generic #48-Ubuntu SMP Wed Oct 23 17:26:34 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
$ file /sbin/init
/sbin/init: ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV)...
# ~OR~
/sbin/init: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV)...
$ uname -m
i686    # <- 32-bit
# ~OR~
x86_64  # <- 64-bit
$ arch 
$ getconf LONG_BIT
32
# ~OR~
64
if [[ $(getconf LONG_BIT) = "64" ]]; then echo "64-bit kernel"; else echo "32-bit kernel"; fi

Kernel files

Note: These files are found in the /boot directory.

Kernel files
Distribution Kernel file Ram disk
SuSE linux initrd
Mandriva vmlinuz all.rdz
Fedora vmlinuz initrd.img
Knoppix vmlinuz initrd.img
Slackware bzImage initrd.img
Ubuntu vmlinuz initrd.gz
Gentoo gentoo gentoo.igz
Debian vmlinuz initrd.gz


See also

External links