how do make an exact copy of my Linux drive?
My old faithful 40 gig hard drive (sda1) is starting to make some bad noises and I am afraid it will die soon. I have a 80 gig drive (sdb1) already formated as ext2 with gparted, mounted and accessible on my Ubuntu desktop. I have all permissions for it.
What is an easy way to clone the 40 gig to the 80 gig? I want an exact copy so I can boot from it. Looking around I found a command named "ddrescue"... here's the plan: (/media/backdrive is mount point for sdb1) Quote:
I am concerned if all the devices will exchange positions without too much serious intervention. Will this work? Is there a better way of doing it? Anyone have any good ideas?. (.tar is not an option). Thanks in advance |
what about rsync
|
Quote:
Get a USB stick to save the log file to, then mount it. I use ddrescue /dev/"SRC_DRIVE" /dev/"DEST_DRIVE" /dev/"USB_STICK"/logfile_name.txt -b -1 4096 It's late and I am forgetting all the switches. Search the LQWiki for ddrescue, that shuld point you in the right direction. |
Quote:
rsync can be used to make a bootable clone as well. In addition to basic file copying, rsync also offers the ability to synchronize the source and target volumes -- it can copy only the items that have changed, thus subsequent clones, or backups, are much faster. The syntax is pretty easy: rsync -xrlptgoEv --progress --delete / /Volumes/Backup That will backup your entire drive, deleting anything from the target that is not on the source drive (synchronizing, that is). Rsync also preserves resource forks (that's what the "E" argument is for) and will give you a bootable backup. You might want to learn more about using rsync to regularly backup your drive. |
Any number of tools will do the job - including those mentioned.
Personally I have to agree with Nikosis. I prefer a filesystem aware copy ("cp -a ...", rsync ..., whatever) so that faults in the filesystem itself are exposed immediately. Imaging tools I use for recovery scenarios only. But this is Linux - lots of choices. |
As for MBR you can always make sure that you'll have the MBR by backing it up using dd
Back up the MBR Code:
dd if=/dev/sda of=/home/sda.boot.mbr bs=512 count=1 Code:
dd if=/home/sda.boot.mbr of=/dev/sdb bs=512 count=1 Code:
dd if=/dev/sda of=/dev/sdb bs=512 count=1 You may want to take a look at this also |
Nikosis, thanks much for your helpful reply
Quote:
Quote:
For now it seems rsync is the quickest and easiest solution. I have downloaded and installed a GUI for rsync (grsync) and will be trying that tonight. Quote:
Please explain the code if you can...where in the command is the source and destination drives for example? (source is /dev/sda and dest is /dev/sdb).... I guess the / is the source, but what is /volumes/backup? is that the dest? and what do all those letters (xrlptgoEv) mean? What does --progress --delete mean? I tried to read the man pages, but as usual not completely understood by me. Lastly I want to clone the drive completely, including the extended/swap partition...in other words I want an exact copy of the source drive, including the MBR. one last thought...if I clone a 40 gig to a 80 gig will it just not allocate 40 gigs or will that be part of the new drive useful space. Thank you for putting up with all the questions and my lack of knowledge. I'm really lost on this one, running out of time, and getting a little worried. please help. Thank you. |
If you use dd, the resulting 80 GB drive will only be formatted for 40 GB, and it will be reported as full. So, you need to make a partition on the 80 GB about the same size as the whole 40 GB drive, and dd partitions at a time. You can't use dd to copy a MBR of a smaller drive to a larger drive, because the partition table data will be skewered.
You can use rsync, and copy files, then boot from any linux installation disk, choose 'rescue', or some similar thing from the boot prompt, and install the grub bootloader. Then the disk will boot. |
Well, i tried rsync and it almost worked. It went on for over 12 hours and was still going when I forced it to stop. The cloned drive (sdb) only has the main partition ( no swap) and it is almost exactly twice the size of the original (11.77 GB vs 22.56 GB).
If anyone has any idea what's going on please explain. Otherwise I guess I will just wait until drive failure and rebuild the entire Ubuntu system from the ground up...how frustrating. Thanks for the help |
Are you doing this from the running system ?. If so, do it from a liveCD instead.
|
syg00
Quote:
Please show me the command to do what you mean, I am willing to try anything at this point. thank you |
Yes, do the rsync from a liveCD - the reason is that it avoids having to exclude the pseudo filesystems (like /dev and /proc) that can cause problems.
Just mount the target and source, and use the command above adjusted for mountpoint(s). |
How many partition do you have, how big they are, and what file system do you use.
Since your disks are different sized (80GB and 40GB), you should make new partitions on a new one, by using fdisk or parted, then format it with any file system that you prefer. Then rsync all the files. Everything will be much faster now Quote:
|
Just a suggestion, but why don't you use clonezilla live cd and gparted (live cd). I do this kind of thing (migrating from one drive to another) regularly and successfully using these two tools, and mostly within minutes rather then hours.
|
wabbalee
Quote:
Please tell me step by step how you would use these two utilities to transfer my Ububtu linux system to a different hard drive. It has to be a COMPLETE image, exactly the same as the source. Try to keep it super simple as I am still at beginner level with Linux. Thanks again |
All times are GMT -5. The time now is 12:47 AM. |