1

I need to migrate one CentOS5 (32bit) physical server to in a virtual machine. My idea is to take a snapshot of the LV and then import in kvm creating a new vm. Is this a good idea? More precisely, I have one disk:

[root@cs5 ~]# fdisk -l

Disco /dev/sda: 292.3 GB, 292326211584 byte

255 heads, 63 sectors/track, 35539 cylinders
Unità = cilindri di 16065 * 512 = 8225280 byte

Dispositivo Boot      Start         End      Blocks   Id  System
/dev/sda1               1           9       72261   de  Dell Utility
/dev/sda2   *          10         271     2104515    b  W95 FAT32
/dev/sda3             272         284      104422+  83  Linux
/dev/sda4             285       35539   283185787+   5  Esteso
/dev/sda5             285       35539   283185756   8e  Linux LVM

and

[root@cs5 ~]# mount
/dev/mapper/VolGroup00-LogVol00 on / type ext3 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
/dev/sda3 on /boot type ext3 (rw)
tmpfs on /dev/shm type tmpfs (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)

So pv, vg and lv are:

[root@cs5 ~]# pvs
  PV         VG         Fmt  Attr PSize   PFree
  /dev/sda5  VolGroup00 lvm2 a-   270,06G    0 
[root@cs5 ~]# vgs
  VG         #PV #LV #SN Attr   VSize   VFree
  VolGroup00   1   2   0 wz--n- 270,06G    0 
[root@cs5 ~]# lvs
  LV       VG         Attr   LSize   Origin Snap%  Move Log Copy%  Convert
  LogVol00 VolGroup00 -wi-ao 264,91G                                      
  LogVol01 VolGroup00 -wi-ao   5,16G

As showed, I have /dev/sda3 mounted in /boot and 2 LV, one for / and another that works as swap partition. I think that the only snapshot I need is LogVol00, right?

At this point, I need to add another disk to the PV and then add it to the VG and finally create the snapshot with

lvcreate -L XXG -s -n data_snap /dev/VolGroup00/LogVol00

Now, how can I import that snapshot in a vm? I can create a tar.gz of the snapshot or I can use dd, but I don't have a boot partition for the vm. Should I first install a new vm and then (booting in single mode) overwrite all files in / (except /boot) ?? Is there some other method?? Thanks

1 Answer 1

2

You basically have three choices:

  • boot with a live CD/USB, take a copy of the entire /dev/sda, and restore it on the KVM host.
  • make a copy of both the LVM volume (via snapshot or, better yet, boot via CD/USB and copy the LVM volumes while it is inactive) and the /boot partition. Then, live boot your virtual machine, restore the partition, chroot into the newly restored root and reinstall GRUB on the MBR
  • if applicable, you can use the p2v tools from Red Hat

If all the approach fail, your best alternative is to install a new RHEL 5 guest and migrate the data from the old machine (eg: via rsync)

6
  • My idea is to reduce the downtime and for this reason I'd like to use an lvm snapshot. Furthermore, it seems that p2v tools are useful from rhel6. Could I start the vm with a livecd and then rsync the snapshot? Jan 7, 2016 at 9:11
  • If you want as little downtime as possible, my suggestion is to install a new RHEL 5 guest and rsync your data twice: the first time for initial seed, the second time for the final, fast sync. After the first initial transfer you had check that all is working properly on the new VM, then you can go ahead with the second transfer.
    – shodanshok
    Jan 7, 2016 at 9:37
  • I'm trying now but I have a problem when I try to login to the vm. Bash returns to the login. What I done: start the vm with systemrescuecd, mount LV in /mnt/disk, rsync from the physical server the /lvm-snapshot/ folder (that contains the mounted snapshot of the server) to /mnt/disk and reboot the vm. What I'm wrong? Jan 7, 2016 at 9:40
  • For some reason bash can not authenticate you, but without details it is impossible to tell you why. What command do you use for transfer data? Have you transferred all permission/acl/metadata? If not, please retransfer it using rsync -avAX
    – shodanshok
    Jan 7, 2016 at 9:44
  • Ok, before I'm using: rsync -avh /lvm-snapshots/ [email protected]:/mnt/disk/ but now, with rsync -avaX /lvm-snapshots/ [email protected]:/mnt/disk/ all seems to work well. Really thank you! Jan 7, 2016 at 10:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .