Main functions

The kernel is primarily responsible for 4 main functions:

  1. System memory management
  2. Software program management
  3. Hardware management
  4. FIlesystem management
1.System memory management

swap space: virtual memory created on hard drive.

Pages: memory locations are grouped into blocks.

Swapping out: the kernel keeps track of which memory pages are in use and automatically copies memory pages that have not been accessed for a period of time to the swap area , even if there’s other physical memory available.

The current status of the memory on Linux system can be viewed in the file /proc/memoinfo file.

shared memory page : For security reason, no processes can access memory used by Kernel processes.

To facilitate data sharing, you can create shared memory pages, so multiple processes can read and write to and from a common shared memory area.

To view the current shared memory pages on the system, use ipcs command. IPC stands for Inter-process Communication.

This technique allows the processes to communicate with each another. Let’s have a look at one example of the output from ipcs -m which is used to list the shared memory pages:

# ipcs -m

------ Shared Memory Segments --------
key        shmid      owner      perms      bytes      nattch     status
0xc616cc44 1056800768 oracle    660        4096       0
0x0103f577 323158020  root      664        966        1

Key : All the IPC facility has unique key and identifier, which is used to identify an IPC facility and gain access to the shared memory segment.

owner: the person who created the segment.

perms: the permissions setting that sets the availability of the segment for other users

2. Software program management

The kernel creates the first process, called the init process, to start all other processes. Some Linux distros contain a table of processes to start automatically on bootup, and this table is in the special file /etc/inittabs; others (such as ubuntu) utilize the /etc/init.d folder, which contains scripts for starting and stopping individual applications at boot time. The scripts are started via entries under the /etc/rcX.d, where the X is the run level.

For more info, check here: http://frankfu.click/?p=762

3.Hardware management

Two method used for inserting driver code in the Linux Kernel:

  • Drivers compiled in the kernel
  • Driver modules added to the kernel

4. Filesystem management

Check the installed version, distribution

First, I want you to run the command uname -r in a terminal, this will show you the kernel version you are currently using. We never want to remove that kernel version. The command will say something like this 3.5.0-26-generic. Take a note of that number, 26! The following commands will assume that that’s the kernel you’re running.

Find the distribution:

  1. dmesg | head

The output would be similar to

Linux version 2.6.13-15-default (geeko@buildhost) (gcc version 4.0.2 20050901 (prerelease) (SUSE Linux)) #1 Tue Sep 13 14:56:15 UTC 2005

2.  cat /proc/version

The output would be like

Linux version 2.6.13-15-default (geeko@buildhost) (gcc version 4.0.2 20050901 (prerelease) (SUSE Linux)) #1 Tue Sep 13 14:56:15 UTC 2005

3. cat /etc/issue
This method gives the most appropriate answer

The output should be like

Welcome to SUSE LINUX 10.0 (i586) – Kernel \r (\l).

 

Update the kernel

apt-get update

apt-get install linux-headers-

Then hit the Tab key twice to see the available kernels you can update. It’s good practice to install the minor number is even number, which is the stable version (production version). Then complete the above command.

eg. apt-get install linux-headers-4.4

 

boot partition is full

If /boot is mounted on a separate partition, and from the output of df -h, that partition is full.

On Ubuntu you can use this command to clean old kernels:

sudo apt autoremove --purge

This is because there are old kernels installed that are not needed; you can tell that by looking at the output of dpkg -l | grep linux-image that you posted, where you can see more than one “linux-image” with different versions. We need to remove the old versions.

The command to remove an old kernel version is:

 

sudo apt-get purge linux-image-x.x.x-xx-generic

…where the x characters are numbers. So, in your case, because you have a lot of old versions (17, 18, 19, etc…), we would have to run this command for each of the versions, like this:

  • sudo apt-get purge linux-image-3.5.0-17-generic
  • sudo apt-get purge linux-image-3.5.0-18-generic
  • sudo apt-get purge linux-image-3.5.0-19-generic

…and so on. But, there’s a way to do all of this through one command. The command is this:

sudo apt-get purge linux-image-3.5.0-{17,18,19,21,22,23,24}-generic

DO NOT RUN THE COMMAND YET! Read the following.

This command will remove the versions mentioned in the brackets. I didn’t include versions 25, 26 and 28 because of the following reasons:

  • Didn’t include 26 obviously because that is the kernel version you are currently running! That’s the version we got from the command uname -r, remember? We never want to remove that!
  • Didn’t include 28 because that’s the one that your upgrade was trying to upgrade to (you can tell that from the iF status next it, meaning that it’s “half configured”).
  • Didn’t include 25 because it is usually good practice to leave at least one old version. So since you’re running 26, we’ll keep 25, so we won’t include it in the command above.

So if the last number in uname -r is 26 (or 28, or even 25), then it’s safe to run the above command. Enter your password when prompted, and type y when asked. This will show a bunch of lines, and will eventually go back to the command prompt (in your case, matty@matty-G41M-ES2L:~$), hopefully without errors. When it’s done, do df -h and look at the last line, the one that starts with /dev/sda1. You should find that it now has more space, and that the percentage used is less than 100% like it was before. You can now proceed with your update again.

Kernel with Extra keyword

If you run the dpkg -l | grep linux-image, you see some kernel with extra keyword.

It contains extra drivers left out of the base kernel package; install it only if you need these drivers

Sometimes, a specific variant of the linux-image is slimmed down by removing the less common kernel modules (drivers). In this case, the linux-image-extra package simply contains all of the “extra” kernel modules which were left out.

  • Officially, this only happens for the -virtual image; the most common hypervisors (Virtualbox, VMWare, Xen, KVM) emulate a well-defined and restricted set of hardware, so removing unnecessary drivers which increase the size of the kernel/initrd is a good idea. You can always get them back by installing the extras package.
  • The kernel team also appears to have adopted this method for some of the mainline-PPA -generic kernels; the reasoning and solution remain the same — if it looks like the base kernel image is missing a module you need, install extras.
  • As far as I know, the above approach has not been taken for the Quantal kernels — only -virtual is affected as usual.