Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Using the linux command 'dd' you can clone a partition to a .img file. I have used this method for duplicating flash drives for use with many servers in the past. Then if one goes down, it is very easy to restore it if needed.

Does anyone know if a similar thing is possible to do over a network? I have a Redhat server that I would like copy everything from, in order to create a Fedora server with the same settings.

share|improve this question

migrated from stackoverflow.com Aug 30 '12 at 11:34

This question came from our site for professional and enthusiast programmers.

4 Answers 4

up vote 2 down vote accepted

I believe you can do something like this:

dd if=/dev/hda | ssh user@destination.com "dd of=/path/to/destination.iso"

Of course, make sure that you have setup passwordless login with private SSH key.

Note that if you just want to copy the settings, this is not the best approach - especially if you are migrating to a different distribution.

In addition, for a server CentOS may be better suited. It has the additional advantage that you should be able to upgrade from RHEL to CentOS with relative ease (when compared to a migration to fedora) since both distributions are closely related. Read the CentOS Migration Guide for more information.

With fedora such a thing is not possible afaik, and you are probably going to have to do a clean install and migrate all settings manually.

share|improve this answer
    
Also remember that cloning an in-use filesystem can get you an inconsistent state. It would be better to boot from a live cd or at least remount-ro on the source server. –  ptman Aug 30 '12 at 11:41
    
Of course, but the command remains the same if you boot from a livecd. You just need to make sure you have your SSH private key somewhere (possibly an USB flash drive) –  brain99 Aug 30 '12 at 11:42
    
Thank you, am I right in believing this would copy the entire contents of the disk and therefore the Redhat install itself? I am being slightly awkward and trying to find a quick and painless way of just copying the settings to a new distro, since I don't have a Redhat key. –  Jon Aug 30 '12 at 12:00
    
Yes, this will copy the entire disk. If you copy/clone the main disk on which Redhat is installed, then the clone will also have a full Redhat installation. I edited my answer with some additional information. –  brain99 Aug 30 '12 at 12:36
    
Thanks that's very clear. What do you think about copying every folder instead? I could avoid the boot partition and just copy all the config files etc. However, I have just ran a 'df' on the Redhat server and found that there is only one partition? Does that mean the boot files are mixed in with everything else, making it more difficult for me? Filesystem 1K-blocks Used Available Use% Mounted on /dev/xvda1 82568880 3048856 75325792 4% / tmpfs 957244 0 957244 0% /dev/shm –  Jon Aug 30 '12 at 15:07

I don't know where windoes comes into this but linux you could do something line

Remote system

nc -l -p 8001|bzip2 -d|dd bs=16M of=/dev/sdb

then on the local system

dd bs=16M if=/dev/sda|bzip2 -c|nc remote.system.tld 8001
share|improve this answer
    
nc doesn't encrypt, ssh does. Only do this on a local network. –  ptman Aug 30 '12 at 11:42

'dd' copying works well to make an exact clone, but you need to power down the machine first, and boot from another medium or partition (dd-ing a mounted/active filesystem, and then restoring it might work just fine, or might break horribly... no way to know for sure how or when it will break, but i would not like to test my luck with that).

What you want to do (since you just want to clone just the configuration to another server) is to just install fedora with the same packages as the ones you have on Redhat and then copy the needed (non-default == changed) config files to it, and hope the (possible) different package versions still work with the same configs.

If you want to do it over a network, just "scp" the needed configs to your new, fedora, server.

share|improve this answer
    
Thanks, I am wanting to install Tomcat, Apache and MySQL on the Fedora box like with Redhat. Do you know the relevant config files/locations I would need to copy across? –  Jon Aug 30 '12 at 12:02

There is a wrapper around dd + netcat called g4u. It is a free bootable iso that you can flash on a thumb drive or burn onto a cd. It works with an ftp server on the other side. It is very reliable and well documented.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.