028 to 042 kernel upgrade

From OpenVZ Virtuozzo Containers Wiki
Revision as of 13:21, 26 May 2015 by 79.112.22.184 (talk)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

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[edit]

yum update

Install required software:

yum install e4fsprogs.x86_64

Add rhel6 kernel repos[edit]

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[edit]

# yum install vzkernel.x86_64

Check bootloader configuration[edit]

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[edit]

# reboot

and make sure the system is up and running.

== For linux swraid (mdadm) users with bitmap enabled and low IO write speed, you might need to redo bitmap cat /proc/mdstat , if chunk size is small , try (example for internal bitmap) : mdadm --grow --bitmap=none /dev/md2 ; mdadm --grow --bitmap=internal --bitmap-chunk=16384 /dev/md2

Convert /vz to ext4[edit]

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 -fpD /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[edit]

# KV=042stab083.2
# mkinitrd -v -f --with=ext4 --without-usb /boot/initrd-2.6.32-${KV}.img 2.6.32-${KV}

Notes:

  • you have to add ext4 explicitly
  • in RHEL6 kernels USB modules are built-in

Reboot and enjoy[edit]

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[edit]

You can now install ploop and enjoy all its benefits.

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

See also[edit]

Acknowledgements[edit]

This article was originally written by Denis Hohryakov.