LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 07-11-2007, 03:52 PM   #1
gfem
Member
 
Registered: Apr 2003
Distribution: Fedora
Posts: 126

Rep: Reputation: 15
backup a failing disk to a larger disk


I would like to know if there is a simple way to backup a failing disk to a larger disk. The failing disk contains my boot partition and hda3 is formatted with XFS. It is 80gb. I have a spare 120gb that I want to copy it to. I found an example that shows how to do it if all file systems are ext2/3, but I have XFS on /de/hda3.
here is the example:
# Mirror hda on hdb
dd if=/dev/hda of=/dev/hdb
# done, the rest of this section assumes that hdb is larger than hda
# Rescan partition tables on hdb
hdparm -Z /dev/hdb
fdisk /dev/hdb
# You must delete the partition and readd it to take up entire disk
# check file system first, assumes ext2/3
e2fsck /dev/hdb1
# Resize fs to fill partition, again assumes ext2/3
resize2fs /dev/hdb1
# check fs again
e2fsck /dev/hdb1
# Done
Can someone tell me how to do it if I have an XFS partition?
Below is the disk I want to copy. I couldn't find anything about how to use the full disk after using DD to copy it with XFS.

Disk /dev/hda: 81.9 GB, 81964302336 bytes
255 heads, 63 sectors/track, 9964 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/hda1 * 1 13 104391 83 Linux
/dev/hda2 14 1925 15358140 83 Linux
/dev/hda3 1926 9899 64051155 83 Linux "XFS Partition"
/dev/hda4 9900 9964 522112+ 5 Extended
/dev/hda5 9900 9964 522081 82 Linux swap / Solaris


Thanks.
 
Old 07-11-2007, 04:06 PM   #2
Quakeboy02
Senior Member
 
Registered: Nov 2006
Distribution: Debian Squeeze 2.6.32.9 SMP AMD64
Posts: 3,245

Rep: Reputation: 121Reputation: 121
Do a man on "xfs_growfs" to see if that's what you want.

You could also use "cp -axu <from directory>/* <to directory>". This will copy file by file, of course, and will probably take longer. But, you get the option of making the "to" partition any type you want.
 
Old 07-11-2007, 04:24 PM   #3
saikee
Senior Member
 
Registered: Sep 2005
Location: Newcastle upon Tyne UK
Distribution: Any free distro.
Posts: 3,398
Blog Entries: 1

Rep: Reputation: 112Reputation: 112
How about this.

The method uses dd so whatever filing systems, operating systems and the number of partitions doesn't come into the equation if you are only reading the "1" and "0" from a failing disk and write the same information on a bigger disk.

The disk boots exactly like the old one because it is a carbon copy of it.
 
Old 07-13-2007, 10:29 AM   #4
gfem
Member
 
Registered: Apr 2003
Distribution: Fedora
Posts: 126

Original Poster
Rep: Reputation: 15
One last question. can I rum the DD comand on the live system/mounted drive , or do I have to boot into rescue mode to do the copy?
 
Old 07-13-2007, 11:25 AM   #5
saikee
Senior Member
 
Registered: Sep 2005
Location: Newcastle upon Tyne UK
Distribution: Any free distro.
Posts: 3,398
Blog Entries: 1

Rep: Reputation: 112Reputation: 112
First : dd is a Bash command you can run in any Linux including one from a Live CD.

Second : dd operates at hardware level and there is no need to mount the drive/partition. dd copies the "1" and "0" only. The clone is a mirror image of your original.
 
Old 07-13-2007, 02:24 PM   #6
gfem
Member
 
Registered: Apr 2003
Distribution: Fedora
Posts: 126

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by saikee
First : dd is a Bash command you can run in any Linux including one from a Live CD.

Second : dd operates at hardware level and there is no need to mount the drive/partition. dd copies the "1" and "0" only. The clone is a mirror image of your original.
Let me clarify. Since my system is up and running and my objective is to image the disk with the boot partition, root home etc... Can I use dd to image the disk while it is mounted and in use? or will it screw somthing up?

Last edited by gfem; 07-13-2007 at 02:26 PM.
 
Old 07-13-2007, 03:32 PM   #7
saikee
Senior Member
 
Registered: Sep 2005
Location: Newcastle upon Tyne UK
Distribution: Any free distro.
Posts: 3,398
Blog Entries: 1

Rep: Reputation: 112Reputation: 112
You can run you Linux, watch movie, listen to the MP3 etc while "dd" the whole hard disk in the background.

Like I said it works at the hard ware level and will have no effect on your Linux filing system which is the the ram. In any case your hard disk is for reading purpose so all the mounted partitions will not be screwed up (because nothing is written on them).You may not get everything up to date to the last minute though.

Try out "dd" and feel the power of Linux.

Last edited by saikee; 07-13-2007 at 03:33 PM.
 
Old 07-13-2007, 04:29 PM   #8
IsaacKuo
Senior Member
 
Registered: Apr 2004
Location: Baton Rouge, Louisiana, USA
Distribution: Debian 4.0 Etch
Posts: 1,349

Rep: Reputation: 49
Saikee, the more relevant question is whether the Linux OS is writing changes to the hard drive. If so, then the dd image may be corrupted and could be in a spoiled inconsistent state--possibly without any sort of error warning.

The mere act of running "dd" will at a minimum write to the bash history file. This particular example is unlikely to cause any problems, of course, because by the time "dd" starts doing its work those changes will almost certainly be commited to disk. A more troubling worry is whatever daemons Fedora might have up and running by default. Booting up into single user mode should hopefully avoid any problems.

Personally, I'd boot up into single user mode (if a liveCD isn't an option), and copy the files over manually with "cp -vax" commands. If the source disk is failing, then it's possible that a full "dd" command will fail in the middle. With manual cp commands, it's at least possible to try and copy over bits at a time and get as much as possible.
 
Old 07-13-2007, 07:19 PM   #9
saikee
Senior Member
 
Registered: Sep 2005
Location: Newcastle upon Tyne UK
Distribution: Any free distro.
Posts: 3,398
Blog Entries: 1

Rep: Reputation: 112Reputation: 112
I must admit I usually use a Live CD to do the cloning job but I had in the past used a Linux from the hard disk too, because I experiencing the dd speed with 32 bit and 64 bit distros. When I started my first dd cloning I couldn't finish a 200Gb disk after 36 hours! The last 500Gb disk I cloned recently took 2.17 hours.

I believe dd does its stuff at a hardware level and the user will only get himself into trouble by unmounting the partitions, while dd is in the middle of working its guts out, thereby forcing the information to be updated into the hard disk, otherwise dd could be quitely happy just cloning the hard disk before changes are implemented into it.

I actually believe dd is more robust than the file copying commands like cp, tar etc because dd copies at least one sector which is the smallest unit. When a file has a dodgy data the whole file may fail in copying whereas dd is almost running at a smooth and constant speed all the time. There are also parameters one can play to tackle the read error in dd plus in Linux one can slow down the DMA to read a disk at a slower speed to improve reliability.

If the disk develops a hardware corruption then eventually no OS can read it. From my experience dd is the last line of defence in disk salvage work.
 
  


Reply


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 On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
dd cloning to a larger disk partition question ciarlatano Linux - General 1 04-23-2007 03:23 AM
fitting 39 Gb disk image onto 39 Gb backup disk ivlad2002 Linux - Laptop and Netbook 6 03-29-2007 04:45 PM
Is my hard disk failing David_Moses Linux - General 9 06-15-2005 12:29 PM
disk to disk backup for debian/Mempis on bootable cd-- advice loninappleton Linux - Software 3 05-27-2005 01:00 AM
can I backup a root disk and boot from the new backup disk linuxbkp Linux - Enterprise 3 10-15-2004 06:42 PM


All times are GMT -5. The time now is 05:13 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