LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices

Reply
 
Search this Thread
Old 05-24-2009, 01:54 AM   #1
joseph2020
Member
 
Registered: Mar 2009
Location: USA
Distribution: Ubuntu 12.04
Posts: 235

Rep: Reputation: Disabled
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:
1) type in the console
Code:
sudo ddrescue /dev/sda1 /media/backdrive
2) when finished, turn off the PC, swap the drives/master/slave jumpers.
3) now the drives are exchanged; sda1 is now sdb1, etc.
3) start PC and hope it reboots from the cloned drive, and hope the partitions are read correctly. (do this step about 50 times, until I'm absolutely sure it works)
4) reformat 40 gig with gparted and try to repair
5) continue existence as a Ubuntu user
This just seems too easy! I must be missing something. Nothing is this easy in Linux.

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
 
Old 05-24-2009, 02:08 AM   #2
Nikosis
Member
 
Registered: Dec 2005
Location: In front of the monitor
Distribution: Slackware
Posts: 310

Rep: Reputation: 59
what about rsync
 
Old 05-24-2009, 02:14 AM   #3
SqdnGuns
Member
 
Registered: Aug 2005
Location: Fountain Valley, CA / Thailand
Distribution: Slackware64 14.0
Posts: 981

Rep: Reputation: 88
Quote:
Originally Posted by Nikosis View Post
what about rsync
rsync won't copy the blocks correctly nor the boot sector, If he wants to use this as the new bootable drive, use dd rescue, I use it at least a 1/2 a dozen times a week at work to rescue customers critical data that they FAILED to have a back up of.

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.
 
Old 05-24-2009, 03:01 AM   #4
Nikosis
Member
 
Registered: Dec 2005
Location: In front of the monitor
Distribution: Slackware
Posts: 310

Rep: Reputation: 59
Quote:
As a backup administrator, I would have to say that dd should never be used for backups. It's more of a utility to create disk image files, not intended for long term storage and or disaster recovery.
But in this case I think ddrescue can be a solution.

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.

Last edited by Nikosis; 05-24-2009 at 03:26 AM.
 
Old 05-24-2009, 03:31 AM   #5
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 12,448

Rep: Reputation: 1069Reputation: 1069Reputation: 1069Reputation: 1069Reputation: 1069Reputation: 1069Reputation: 1069Reputation: 1069
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.

Last edited by syg00; 05-24-2009 at 03:34 AM. Reason: typo
 
Old 05-24-2009, 04:46 AM   #6
Nikosis
Member
 
Registered: Dec 2005
Location: In front of the monitor
Distribution: Slackware
Posts: 310

Rep: Reputation: 59
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
Copy MBR to another disk
Code:
dd if=/home/sda.boot.mbr of=/dev/sdb bs=512 count=1
It probably can be done using one command
Code:
dd if=/dev/sda of=/dev/sdb bs=512 count=1
Once again, the choice is yours
You may want to take a look at this also

Last edited by Nikosis; 05-24-2009 at 05:08 AM.
 
Old 05-25-2009, 01:37 AM   #7
joseph2020
Member
 
Registered: Mar 2009
Location: USA
Distribution: Ubuntu 12.04
Posts: 235

Original Poster
Rep: Reputation: Disabled
Nikosis, thanks much for your helpful reply

Quote:
Once again, the choice is yours
You may want to take a look at this also
I appreciate that link, I have bookmarked it and will be reading it as soon as I can. The drive might fail at any time, I need to clone it ASAP.

Quote:
As for MBR you can always make sure that you'll have the MBR by backing it up using dd
Please tell me I don't have to backup the MBR separately....won't rsync take care of that for me?

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:
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:

Code:
rsync -xrlptgoEv --progress --delete / /Volumes/Backup
You call that easy syntax?? I'd hate to see what you consider difficult.

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.

Last edited by joseph2020; 05-25-2009 at 01:40 AM.
 
Old 05-25-2009, 03:32 AM   #8
AwesomeMachine
Senior Member
 
Registered: Jan 2005
Location: USA and Italy
Distribution: Debian jessie/sid; OpenSuSE; Fedora
Posts: 1,593

Rep: Reputation: 162Reputation: 162
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.
 
Old 05-25-2009, 05:14 PM   #9
joseph2020
Member
 
Registered: Mar 2009
Location: USA
Distribution: Ubuntu 12.04
Posts: 235

Original Poster
Rep: Reputation: Disabled
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
 
Old 05-25-2009, 05:37 PM   #10
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 12,448

Rep: Reputation: 1069Reputation: 1069Reputation: 1069Reputation: 1069Reputation: 1069Reputation: 1069Reputation: 1069Reputation: 1069
Are you doing this from the running system ?. If so, do it from a liveCD instead.
 
Old 05-25-2009, 09:24 PM   #11
joseph2020
Member
 
Registered: Mar 2009
Location: USA
Distribution: Ubuntu 12.04
Posts: 235

Original Poster
Rep: Reputation: Disabled
syg00

Quote:
Are you doing this from the running system ?. If so, do it from a liveCD instead.
Please explain...do you mean run rsync from the liveCD? What difference would that make?

Please show me the command to do what you mean, I am willing to try anything at this point.

thank you
 
Old 05-26-2009, 02:32 AM   #12
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 12,448

Rep: Reputation: 1069Reputation: 1069Reputation: 1069Reputation: 1069Reputation: 1069Reputation: 1069Reputation: 1069Reputation: 1069
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).
 
Old 05-26-2009, 02:39 AM   #13
Nikosis
Member
 
Registered: Dec 2005
Location: In front of the monitor
Distribution: Slackware
Posts: 310

Rep: Reputation: 59
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:
Please explain...do you mean run rsync from the liveCD? What difference would that make?
faster transfer, you can try slax or any other livecd

Last edited by Nikosis; 05-26-2009 at 03:09 AM.
 
Old 05-27-2009, 10:34 PM   #14
wabbalee
Member
 
Registered: Oct 2006
Location: brisbane - australia
Distribution: mepis, ubuntu, zenwalk
Posts: 334

Rep: Reputation: 38
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.
 
Old 05-27-2009, 11:03 PM   #15
joseph2020
Member
 
Registered: Mar 2009
Location: USA
Distribution: Ubuntu 12.04
Posts: 235

Original Poster
Rep: Reputation: Disabled
wabbalee

Quote:
Just a suggestion, but why don't you use clonezilla live cd and gparted (live cd)
Thank you for your reply. I have the clonezilla site bookmarked for possible later download (I use a dialup connection, so the download takes about 3.5 hours), and I already have Gparted liveCD.

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
 
  


Reply

Tags
boot, copy, flash, tar, untar, unzip, usb, zip


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
make exact copy of hda1 for new HD nephish Linux - General 5 06-24-2006 05:49 PM
make exact copy of a hard disk in fedora AQG Linux - Hardware 6 08-07-2005 05:11 PM
How do I make an exact copy of a movie DVD u6jaf Linux - Software 1 07-08-2004 01:45 PM
make an exact copy of Fedora from 1 PC to another lothario Linux - Newbie 1 06-04-2004 01:34 PM
How to make an exact copy of a Hard Disk danishmr Linux - General 15 11-10-2003 02:48 AM


All times are GMT -5. The time now is 12:26 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration