2 Replies Latest reply on Sep 28, 2005 12:26 AM by d0nd

    linux manually p2v

    msli Novice

      hi,

      i would like to migrate a real SLES server to virtual machine. Do you have any guide/information to manually migrate physical linux servers to virtual servers?

      this is what i have done for the moment :

      \- ghost image of sles

      \- import ghost image in a virtual disk

        • 1. Re: linux manually p2v
          rjohnso5 Novice

          Here's what I did for a Redhat 9 machine. Maybe you can adapt it?

           

          Migrating a Linux Machine to VMWare ESX

           

          Before the Linux image is ghosted, the BusLogic scsi driver must be either loaded

          into the kernel at boot or compiled into a new kernel. Many Linux installations use

          a two-stage boot process, consisting of an "initrd" (i.e., initial RAM disk) followed

          by the normal boot process. The initial RAM disk is used to load drivers, etc.,

          into the kernel before switching to the root disk.

           

          Note: In VMWare Workstation 4.0, the linux VM uses initrd to load the BusLogic scsi

          module, as well as scsi support modules. So, we follow the same process in ESX.

          To check what loadable modules have been loaded into the kernel:

           

          lsmod

           

          Check for initrd by displaying the contents of the bootloader:

           

          more /etc/grub.conf

          more /etc/lilo.conf

           

          Example grub configuration: (all paths are relative from /boot)

           

          default=0

          timeout=10

          splashimage=(hd0,0)/grub/splash.xpm.gz

          title Red Hat Linux (2.4.20-8)

                  root (hd0,0)

                  kernel /vmlinuz-2.4.20-8 ro root=LABEL=/

                  initrd /initrd-2.4.20-8.img

          (end example)

           

          According to the grub configuration, on boot an initial RAM disk image is being

          used before passing control to the root ide or scsi disk. The contents of the RAM

          disk consists of whatever is in "initrd-2.4.20-8.img". There is a procedure to

          check the image file's contents, which we will explore later.

           

          If the initrd line is not in the grub or lilo configuration then check for two things:

          Go to the /boot directory and "more config-2.4.20-8" and look for

               - CONFIG_BLK_DEV_RAM=Y

               - CONFIG_BLK_DEV_INITRD=Y

           

          If the two lines cannot be found it means that RAM disk and initrd support were not

          compiled into the kernel. This means you must compile scsi support into a new kernel -

          you cannot load them into the kernel at boot.

           

          If the two lines are present, but the initrd line is missing from the grub or lilo

          configuration, then an initrd image file has to be generated using mkinitrd or

          something similar.

           

          Back to the initrd image file. Hack into it by:

           

          cd /boot

          gzip -dc initrd-2.4.20-8.img >/tmp/initrd.ext2

          mkdir /mnt/initrd

          mount -o loop /tmp/initrd.ext2 /mnt/initrd

          cd /mnt/initrd

          ls

           

          There should be a directory structure and a file called "linuxrc". "linuxrc" will

          load device drivers, etc., from the initial root disk (i.e., the RAM disk). To add

          BusLogic scsi support, the following lines should be added to "linuxrc".

           

          echo "Loading scsi_mod.o module"

          insmod /lib/scsi_mod.o

          echo "Loading sd_mod.o module"

          insmod /lib/sd_mod.o

          echo "Loading BusLogic.o module"

          insmod /lib/BusLogic.o

           

          The object "o" files must be copied into the "lib" directory.

           

          cd /lib/modules/2.4.20-8/kernel/drivers/scsi

          cp BusLogic.o /mnt/initrd/lib

          cp scsi_mod.o /mnt/initrd/lib

          cp sd_mod.o /mnt/initrd/lib

           

          Unmount /mnt/initrd. The changes/additions will be saved in /tmp/initrd.ext2.

           

          umount /mnt/initrd

           

          Compress a new image. Rename the existing image, first!

           

          cd /boot

          mv initrd-2.4.20-8.img initrd-2.4.20-8.img.old

          gzip -c /tmp/initrd.ext2 > /boot/initrd-2.4.20-8.img

           

          The linux server can now be ghosted. Before you ghost make sure the Linux server is

          not booting into X Server. Change the bootlevel to "3" by modifying /etc/inittab.

           

          After ghosting the image into an ESX VM, Linux will not reboot properly because the

          bootloader has been overwritten. Follow this procedure to repair a grub

          bootloader.

           

          1) Boot from Linux disk1 and type "linux rescue"

          2) Select all defaults, then you will receive a message saying:

          "If you would like to make your system the root environment, run the command:

          chroot /mnt/sysimage"

          Go ahead and do that.

          3) You can use "grub-install /dev/hda", but when going from ide to scsi, the device

          names will change. The following can be used instead.

           

          grub

          grub> root (hd0,0)

          (the first partition (0) of your first hard disk (hd0) )

          (you should see a message as follows: Filesystem type is Ext2fs, partition type is 0x83)

          grub> setup (hd0,0)

          (This will install grub in the MBR of the first hard disk)

          grub> quit

           

          Reboot the machine.

           

          Linux should now boot in the VM. (The BusLogic scsi driver will load via initrd).

          KUDZU will activate and prompt you to remove drivers that are no longer needed.

          Go ahead and remove them.

           

          When going from ide to scsi, some device links may get broken.

          For example, when installing the VMWare Tools, you may receive a message saying,

          "the special device /dev/cdrom does not exist". In this case, do the following:

           

          dmesg | grep CD

           

          It will tell you what the CD is linked to, say "hda" in this case. Create a new link.

           

          ln -s /dev/hda /dev/cdrom

           

          (the correct permissions for the CD device is "brw-rr")

           

          Now the CD should be available.

           

          Try to stay away from the X Windows environment until you get the VMWare Tools installed.

           

          *See page 40 of the VMWare Administration Guide for installing VMWare Tools*

           

          To get the Linux VM to work with DHCP:

           

          To work around this problem, become root (su -) and use a text editor to edit the

          following files in the guest operating system. If only one of these files exist,

          then make the change for that file only.

           

          /etc/sysconfig/network-scripts/ifcfg-eth[n]

          /etc/sysconfig/networking/devices/ifcfg-eth[n]

           

          where, in both cases, is the number of the Ethernet adapter -- for example, eth0.

           

          Add the following section to each of these two files:

           

           

             check_link_down () {

                 return 1;

             }

           

          Then, run the command ifup eth[n] (where is the number of the Ethernet adapter) or

          restart the guest operating system.

           

          To change the hostname: "file://
          Bertha\source\VMWare\ESX\TreePad\861.mht"

           

          To change the IP address:

          "file://
          Bertha\source\VMWare\ESX\TreePad\Re_ IP address editing.txt"

           

          NOTE: There may be more issues to resolve down the road...

          • 2. Re: linux manually p2v
            d0nd Hot Shot

            Just wanted to thank you for this great walkthru