Difference between revisions of "RHEL5 Kernel HOWTO"

From Funtoo Linux
Jump to: navigation, search
(pointed to the renamed category)
(Step 5: boot-update)
 
(18 intermediate revisions by 7 users not shown)
Line 1: Line 1:
1. Downgrade udev to a version compatible with kernels previous than 2.6.27:
+
== Introduction ==
 +
 
 +
This HOWTO will show you how to get a RHEL5-based OpenVZ kernel running on a Funtoo Linux system.
 +
 
 +
== Step 1: Downgrade udev, lvm2 ==
 +
 
 +
Downgrade udev to a version compatible with kernels previous than 2.6.27:
 +
 
 +
<pre>
 
echo ">=sys-fs/udev-147" >> /etc/portage/package.mask
 
echo ">=sys-fs/udev-147" >> /etc/portage/package.mask
 
emerge -u udev
 
emerge -u udev
 +
</pre>
  
2. Mask any openvz-sources version equal or newer than 2.6.27:
+
This will also require a downgrade of lvm2, if you are using it. Version 2.02.68 is a good one to use:
echo ">=sys-kernel/openvz-sources-2.6.27" >> /etc/portage/package.mask
+
  
3. openvz-sources-2.6.18* needs gcc-4.1*, so you must install it prior build your future downgraded kernel. If you have newer versions than gcc-4.1* then you must install this one. Also check your CFLAGS if you are using gcc-4.3* or later *AND* your make.conf CFLAGS has -march=native, due previous GCC versions doesn't allow it. Check [1] and put a correct -march directive in your CFLAGS. You also need to change CXXFLAGS in the same way, ie:
+
<pre>
CFLAGS="-march=amd64" CXXFLAGS="-march=amd64" emerge =sys-devel/gcc-4.1.2
+
echo ">=sys-fs/lvm2-2.02.69" >> /etc/portage/package.mask
 +
emerge -u lvm2
 +
</pre>
  
That may take a while, take a cup of your favourite beverage and wait until finish.
+
Downgrade make to a version compatible with older kernel version
 +
 
 +
<pre>
 +
echo ">=sys-devel/make-3.82" > /etc/portage/package.mask
 +
emerge -u make
 +
</pre>
 +
 
 +
== Step 2: Install binary kernel ==
 +
 
 +
The process for installing an RHEL5-based kernel with OpenVZ support has been drastically simplified. Simply perform the following steps:
 +
 
 +
<pre>
 +
# echo "sys-kernel/openvz-rhel5-stable binary" >> /etc/portage/package.use
 +
</pre>
 +
 
 +
This will result in the kernel sources and a binary kernel and initrd being merged. Without <tt>binary</tt> in USE, only the sources will be merged. Then:
 +
 
 +
<pre>
 +
# emerge openvz-rhel5-stable
 +
</pre>
 +
 
 +
This will build and install a binary kernel image and initial RAM disk, and take care of installing all necessary dependencies like gcc-4.1.2. Once the binary kernel image and initrd is installed, configure <tt>/etc/boot.conf</tt> to find and boot the new kernel.
 +
 
 +
Note: you may need to temporarily modify your <tt>CFLAGS</tt> settings to ensure they are compatible with gcc-4.1 systems. In particular, <tt>-march=native</tt> is not recognized by the older gcc.
  
 
[1] http://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/i386-and-x86_002d64-Options.html#i386-and-x86_002d64-Options
 
[1] http://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/i386-and-x86_002d64-Options.html#i386-and-x86_002d64-Options
  
4. Switch to gcc-4.1* on your system:
+
== Step 3: Enable vz initscript ==
localhost ~ # gcc-config -l
+
[1] x86_64-pc-linux-gnu-4.1.2
+
[2] x86_64-pc-linux-gnu-4.4.3 *
+
localhost ~ # gcc-config 1
+
* Switching native-compiler to x86_64-pc-linux-gnu-4.1.2...
+
>>> Regenerating /etc/ld.so.cache...                                                                                                                                                                                                    [ok]
+
  
* If you intend to use the gcc from the new profile in an already
+
When your system boots with OpenVZ support enabled, it will require /etc/init.d/vz to run:
* running shell, please remember to do:
+
  
# source /etc/profile
+
<pre>
 +
# rc-update add vz default
 +
</pre>
  
localhost ~ # source /etc/profile
+
== Step 4: Edit boot.conf ==
localhost ~ # gcc --version
+
gcc (GCC) 4.1.2 (Gentoo 4.1.2 p1.3)
+
gcc (GCC) 4.1.2 (Gentoo 4.1.2 p1.3)
+
Copyright (C) 2006 Free Software Foundation, Inc.
+
This is free software; see the source for copying conditions.  There is NO
+
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
  
localhost ~ #
+
Update /etc/boot.conf to point to your new kernel, ie:
  
5. Rebuild your sources:
+
<pre>
cd /usr/src/linux
+
boot {
make menuconfig
+
        generate grub
[do your work]
+
        default kernel-openvz-rhel5-stable-x86_64-2.6.18-028stab089.1
make
+
        timeout 3
cp arch/x86/boot/bzImage /boot/linux-2.6.18-openvz-028.068.9
+
}
  
6. Update /etc/boot.conf to point to your new kernel, ie:
+
"Funtoo Linux with OpenVZ" {
vi /etc/boot.conf
+
         kernel kernel-openvz[-v]
[inside /etc/boot.conf now]
+
        initrd initramfs-openvz[-v]
"Funtoo Linux" {
+
         params += real_root=auto
         kernel linux-2.6.18-openvz-028.068.9
+
         params root=/dev/sda3
+
 
}
 
}
 +
</pre>
 +
 +
Note that you must use the <tt>params += real_root=auto</tt> option. This will automatically
 +
configure your boot loader to specify your root fileysstem as the <tt>real_root</tt> to the
 +
initrd.
 +
 +
== Step 5: boot-update ==
 +
 +
Now, simply run <tt>boot-update</tt> as root:
 +
 +
<pre>
 +
boot-update
 +
</pre>
 +
 +
<tt>boot-update</tt> should show the new kernel as being found and display it as the default
 +
selection for the next boot. You can now reboot your system and start using OpenVZ.
  
7. Reboot your computer and enjoy
 
reboot
 
 
[[Category:HOWTO]]
 
[[Category:HOWTO]]
 +
[[Category:Kernel]]

Latest revision as of 13:39, 18 November 2012

Contents

[edit] Introduction

This HOWTO will show you how to get a RHEL5-based OpenVZ kernel running on a Funtoo Linux system.

[edit] Step 1: Downgrade udev, lvm2

Downgrade udev to a version compatible with kernels previous than 2.6.27:

echo ">=sys-fs/udev-147" >> /etc/portage/package.mask
emerge -u udev

This will also require a downgrade of lvm2, if you are using it. Version 2.02.68 is a good one to use:

echo ">=sys-fs/lvm2-2.02.69" >> /etc/portage/package.mask
emerge -u lvm2

Downgrade make to a version compatible with older kernel version

echo ">=sys-devel/make-3.82" > /etc/portage/package.mask
emerge -u make

[edit] Step 2: Install binary kernel

The process for installing an RHEL5-based kernel with OpenVZ support has been drastically simplified. Simply perform the following steps:

# echo "sys-kernel/openvz-rhel5-stable binary" >> /etc/portage/package.use

This will result in the kernel sources and a binary kernel and initrd being merged. Without binary in USE, only the sources will be merged. Then:

# emerge openvz-rhel5-stable

This will build and install a binary kernel image and initial RAM disk, and take care of installing all necessary dependencies like gcc-4.1.2. Once the binary kernel image and initrd is installed, configure /etc/boot.conf to find and boot the new kernel.

Note: you may need to temporarily modify your CFLAGS settings to ensure they are compatible with gcc-4.1 systems. In particular, -march=native is not recognized by the older gcc.

[1] http://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/i386-and-x86_002d64-Options.html#i386-and-x86_002d64-Options

[edit] Step 3: Enable vz initscript

When your system boots with OpenVZ support enabled, it will require /etc/init.d/vz to run:

# rc-update add vz default

[edit] Step 4: Edit boot.conf

Update /etc/boot.conf to point to your new kernel, ie:

boot {
        generate grub
        default kernel-openvz-rhel5-stable-x86_64-2.6.18-028stab089.1
        timeout 3
}

"Funtoo Linux with OpenVZ" {
        kernel kernel-openvz[-v]
        initrd initramfs-openvz[-v]
        params += real_root=auto
}

Note that you must use the params += real_root=auto option. This will automatically configure your boot loader to specify your root fileysstem as the real_root to the initrd.

[edit] Step 5: boot-update

Now, simply run boot-update as root:

boot-update

boot-update should show the new kernel as being found and display it as the default selection for the next boot. You can now reboot your system and start using OpenVZ.

Personal tools
Namespaces

Variants
Actions
Categories
Toolbox
Stuff