PDA

View Full Version : Standard Kernels with Ubuntu / Debian


Myatu
10-07-2011, 22:04
I've seen a couple threads that ask if its possible to use the standard kernel - one that can load kernel modules - instead of OVH's kernels. With Ubuntu and Debian this is an easy task, that does not require compiling:

Step 1: ensure your server has the GRUB-2 boot loader.

Most newer servers from OVH do, as do all VPS/Cloud installations. You can have a quick look to see if the file /etc/default/grub exists, or whether this command give a valid output:
# update-grub -v
grub-mkconfig (GRUB) 1.99~rc1-13ubuntu3

Step 2: install a kernel

First make sure you have the most recent data from the repositories:
apt-get update

And check what kernels are available to you with:
apt-cache search linux-image

An example output:
# apt-cache search linux-image
linux-image-2.6.38-8-generic - Linux kernel image for version 2.6.38 on x86/x86_64
linux-image-2.6.38-8-generic-pae - Linux kernel image for version 2.6.38 on x86
linux-image-2.6.38-8-virtual - Linux kernel image for version 2.6.38 on x86/x86_64
linux-image-generic - Generic Linux kernel image
linux-image-generic-pae - Generic Linux kernel image
linux-image-server - Linux kernel image on Server Equipment.
linux-image-virtual - Linux kernel image for virtual machines
linux-image-2.6.32-25-generic-pae - Linux kernel image for version 2.6.32 on x86
linux-image-2.6.32-31-generic-pae - Linux kernel image for version 2.6.32 on x86
linux-image-2.6.32-29-generic-pae - Linux kernel image for version 2.6.32 on x86


The kernels that do not have a specific version, such as linux-image-generic, are meta packages that automatically select the most recent kernel.

The "generic" kernels are best suitable for desktop systems, "servers" for, well, servers, and so on.

Once you have decided on a kernel, install it with:
apt-get install linux-image-[your selection]

Step 3: Load a kernel

Debian and Ubuntu should already have issued a update-grub command when it installed the kernel you've selected in step 2. But it will not yet be loaded, reason being is that you don't see the "boot screen" of the server (except in vKVM mode or the ipKVM option) and so can't make a selection during boot time.

First determine the order the kernels are listed by GRUB, which can easily be done with fgrep or cat | grep:

# fgrep menuentry /boot/grub/grub.cfg
menuentry "Ubuntu 10.10, OVH kernel 2.6.38.2-xxxx-grs-ipv6-64" {
menuentry 'Ubuntu, with Linux 2.6.38-8-server' --class ubuntu --class gnu-linux --class gnu --class os {
menuentry 'Ubuntu, with Linux 2.6.38-8-server (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os {


The text between the quotes will give you an idea what's-what. Do keep in mind you need to start counting from zero, so the first entry is 0, the second is 1, etc.

Now you need to edit the file /etc/default/grub and change the the GRUB_DEFAULT=0 entry according to which boot option/kernel you wish to use.

So using the previous sample output, we want to load "Ubuntu, with Linux 2.6.38-8-server", and therefore need to change the zero (0) to a one (1) in /etc/default/grub:
GRUB_DEFAULT=1

Now re-update the GRUB configuration (and this is important) with:
update-grub

Now reboot your server and cross your fingers. Once the server is back up, you can verify the correct kernel has loaded with uname, ie:

# uname -a
Linux my-super-duper-server 2.6.38-8-server #42-Ubuntu SMP Mon Apr 11 03:49:04 UTC 2011 x86_64 x86_64 x86_64 GNU/Linux

jonlewi5
10-07-2011, 23:19
Seems to have worked perfectly!
Cheers myatu :D

Myatu
10-07-2011, 23:28
Good stuff :) I was updating an OVH server with a standard kernel when I saw your post, so good timing!

jonlewi5
10-07-2011, 23:42
haha it really was, managed to vmware server to half install, still failing but i know its something im doing an its too late to be messing with it :D

Iray
11-07-2011, 10:38
Myatu .. Thanks dude! You need some man love... *Hug*

I'll try this out once I get my new shiny server. Hopefully this is a step by step process for us fellow noobs.

jonlewi5
11-07-2011, 13:03
I can confirm this works perfectly, got vmware setup and working alongside GNS3,

thanks very very much myatu!

Winit
12-07-2011, 01:35
Thank you Myatu. :)

nodokodo
12-08-2011, 23:58
Just an FYI, but you do NOT have to (and really shouldn't) edit /etc/default/grub.

Instead cd in to /etc/grub.d and if you ls you will see a bunch of scripts prefixed by numbers; the numbers are the boot ordering—change these numbers and you alter the order.

For example, on my Ubuntu 11.04, the OVH kernel is prefixed 06 (to slip in ahead of 10):

-rwxr-xr-x 1 root root 6658 2011-04-21 14:31 00_header
-rwxr-xr-x 1 root root 5522 2011-04-21 14:19 05_debian_theme
-rwxr-xr-x 1 root root 959 2010-10-11 12:31 06_OVHkernel
-rwxr-xr-x 1 root root 6304 2011-04-21 14:31 10_linux
-rwxr-xr-x 1 root root 5233 2011-04-21 14:31 20_linux_xen
-rwxr-xr-x 1 root root 7119 2011-04-21 14:31 30_os-prober
-rwxr-xr-x 1 root root 214 2011-04-21 14:31 40_custom
-rwxr-xr-x 1 root root 95 2011-04-21 14:31 41_custom
-rw-r--r-- 1 root root 483 2011-04-21 14:31 README

I altered that to 25 (to slip it in after the other kernels):

-rwxr-xr-x 1 root root 6658 2011-04-21 14:31 00_header
-rwxr-xr-x 1 root root 5522 2011-04-21 14:19 05_debian_theme
-rwxr-xr-x 1 root root 6304 2011-04-21 14:31 10_linux
-rwxr-xr-x 1 root root 5233 2011-04-21 14:31 20_linux_xen
-rwxr-xr-x 1 root root 959 2010-10-11 12:31 25_OVHkernel
-rwxr-xr-x 1 root root 7119 2011-04-21 14:31 30_os-prober
-rwxr-xr-x 1 root root 214 2011-04-21 14:31 40_custom
-rwxr-xr-x 1 root root 95 2011-04-21 14:31 41_custom
-rw-r--r-- 1 root root 483 2011-04-21 14:31 README

Run: update-grub and the default becomes 10_linux (whatever kernel you've just installed after following Myatu).

I'm pretty positive you can just remove it (06_OVHkernel) altogether, but if it aint broke… redundancy never killed anyone (well maybe a few coal miners but that's another story). HTH

mrchrister
12-03-2012, 13:20
thanks so much for the explination, this is sooo much easier then self compiling :)

I used your instructions on 2 ovh servers now, works flawlessly!

Phixion
08-07-2012, 17:58
Can anyone tell me the benefits of doing this?

K.Kode
08-07-2012, 18:42
LKM's

Kacotet
08-07-2012, 19:13
Can anyone tell me the benefits of doing this?

Some applications & services require a modular kernel.

Phixion
09-07-2012, 13:35
Oh I see... cheers! :)

JustJason
18-07-2012, 17:28
Thanks very much for this. It saved me a lot of trouble.
I needed LKMs and didn't have time to fsck around.
FWIW I tried it on a vanilla md raid 1 OVH 10.04 box and it's still ticking along and the standard Ubuntu Server kernel worked fine with the existing md config.

gregoryfenton
12-09-2012, 16:04
Thanks Myatu.

As they say in Mortal Kombat:
Flawless victory.

martzuk
24-10-2012, 08:25
I've done the steps above and tried both making default=1 and changing the number of the ovhkernel to 21 in /etc/grub.d but no matter what it still loads up as

Linux ks3097745.kimsufi.com 3.2.13-xxxx-std-ipv6-64 #1 SMP Wed Mar 28 11:20:17 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux

Whenever I run update-grub or update-grub2 I get:

Generating grub.cfg ...
Found linux image: /boot/vmlinuz-3.5.0-17-generic
Found initrd image: /boot/initrd.img-3.5.0-17-generic
/usr/sbin/grub-probe: warning: disk does not exist, so falling back to partition device /dev/sda1.
/usr/sbin/grub-probe: error: cannot find a GRUB drive for /dev/sda1. Check your device.map.
/usr/sbin/grub-probe: warning: disk does not exist, so falling back to partition device /dev/sda1.
/usr/sbin/grub-probe: error: cannot find a GRUB drive for /dev/sda1. Check your device.map.
/usr/sbin/grub-probe: warning: disk does not exist, so falling back to partition device /dev/sda1.
/usr/sbin/grub-probe: error: cannot find a GRUB drive for /dev/sda1. Check your device.map.
/etc/grub.d/21_OVHkernel: line 6: /usr/lib/grub/update-grub_lib: No such file or directory

And fdisk -l doesn't return anything.

This all stemmed from updating to 12.10 without realising OVH screws with the kernel, I've installed the kernel ok but just can't make it boot into it, I need to switch to the generic kernel as the ovh one for 12.04 seems to have broken my pptpd service.

Myatu
24-10-2012, 19:03
/etc/grub.d/21_OVHkernel: line 6: /usr/lib/grub/update-grub_lib: No such file or directory

Move /etc/grub.d/21_OVHkernel completely out of that directory, ie., place it in /opt/ for the time being (as a backup), and run it again.

martzuk
24-10-2012, 20:15
I got the ovh guys to fix the issue with the fdisk being unable to find any drives, they did this:

for fdisk: simply don't use fdisk, but pinstead use parted
parted /dev/sd print
parted /dev/sda print
(/usr/lib/grub/update-grub_lib: No such file or directory
sed -i "s/update-grub_lib/grub-mkconfig_lib/g" /etc/grub.d/21_OVHkernel
the file is called differently now :-/
root@ksXXXXXXX:~# ls -lah /dev/sda
ls: cannot access /dev/sda: No such file or directory
root@ksXXXXXXX:~# ls -lah /dev/sda*
brw-rw---- 1 root disk 8, 1 Oct 24 09:12 /dev/sda1
brw-rw---- 1 root disk 8, 2 Oct 24 09:12 /dev/sda2
brw-rw---- 1 root disk 8, 3 May 19 13:15 /dev/sda3
Without that file fdisk can't read the partition table3
root@ksXXXXXXX:~# cd /dev
root@ksXXXXXXX:/dev# mknod sda b 8 0
root@ksXXXXXXX:/dev# fdisk -l
Disk /dev/sda: 1000.2 GB, 1000204886016 bytes
255 heads, 63 sectors/track, 121601 cylinders, total 1953525168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000a3f77
Device Boot Start End Blocks Id System
(much better now :-)
/dev/sda1 * 4096 20975616 10485760+ 83 Linux
/dev/sda2 20975617 1952468992 965746688 83 Linux
/dev/sda3 1952468993 1953520064 525536 82 Linux swap / Solaris
root@ksXXXXXXX:/dev#
hmm, a couple lines seem to be missing:
/dev/sda1 * 4096 20975616 10485760+ 83 Linux
/dev/sda2 20975617 1952468992 965746688 83 Linux
/dev/sda3 1952468993 1953520064 525536 82 Linux swap / Solaris
root@ksXXXXXXX:~# cd /dev
root@ksXXXXXXX:/dev# mknod sda b 8 0
re-created the /dev/sd file

I then moved the file you suggested and re-ran grub update but it still boots into the ovh kernel Linux ks3097745.kimsufi.com 3.2.13-xxxx-std-ipv6-64 #1 SMP Wed Mar 28 11:20:17 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux

Myatu
24-10-2012, 20:42
Did the update complete without any fatal errors? What does fgrep default= /boot/grub/grub.cfg and fgrep menuentry /boot/grub/grub.cfg give?

martzuk
25-10-2012, 08:44
It seems to have completed ok, I tried changing the default but may have selected the wrong one, am I right in thinking I need to set it to 2?

root@XXXXXXX:/boot/grub# fgrep default= /boot/grub/grub.cfg
set default="0"
root@ksXXXXXXX:/boot/grub# fgrep menuentry /boot/grub/grub.cfg
if [ x"${feature_menuentry_id}" = xy ]; then
menuentry_id_option="--id"
menuentry_id_option=""
export menuentry_id_option
menuentry 'Ubuntu' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-simple-7b3baca0-a11a-48db-be56-c1e1f4f773cd' {
submenu 'Advanced options for Ubuntu' $menuentry_id_option 'gnulinux-advanced-7b3baca0-a11a-48db-be56-c1e1f4f773cd' {
menuentry 'Ubuntu, with Linux 3.5.0-17-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-3.5.0-17-generic-advanced-7b3baca0-a11a-48db-be56-c1e1f4f773cd' {
menuentry 'Ubuntu, with Linux 3.5.0-17-generic (recovery mode)' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-3.5.0-17-generic-recovery-7b3baca0-a11a-48db-be56-c1e1f4f773cd' {
root@ks3097745:/boot/grub#

martzuk
25-10-2012, 10:29
Well, I've been emailing Neil who has been quite helpful sorting these errors out, however I still can't get the generic kernel to boot. On a better note, and the reason I was trying to switch kernel was I've managed to get pptpd to work again.

Looking through the syslog I found that the ppp kernel module seemed to be missing, so I did some googling. When I re-read the syslog I found that it actually gave me the solution!

mknod /dev/ppp c 108 0

To my surprise and elation this seemed to fix the problem! Probably the most helpful error log ever. I'm guessing the upgrade to 12.10 may have removed the kernel module? Is there any reason to carry on trying to switch to the generic kernel?

martzuk
25-10-2012, 10:29
Although saying that I noticed that it has finally changed! Am I right in thinking this is the generic kernel?

Linux ksXXXXXXX.kimsufi.com 3.5.0-17-generic #28-Ubuntu SMP Tue Oct 9 19:31:23 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux

Myatu
25-10-2012, 14:54
Although saying that I noticed that it has finally changed! Am I right in thinking this is the generic kernel?

Linux ksXXXXXXX.kimsufi.com 3.5.0-17-generic #28-Ubuntu SMP Tue Oct 9 19:31:23 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux

Yes, that's a generic kernel - not the one supplied by OVH (which has the xxxx in it). So looks like you're back in business! :)

bupkis
13-02-2013, 19:39
I've installed a generic server kernel on my kimsufi running Ubuntu 12.04 LTS using a somewhat different method. After a "sudo su -", I did the following:

apt-get install linux-image-server


to get the generic kernel.

Then I moved the OVH kernel from /etc/grub.d to a new directory:

mkdir ~/ovh.d
mv /etc/grub.d/06_OVHkernel ~/ovh.d

Then I ran

update-grub

and rebooted.

Everything worked fine and the new kernel is loaded.

One thing I've noticed is that "ps ax" and "htop" are now populated with a great many processes that I never saw under the OVH kernel: a dozen or so apache processes, a number of processes in brackets and several /sbin/getty processes. It seems to be showing me a lot of processes that were somehow masked when using the OVH kernel, which was more useful, frankly.

What do I have to do in order to show only the "salient" (for want of a better term) processes that were shown under the OVH kernel?

Myatu
13-02-2013, 21:33
Some of those, like hiding kernel processes, were part of the grsecurity patch that OVH uses on its kernels. See http://en.wikibooks.org/wiki/Grsecurity/Appendix/Grsecurity_and_PaX_Configuration_Options for a full list of features.

streaky
14-02-2013, 17:07
One thing I've noticed is that "ps ax" and "htop" are now populated with a great many processes that I never saw under the OVH kernel: a dozen or so apache processes, a number of processes in brackets and several /sbin/getty processes. It seems to be showing me a lot of processes that were somehow masked when using the OVH kernel, which was more useful, frankly.

What do I have to do in order to show only the "salient" (for want of a better term) processes that were shown under the OVH kernel?

In newer kernels (3.2+ IIRC) you can restrict access to proc for non-root users to their own processes which has this effect without a vanilla kernel. http://www.linux-dev.org/2012/09/hide-process-information-for-other-users/

bupkis
14-02-2013, 19:55
Some of those, like hiding kernel processes, were part of the grsecurity patch that OVH uses on its kernels. See http://en.wikibooks.org/wiki/Grsecurity/Appendix/Grsecurity_and_PaX_Configuration_Options for a full list of features.

Looking at that grsecurity patch and what it does makes me feel, uh, insecure. Is running a generic kernel that insecure? Should I be worrying about this?

Myatu
15-02-2013, 01:59
It all depends on your level of paranoia ;)

If you're using it for general purposes, then personally, I don't see an issue - kernel hardening is only as effective as securing the rest of the server.

But if you're talking about sensitive data, say for example bank details or patient data, then you might want to consider patching it as well as implementing other security measures.

OVH has provided the full kernel config files here: ftp://ftp.ovh.net/made-in-ovh - so it makes it easy to re-compile the kernel with your own customizations, such as support for dynamic modules.

But that's a personal opinion of course.