[CentOS] Re: transfer data from one hard drive to another

Wed Oct 11 16:07:14 UTC 2006
Lorenzo Martínez Rodríguez <Lawwait at yahoo.es>


To migrate complete filesystems (even the softlinks and conserving the
permissions asigned to users) I use this procedure:

1.- Connect the new disk to the machine I have the filesystem to clone
2.- Run with a LiveCD to avoid open files and to preserve the integrity
of everything OK.
3.- Create /tmp/original and /tmp/destination directories as mountpoints
4.- Mount both filesystems in the created mountpoints (before that the
new filesystem must be created in new disk, you know, format disk
partition, create filesystem and mount)
5.- Change directory to /tmp/original
6.- tar cf - . | (cd /tmp/destination && tar xvfp -)

I have always used this procedure to clone it. The only problem making
this process is that if the original filesystem was bootable filesystem
you have to recreate the 0 sector with grub (The problem when you boot
with a Live CD is that if you make "grub-install /dev/hda", /dev is
mounted outside the filesystem, it does not correspond with your hda, so
you have to make a trick I will describe below these lines).
To do this, I boot the machine with an Ubuntu LiveCD (I have only got it
working with this Live distro) to make the partition bootable. The steps
I follow to do this are next:

1.-) Boot Ubuntu LiveCD
2.-) mount the filesystem to be bootable in /tmp/pp (previously created)
3.-) mount --bind /dev /tmp/pp/dev (this will remount /dev filesystem
inside the filesystem we have just cloned)
4.-) chroot /tmp/pp (yeah now the filesystem is yours)
5.-) grub-install /dev/hda
6.-) umount everything and reboot...

everything will work like a charm. I have been trobules with the disks
of my home server and this is what I've done.

Hope it helps everybody



Scott Silva wrote:
> chrism at imntv.com spake the following on
> 10/7/2006 5:10 AM:
>   
>> Lamar Owen wrote:
>>     
>>> On Friday 06 October 2006 22:42, Joseph Cheng wrote:
>>>  
>>>       
>>>> Thx for all the suggestions ppl. I think for simplicity I will either
>>>> go with the knoppix & dd solution or I also found ghost 4 unix
>>>> http://www.feyrer.de/g4u/
>>>>     
>>>>         
>>> I have used the dd solution a number of times, and it works quite well.
>>> There are, however, a couple of suggestions I would make:
>>> 1.) Use the CentOS rescue mode (boot CD number 1, type 'linux rescue'
>>> at the boot prompt) and tell it not to mount your drives.  No need to
>>> download Yet Another Linux Distribution to do the work.  Or use the
>>> CentOS LiveCD.
>>> 2.) While the dd is running, you can check on its progress.  Switch to
>>> another virtual console (you are by default on VC 1; hit ALT-F2 to go
>>> to VC 2) and send the dd process a SIGUSR1 (run a ps ax and make a
>>> note of the dd process's PID; then kill -USR1 $PID); then switch back
>>> to VC 1 and you'll see where dd is in your copy.
>>>
>>> You can then run fdisk or parted and grow the partition; then you can
>>> resize the filesystem (I'm fairly certain the rescue mode includes the
>>> resizing program; not sure about the LiveCD, but I would think it
>>> does).  The native CentOS tools to do this are, in my experience, far
>>> superior in quality to the various third party solutions (including
>>> Symantec Ghost) availabe to do this sort of thing.  They are a little
>>> harder to use, though they seem to work better.
>>>   
>>>       
>> Interesting.  I wonder if you used this method to copy the image from
>> one disk to an identical disk hda-->hdb if you could then unplug hda and
>> have the system boot from the "copy" without any other intervention. 
>> Kind of like a poor man's RAID1 except you only get back to where you
>> were at the instant the snapshot was taken.  I've never tried this since
>> RAID cards are so cheap, but I guess I'm wondering out loud if that
>> would work.  Anyone tried it?
>>
>> Cheers,
>>     
> If the system was able to boot from the second drive in any other
> circumstance, maybe. More likely to work with SCSI than IDE, because scsi is
> numbered by their detection, and IDE is numbered by its cable and port
> position. But with IDE, you could unplug the first drive and plug the second
> drive into the same position as the first (primary master ...). It should boot.
> As for raid cards being cheap, software raid works as fast or faster than most
> "cheap" raid cards. I mean the less than $200 US priced cards.
>
>   


-- 



Lorenzo Martínez Rodríguez
Consultor de seguridad informática