Difference between revisions of "028 to 042 kernel upgrade"

From OpenVZ Virtuozzo Containers Wiki
Jump to: navigation, search
(now should look better)
(improvements all over the place (apparently live cd is optional))
Line 1: Line 1:
 
This article describes a way to upgrade your old OpenVZ system with RHEL5-based
 
This article describes a way to upgrade your old OpenVZ system with RHEL5-based
 
(028stabNNN kernel) to RHEL6-based (042stabNNN) kernel, and convert /vz
 
(028stabNNN kernel) to RHEL6-based (042stabNNN) kernel, and convert /vz
from ext3 to ext4.
+
from ext3 to ext4, while keeping RHEL/CentOS 5 as a host OS.
  
 
Assumptions:
 
Assumptions:
Line 16: Line 16:
  
 
  yum update
 
  yum update
 +
 +
Install required software:
 +
 +
yum install e4fsprogs.x86_64
  
 
== Add rhel6 kernel repos ==
 
== Add rhel6 kernel repos ==
Line 72: Line 76:
 
== Convert /vz to ext4 ==
 
== Convert /vz to ext4 ==
  
Boot node from a live-CD (such as, CentOS 6 live CD) and perform the following steps.
+
If your /vz is a separate file system, you need to stop all containers
 +
and umount it first:
 +
 
 +
for ve in $(vzlist -1); do vzctl stop $ve; done
 +
umount /vz
 +
 
 +
Alternatively, boot the node from a live-CD (such as CentOS 6 live CD).
  
 
Check file system:
 
Check file system:
Line 78: Line 88:
  
 
Turn on ext4 features:
 
Turn on ext4 features:
  # tune2fs -O extents,uninit_bg,dir_index /dev/sd''xY''
+
  # tune4fs -O extents,uninit_bg,dir_index /dev/sd''xY''
  
 
Check the new file system again, as ext4 this time:
 
Check the new file system again, as ext4 this time:
 
  # fsck.ext4 -fD /dev/sd''xY''
 
  # fsck.ext4 -fD /dev/sd''xY''
  
You can do the same for root filesystem, too.
+
If you have booted from the live CD, you can do the same for root filesystem.
  
Now, mount your ROOT (<code>/</code>, not <code>/vz</code>) and BOOT partitions:
+
If you have booted from the live CD, do this:
 +
* mount your ROOT and BOOT partitions:
 
  # mkdir /tmp/root
 
  # mkdir /tmp/root
 
  # mount /dev/sd''aB'' /tmp/root
 
  # mount /dev/sd''aB'' /tmp/root
 
  # mount /dev/sd''aC'' /tmp/root/boot
 
  # mount /dev/sd''aC'' /tmp/root/boot
 
+
* chroot into it:
Finally, chroot into it:
 
 
  # chroot /tmp/root
 
  # chroot /tmp/root
  
Edit its <code>/etc/fstab</code>, replacing <code>ext3</code> with <code>ext4</code> for <code>/vz</code> (and <code>/</code> if you converted it as well).
+
Finally, edit <code>/etc/fstab</code>, replacing <code>ext3</code> with <code>ext4</code> for <code>/vz</code> (and <code>/</code> if you converted it as well).
 
  # vi /etc/fstab
 
  # vi /etc/fstab
  
 
== Create new initrd with proper modules ==
 
== Create new initrd with proper modules ==
  
This assumes you are still entered chroot:
+
# KV=042stab083.2
 
 
 
  # mkinitrd -v -f --with=ext4 --builtin=ehci-hcd --builtin=ohci-hcd --builtin=uhci-hcd \
 
  # mkinitrd -v -f --with=ext4 --builtin=ehci-hcd --builtin=ohci-hcd --builtin=uhci-hcd \
   /boot/initrd-2.6.32-042stab81.8.img 2.6.32-042stab081.8
+
   /boot/initrd-2.6.32-${KV}.img 2.6.32-${KV}
  
 
Notes:
 
Notes:
Line 124: Line 133:
 
       /dev/sda2    ext3    496M  46M  425M  10% /boot
 
       /dev/sda2    ext3    496M  46M  425M  10% /boot
 
       /dev/sdb1    ext4    1.8T  196M  1.7T  1% /vz
 
       /dev/sdb1    ext4    1.8T  196M  1.7T  1% /vz
 +
 +
== Next steps ==
 +
 +
You can now install [[ploop]] and enjoy all its benefits.
 +
 +
Also, it makes sense to convert your containers to [[VSwap]].
  
 
== See also ==
 
== See also ==

Revision as of 03:54, 21 November 2013

This article describes a way to upgrade your old OpenVZ system with RHEL5-based (028stabNNN kernel) to RHEL6-based (042stabNNN) kernel, and convert /vz from ext3 to ext4, while keeping RHEL/CentOS 5 as a host OS.

Assumptions:

  • systems is CentOS (RHEL) 5.x
  • vzkernel is 028stabXXX, i.e. RHEL5-based
  • /vz uses ext3

End result should be:

  • Same CentOS 5 system
  • vzkernel is 042stabXXX
  • /vz uses ext4

Update your system

yum update

Install required software:

yum install e4fsprogs.x86_64

Add rhel6 kernel repos

Disable rhel5 and enable rhel6 OpenVZ kernel repository. In other words, change /etc/yum.repos.d/openvz.repo to look like this (changes required are in bold):

  [openvz-kernel-rhel6]
  name=OpenVZ RHEL6-based stable kernels
  #baseurl=http://download.openvz.org/kernel/branches/rhel6-2.6.32/current/
  mirrorlist=http://download.openvz.org/kernel/mirrors-rhel6-2.6.32
  enabled=1
  gpgcheck=1
  gpgkey=http://download.openvz.org/RPM-GPG-Key-OpenVZ
  #exclude=vzkernel-firmware
  [openvz-kernel-rhel5]
  name=OpenVZ RHEL5-based kernel
  #baseurl=http://download.openvz.org/kernel/branches/rhel5-2.6.18/current/
  mirrorlist=http://download.openvz.org/kernel/mirrors-rhel5-2.6.18
  enabled=0
  gpgcheck=1
  gpgkey=http://download.openvz.org/RPM-GPG-Key-OpenVZ


Install new OpenVZ kernel

# yum install vzkernel.x86_64

Check bootloader configuration

Make sure 042stab kernel is there and will boot by default:

  cat /boot/grub/grub.conf

  timeout 5
  default 0
  title OpenVZ (2.6.32-042stab081.8)
  root (hd0,1)
  kernel /vmlinuz-2.6.32-042stab081.8 ro root=/dev/sda3 vga=0x317 selinux=0 sysfs.deprecated=1
  initrd /initrd-2.6.32-042stab081.8.img
  
  title OpenVZ (2.6.18-348.16.1.el5.028stab108.1)
  root (hd0,1)
  kernel /vmlinuz-2.6.18-348.16.1.el5.028stab108.1 ro root=/dev/sda3 vga=0x317 selinux=0
  initrd /initrd-2.6.18-348.16.1.el5.028stab108.1.img
  ....

Reboot into new kernel

# reboot

and make sure the system is up and running.

Convert /vz to ext4

If your /vz is a separate file system, you need to stop all containers and umount it first:

for ve in $(vzlist -1); do vzctl stop $ve; done
umount /vz

Alternatively, boot the node from a live-CD (such as CentOS 6 live CD).

Check file system:

# fsck.ext3 -f /dev/sdxY

Turn on ext4 features:

# tune4fs -O extents,uninit_bg,dir_index /dev/sdxY

Check the new file system again, as ext4 this time:

# fsck.ext4 -fD /dev/sdxY

If you have booted from the live CD, you can do the same for root filesystem.

If you have booted from the live CD, do this:

  • mount your ROOT and BOOT partitions:
# mkdir /tmp/root
# mount /dev/sdaB /tmp/root
# mount /dev/sdaC /tmp/root/boot
  • chroot into it:
# chroot /tmp/root

Finally, edit /etc/fstab, replacing ext3 with ext4 for /vz (and / if you converted it as well).

# vi /etc/fstab

Create new initrd with proper modules

# KV=042stab083.2
# mkinitrd -v -f --with=ext4 --builtin=ehci-hcd --builtin=ohci-hcd --builtin=uhci-hcd \
  /boot/initrd-2.6.32-${KV}.img 2.6.32-${KV}

Notes:

  • you have to add ext4 explicitly
  • in RHEL6 kernels some USB stuff (that used to be in ehci-hcd, ohci-hcd, uhci-hcd modules) is built-in

Reboot and enjoy

End result is:

     # cat /etc/issue
     CentOS release 5.10 (Final)
     Kernel \r on an \m
     
     # uname -a 
     Linux CentOS-58-64-minimal 2.6.32-042stab081.8 #1 SMP Mon Sep 30 16:52:24 MSK 2013 x86_64 x86_64 x86_64 GNU/Linux
     # df -Th
     Filesystem    Type    Size  Used Avail Use% Mounted on
     /dev/sda3     ext4    259G  1.5G  244G   1% /
      tmpfs        tmpfs     16G     0   16G   0% /dev/shm
     /dev/sda2     ext3    496M   46M  425M  10% /boot
     /dev/sdb1     ext4    1.8T  196M  1.7T   1% /vz

Next steps

You can now install ploop and enjoy all its benefits.

Also, it makes sense to convert your containers to VSwap.

See also

Acknowledgements

This article was originally written by Denis Hohryakov.