I'm trying to convert a VM to a physical dedicated server.
I have access to the VM OS only (CentOS 6.7). I have no access to hypervisor.
I would like to use the dd
command to dump the VM disk, and then write that image with dd
onto the HD of the dedicated server. To do this I will probably need to boot the server from a Live CD.
My question is: this will work? It would be better to copy all files and directories in / from one server to another with rsync
?
You should handle that migration at the application level, so that you have a clean start with the new server and no leftover migration cruft (like hypervisor tools and drivers) lying around.
Start with a list of all the things the server currently hosts, and migrate those roles individually onto the new server using migration procedures specific to each application, with a rollback plan and testing procedure for each. Then, decommission the old server.
Since the Physical Server will have different hardware, I would not suggest cloning the disk. I would recommend installing the same version of CentOS to physical server and then copy relevant folders/directories. Just be selective when you copy /etc and other system folders.
I would install Cent O.S. on the Physical Machine. This cuts down on the rsync time, allows you to setup permissions and grub for the physical machine. Then rsync from the VM. I see no reason to live boot in this scenario. You probably don't want to rsync all of root, so you will need some excludes. What you exclude varies some depending on your environment. This site has a nice example exclude list to look at.
http://www.rackspace.com/knowledge_center/article/migrating-a-linux-server-from-the-command-line-0
You may also consider throttling the rsync depending on your network and the size of the server.
So from the VM run
The -a preserves permissions and time stamps. The --delete removes any files that are on the physical server but not on the vm. The --bwlimit throttles the rsync. The Exclude-from excludes patterns found in your exclude file.
Potential Issues
If you are using ACL's they wont transfer during an rsync. You can do a export and import if needed though.
If you are using the Disk ID in your fstab, and you overwrite the new fstab your partitions will not mount. If your not sure, just exclude the fstab file from the rsync and add any needed lines to the file after.
Just like fstab your network config scripts will need to be excluded or looked at for potential problems.
There are other options that will work equally well for this, but this method has worked well for me.
simple dd wouldn't work - guests don't have correct boot partitions. And dd is slow. Manual way - install a minimal centos 6.7 on a system - make sure to use a separate /boot partition, and pre-create all other partitions (including fs, but not necessarily mountpoints).
now livecd your minimal centos, and using nc and tar overwrite everything but the /boot partition, one partition at a time. this will also be much quicker than dd.
a sample nc/tar invocation; on physical machine:
on virtual side:
repeat for each partition except boot.
Eric's caveats hold here as well - you might have to modify any hardware specific file, including networking, fstab and udev rules. You will have to pay attention to modprobe as paravirt network drivers differ from their real counterparts.
Other option - search the net for v2p solutions.