Sep 20, 2010

Migrating Redhat XEN Virtual Machine to VMware 1.x

Migrating Redhat XEN Virtual Machine to VMware 1.x


Release:

RedHat Enterprise Linux

VMware 1.x


Problem:

Migrating Redhat Xen virtual machine to VMware Server 1.x


Solution:

Note: Only “Fully Virtualized” Xen virtual machines are able to be migrated to VMware

Configuration changes to be done on Xen virtual machine:

1) Modify /etc/modprobe.conf to add the proper SCSI and network card modules which are configured in Vmware Server.

# vi /etc/modprobe.conf

alias eth0 pcnet32

alias scsi_hostadapter mptbase

alias scsi_hostadapter1 mptspi

alias scsi_hostadapter2 ata_piix

Note: Once modified the kernel modules, you won’t be able to properly start the machine, and you will receive a Kernel panic error message.


Convert VM migration disk:

          To convert a XEN machine in a .vmdk format to be used with VMware, a tool called qemu will be used. QEMU is a generic and open source machine emulator and virtualizer. It is also a fast processor emulator using dynamic translation to achieve good emulation speed.


2) Download qemu from the below link

http://dag.wieers.com/rpm/packages/qemu/


3) Install the downloaded RPM

# rpm –ivh qemu-0.12.4-1.el5.rf.i386.rpm


4) Convert the XEN machine disk to VMware disk

# qemu-img convert -O vmdk


5) Now we have a valid VMware Server 1.xx disk device file. This can be added on onto any VMware Server.


6) Create a new virtual machine. Under Hard disk configuration, select “use existing hard disk”.


Note: If the storage controller and network controllers are not integrated in /etc/modprobe.conf, system might refuse to boot. Hence, it is mandatory to add necessary links to driver modules.

Sep 13, 2010

Migrate user accounts from old Linux server to new Linux server


Migrate user accounts from old Linux server to new Linux server

Release:

RedHat Enterprise Linux

 

Problem:

Migrate user accounts from old Linux server to new Linux server

 

Solution:

The below procedure explains how to migrate users from old Linux server to new fresh installation.

 

Required files and directories:

            The following files and directories are required for Linux user account management

/etc/passwd – Contains various information about each user account

/etc/shadow – Contains the encrypted password information for user’s accounts

/etc/group – Defines the groups to which users belong

/etc/gshadow - group shadow file (contains the encrypted password for group)

/var/spool/mail – Generally user emails are stored here

/home – All users home directory and data is stored here

All these files and directories are need to copy from old server to new server.

 

Assumptions:

a)      Users that are added to the Linux system always start with UID and GID values of as specified by Linux distribution or set by admin. In RHEL default is 500 and maximum limit is 65534.

 

b)      The home directory of all the users is kept in /home. If there are different locations, it is mandatory to take separate backup of each location.


c)       There are enough space in /migrate file system to hold the backup of user’s directories.

 

Old Server side Configuration:

 

1)      Create a tar ball of the users home directory and mails

# mkdir /migrate

# cd /migrate

# tar –czvpf home.tar.gz /home

# tar –czvpf mail.tar.gz /var/spool/mail

 

2)      Now copy all the required user account management files from the old server

# export UGIDLIMIT=500

 

# awk –v LIMIT=$UGIDLIMIT –F: ‘($3>=LIMIT) && \               ($3!=655354)’ /etc/passwd > /migrate/passwd.old

 

# awk –v LIMIT=$UGIDLIMIT –F: ‘($3>=LIMIT) && \ ($3!=655354)’ /etc/group > /migrate/group.old

 

# awk –v LIMIT=$UGIDLIMIT –F: ‘($3>=LIMIT) && ($3!=65534) \ {print $1}’ /etc/passwd | tee - | egrep –f - /etc/shadow \ > /migrate/shadow.old

 

# cp /etc/gshadow /migrate/gshadow.old

 

The above three commands to extract only normal user details from /etc/passwd, /etc/group,  /etc/shadow and /etc/gshadow from UID/GUID from 500 (Refer the assumptions).

 

3)      Copy all the files inside the /migrate to the new server using scp or pendrive

 

New Server side Configuration:

 

4)      Take the backup of the user account management files in the new server

# mkdir /backup

# cp /etc/passwd /etc/group /etc/shadow /etc/gshadow /backup

 

5)      Copy all the files copied from the old server in new server within /new directory

# mkdir /new

# cd /new

 

6)      Now restore all the files

# cat passwd.old >> /etc/passwd

# cat group.old >> /etc/group

# cat shadow.old >> /etc/shadow

# cp gshadow.old /etc/gshadow

# chmod 0400 /etc/gshadow

# chown root:root /etc/gshadow

 

7)      Now copy and extract the users home directory and mail backups

# cd /

# tar –zxvf /new/home.tar.gz

# tar –zxvf /new/mail.tar.gz

 

8)      Reboot the server and check

# init 6