User Tools

Site Tools


linux:redhat_p2v

Redhat (RHEL) 4.5 P2V

Hello, this documentation is mostly for me. I will be doing P2V of a very old RHEL 4.5 physical NEC server, to VMWare. I tested this on VirtualBox, but now I'm trying for long term…

DO THIS AT YOUR OWN RISK. If your data is worth money to you, then pay for a product / service to do this… This is just my own lucky experience.

You could also try this https://manpages.ubuntu.com/manpages/bionic/man1/virt-p2v.1.html . I do things the hard way.

TL;DR When you take the physical disk image, the VM likely won't boot, due to kernel panics. So, replace the kernel!

Get Disk Images - Hot

I performed a hot copy of the disks, which isn't great, but it is what I have for now, until I get server time.

On the source machine, I did this for each disk:

dd if=/dev/sda conv=sync bs=64k | gzip -c | ssh someUser@SomeOtherHost ff of=/cpy/srcHost-sda.gz
...
dd if=/dev/sdd conv=sync bs=64k | gzip -c | ssh someUser@SomeOtherHost ff of=/cpy/srcHost-sdd.gz

I didn't come up with that beauty. See: dd manual - 4.2 Create disk image

This is a quick-ish way to get the disk off of the source machine, and a somewhat compressed copy on the destination.

Purists will tell you to never do that. Whatever. 1st pass test of feasibility. Do so at your own risk.

Create Donor CentOS 4.5 VM

Create a simple VM in your Host environment. Use CentOS 4.5, or what ever kernel matches your P2V system. If you have your RedHat install media, good for you. Use that. I don't know where my copy is, so CentOS is a close 2nd. I got that tip from a forum post. https://www.linuxquestions.org/questions/red-hat-31/how-to-download-rhel-4-ws-337281/

Helpful list of kernel versions to system versions: Red Hat Enterprise Linux Release Dates

CentOS Releases Download CentOS Linux ISO images - Section 4

For me, I needed 4.5 CentOS 4.5 . I did a minimal installation, so I only needed CD 1 of 4. You will need to get the boot ISO out of the CD, as the CD itself is not bootable… Go figure…

Do the install, and make sure it is bootable.

Copy working kernel

I got the idea from Copying a Linux Kernel From One System to Another . I don't quite use their method, as they make a new image..

Modify the Donor VM to include the system disk from the physical system. You copied the disk image to the VM Host, right?

When I run

cat /proc/partitions

I get the following:

[root@localhost proc]# cat partitions
major minor  #blocks  name

   8     0    8388608 sda
   8     1     104391 sda1
   8     2    8281507 sda2
   8    16   35564544 sdb
   8    17      56196 sdb1
   8    18     128520 sdb2
   8    19    3148740 sdb3
   8    20          1 sdb4
   8    21    3582463 sdb5
   8    22    6289416 sdb6
   8    23    4192933 sdb7
   8    24    4192933 sdb8
   8    25   13968486 sdb9
 253     0    6193152 dm-0
 253     1    2031616 dm-1
[root@localhost proc]#

sda is my Donor boot disk. sdb is my copied disk. For me, my boot image comes from sdb2, yours may be sdb1.. Just mount it and see!

On the Donor, make a folder to mount to.

[root@localhost proc]# cd /
[root@localhost /]# mkdir sdb2
[root@localhost /]#

Now jump into the directory and see if it is a winner!

[root@localhost /]# mount /dev/sdb2 /sdb2
[root@localhost /]# cd sdb2
[root@localhost sdb2]# ls
config-2.6.9-34.EL     grub                       initrd-2.6.9-55.ELsmp.img  System.map-2.6.9-34.ELsmp  vmlinuz-2.6.9-34.ELsmp
config-2.6.9-34.ELsmp  initrd-2.6.9-34.EL.img     lost+found                 System.map-2.6.9-42.EL     vmlinuz-2.6.9-42.EL
config-2.6.9-42.EL     initrd-2.6.9-34.ELsmp.img  memtest86+-1.26            System.map-2.6.9-42.ELsmp  vmlinuz-2.6.9-42.ELsmp
config-2.6.9-42.ELsmp  initrd-2.6.9-42.EL.img     message                    System.map-2.6.9-55.EL     vmlinuz-2.6.9-55.EL
config-2.6.9-55.EL     initrd-2.6.9-42.ELsmp.img  message.ja                 System.map-2.6.9-55.ELsmp  vmlinuz-2.6.9-55.ELsmp
config-2.6.9-55.ELsmp  initrd-2.6.9-55.EL.img     System.map-2.6.9-34.EL     vmlinuz-2.6.9-34.EL
[root@localhost sdb2]#

I see my vmlinuz-2.6.9-55.ELsmp file, so, bingo! I don't want to replace it, directly, so I'll copy next to it.

But, first, we need our source boot kernel images. To do that, we need to mount our Donor boot partition.

[root@localhost sdb2]# cd /
[root@localhost /]# mkdir sda1
[root@localhost /]# mount /dev/sda1 /sda1
[root@localhost /]# cd sda1
[root@localhost sda1]# ls -a
.                   config-2.6.9-55.ELsmp   initrd-2.6.9-55.ELsmp.img  message.ja                 vmlinuz-2.6.9-55.EL
..                  grub                    lost+found                 System.map-2.6.9-55.EL     vmlinuz-2.6.9-55.ELsmp
config-2.6.9-55.EL  initrd-2.6.9-55.EL.img  message                    System.map-2.6.9-55.ELsmp
[root@localhost sda1]#

Ok, now we can copy. NOTICE the 'c' I placed after the 55, in the destination files. Like I said, I'll copy next to…

cp initrd-2.6.9-55.ELsmp.img /sdb2/initrd-2.6.9-55c.ELsmp.img
cp initrd-2.6.9-55.EL.img /sdb2/initrd-2.6.9-55c.EL.img
cp vmlinuz-2.6.9-55.EL /sdb2/vmlinuz-2.6.9-55c.EL
cp vmlinuz-2.6.9-55.ELsmp /sdb2/vmlinuz-2.6.9-55c.ELsmp

# I don't know what these are...  Copy anyways?
cp System.map-2.6.9-55.EL /sdb2/System.map-2.6.9-55c.EL
cp System.map-2.6.9-55.ELsmp /sdb2/System.map-2.6.9-55c.ELsmp

Now we need to patch the GRUB list

[root@localhost sda1]# cd /sdb2/grub
[root@localhost grub]# nano menu.lst

This file is crazy, and you can easily make your system non-bootable! Simply find your kernel files, and add your extra 'c'

Old:

title Red Hat Enterprise Linux ES (2.6.9-55.ELsmp)
        root (hd0,1)
        kernel /vmlinuz-2.6.9-55.ELsmp ro root=/dev/sda6 rhgb
        initrd /initrd-2.6.9-55.ELsmp.img
title Red Hat Enterprise Linux ES (2.6.9-55.EL)
        root (hd0,1)
        kernel /vmlinuz-2.6.9-55.EL ro root=/dev/sda6 rhgb
        initrd /initrd-2.6.9-55.EL.img

New:

title Red Hat Enterprise Linux ES (2.6.9-55c.ELsmp)
        root (hd0,1)
        kernel /vmlinuz-2.6.9-55c.ELsmp ro root=/dev/sda6 rhgb
        initrd /initrd-2.6.9-55c.ELsmp.img
title Red Hat Enterprise Linux ES (2.6.9-55c.EL)
        root (hd0,1)
        kernel /vmlinuz-2.6.9-55c.EL ro root=/dev/sda6 rhgb
        initrd /initrd-2.6.9-55c.EL.img

Save and exit.

Now, we un-mount our partitions, and power down the Donor VM.

[root@localhost grub]# cd /
[root@localhost /]# umount /dev/sda1
[root@localhost /]# umount /dev/sdb2
[root@localhost /]#
[root@localhost /]# shutdown -h now

Broadcast message from root (pts/0) (Thu Jun 27 18:36:06 2024):

The system is going down for system halt NOW!
[root@localhost /]#

Now you need to remove the disk association, and power up the P2V VM!





linux/redhat_p2v.txt · Last modified: 2024/06/27 14:49 by srbios

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki