how to migrate my old linux host based on software raid 1 (md) to proxmox kvm?

rootkid

Member
Jul 2, 2010
45
1
8
Question is simple, but i've been spending 2 nghts on this. maybe i'm just thinking too complicated.

So, i have my old centos root server, it has 2 sata disks that are partitioned this way:
Code:
[root@heiwu ~]# fdisk -l

Platte /dev/sda: 400.0 GByte, 400088457216 Byte
255 heads, 63 sectors/track, 48641 cylinders
Einheiten = Zylinder von 16065 × 512 = 8225280 Bytes

    Gerät  boot.     Anfang        Ende     Blöcke   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2             132       48641   389656575   fd  Linux raid autodetect

Platte /dev/sdb: 400.0 GByte, 400088457216 Byte
255 heads, 63 sectors/track, 48641 cylinders
Einheiten = Zylinder von 16065 × 512 = 8225280 Bytes

    Gerät  boot.     Anfang        Ende     Blöcke   Id  System
/dev/sdb1   *           1         131     1052226   82  Linux Swap / Solaris
/dev/sdb2             132       48641   389656575   fd  Linux raid autodetect

Platte /dev/md0: 10.7 GByte, 10737418240 Byte
2 heads, 4 sectors/track, 2621440 cylinders
Einheiten = Zylinder von 8 × 512 = 4096 Bytes

Festplatte /dev/md0 enthält keine gültige Partitionstabelle

Grub is installed on sda.
I tried to copy /dev/md0 and sda1 (incl. mbr of sda) to my proxmox host and fire it up as raw files, no chance. I also tried to install a fresh centos host with seperate boot disk and then change out its system partition with my image of /dev/md0. Both isn't really working.

Before i spend another unsuccessfull night: What's the best way to get /dev/md0 to work in proxmox?

best regards,
Heiner
 
I've did this before, your second approach should work.

1. Make new install, /boot, / and swap partitions
2. boot a live distro
3. copy old /boot content to new /boot
4. copy old / (root) content to new /
5. !!IMPORTANT!! change /boot/grub/menu.lst to reflect new drive (eg. /dev/vda1 or whatever) OR by UUID (ls -l /dev/disk/by-uuid/)
6. !!IMPORTANT!! do the same as step 5 but with /etc/fstab
7. umount and reboot

System should come up all nice. Although it might complain about the "md0" not being found, the system should be stable. Just unconfigure MD as usual.

Let us hear how it went.
 
Thank you for replying!

Yesterday (my 3rd night shift ;) ) i finally got it up and running! The trick is:
don't take out the hard disks that contain the VM's software raid (/dev/md0)! To make it clear:

This works:
IDE 0:0 local:104/vm-104-disk-3.raw (boot device)
IDE 0:1 local:104/hetzner_v2.raw (my migrated system)
IDE 1:0 local:104/vm-104-disk-1.raw (raid hdd 0) \_____________ /dev/md0
IDE 1:1 local:104/vm-104-disk-2.raw (raid hdd 1) /

This doesn't:
IDE 0:0 local:104/vm-104-disk-3.raw (boot device)
IDE 0:1 local:104/hetzner_v2.raw (my migrated system)


I didn't need to copy /boot content, because i updated the new system's kernel to the same kernel. I also don't have a swap partition. When booting, centos notices that it's not reachable and simply leaves it out.

my fstab:
Code:
/dev/md0                /                       ext3    defaults        1 1
LABEL=/boot             /boot                   ext2    defaults        1 2
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
tmpfs                   /dev/shm                tmpfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
sysfs                   /sys                    sysfs   defaults        0 0
LABEL=SWAP-sdb1         swap                    swap    defaults        0 0
maybe the first line makes the system crash at boottime when my raid hdd's aren't installed. funny is: My system thinks, /dev/hdb is /dev/md0 :D

Code:
[root@heiwu ~]# df -h
Dateisystem          Größe Benut  Verf Ben% Eingehängt auf
/dev/md0              9,7G  8,8G  459M  96% /
/dev/hda1              99M   14M   81M  15% /boot
tmpfs                1006M     0 1006M   0% /dev/shm
i know, this is far away from a clean system. But who cares - it works. Don't want to risk anything and modify this config. I can now build my new concept on new VMs and move the services little by little from this one.

But just for interest:
if i changed /dev/md0 to /dev/hdb in fstab, would it work and make "df" say the truth?

Best regards,
Heiner
 
I have no idea what you have done, but I'm happy it worked.

I'm just curious, what does "fdisk -l" show?

One more thing, you have 2x400GB in mirrored raid - still your "df -h" shows a 100MB /boot and a 10GB root... What happened to the rest?
 
Code:
[root@heiwu ~]# fdisk -l

Platte /dev/hda: 10.7 GByte, 10737418240 Byte
255 heads, 63 sectors/track, 1305 cylinders
Einheiten = Zylinder von 16065 × 512 = 8225280 Bytes

    Gerät  boot.     Anfang        Ende     Blöcke   Id  System
/dev/hda1   *           1          13      104391   83  Linux
/dev/hda2              14        1305    10377990   83  Linux

Platte /dev/hdb: 10.7 GByte, 10737418240 Byte
255 heads, 63 sectors/track, 1305 cylinders
Einheiten = Zylinder von 16065 × 512 = 8225280 Bytes

Festplatte /dev/hdb enthält keine gültige Partitionstabelle

Platte /dev/hdc: 5368 MByte, 5368709120 Byte
255 heads, 63 sectors/track, 652 cylinders
Einheiten = Zylinder von 16065 × 512 = 8225280 Bytes

    Gerät  boot.     Anfang        Ende     Blöcke   Id  System
/dev/hdc1   *           1         522     4192933+  fd  Linux raid autodetect

Platte /dev/hdd: 5368 MByte, 5368709120 Byte
255 heads, 63 sectors/track, 652 cylinders
Einheiten = Zylinder von 16065 × 512 = 8225280 Bytes

    Gerät  boot.     Anfang        Ende     Blöcke   Id  System
/dev/hdd1   *           1         522     4192933+  fd  Linux raid autodetect

Platte /dev/md0: 4293 MByte, 4293459968 Byte
2 heads, 4 sectors/track, 1048208 cylinders
Einheiten = Zylinder von 8 × 512 = 4096 Bytes

Festplatte /dev/md0 enthält keine gültige Partitionstabelle
/dev/hda1 is my boot partition, hda2 has no function.
i managed to shrink my /dev/md0 down to about 7.8GB, so that it is more comfortble to transfer :)
Beside of the differences mentioned my last post, i did it like you did.
 
After i managed to successfully backup and restore my VMs, i tried out what would happen if i correct my fstab:
Code:
[root@heiwu ~]# cat /etc/fstab
#/dev/md0                /                       ext3    defaults        1 1
/dev/hdb                /                       ext3    defaults        1 1

this is the result (after rebooting):
Code:
[root@heiwu ~]# df -h
Dateisystem          Größe Benut  Verf Ben% Eingehängt auf
/dev/hdb              9,7G  7,8G  1,5G  85% /
/dev/hda1              99M   14M   81M  15% /boot
tmpfs                1006M     0 1006M   0% /dev/shm

then i took away the drives forming /dev/md0.
I had to completely shut down and fire up the System (i suppose reboot doesn't let him rescan IDE) to get a sweet looking fdisk -l:
Code:
[root@heiwu ~]# fdisk -l

Platte /dev/hda: 10.7 GByte, 10737418240 Byte
255 heads, 63 sectors/track, 1305 cylinders
Einheiten = Zylinder von 16065 × 512 = 8225280 Bytes

    Gerät  boot.     Anfang        Ende     Blöcke   Id  System
/dev/hda1   *           1          13      104391   83  Linux
/dev/hda2              14        1305    10377990   83  Linux

Platte /dev/hdb: 10.7 GByte, 10737418240 Byte
255 heads, 63 sectors/track, 1305 cylinders
Einheiten = Zylinder von 16065 × 512 = 8225280 Bytes

Festplatte /dev/hdb enthält keine gültige Partitionstabelle

I think it doesn't really matter that it says there's no partition table on hdb, does it?

best regards,
Heiner
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!