LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 12-19-2005, 06:50 PM   #1
ctroyp
Member
 
Registered: Sep 2005
Distribution: Fedora Core 4 / CentOS
Posts: 92

Rep: Reputation: 15
Help with creating a HDD mirror...


Hello,
I am sort-of a Linux newbie, and I am trying to find help on setting creating a duplicate of my hard drive.

I have a Dell Dimension 8200 running a webserver via Debian Sarge 3.1. I have an (2) 80GB drives--one of which I would like to mirror the other. I have read a little about using the dd command to do so, but I am really uncomfortable doing this. In short I want to schedule this mirror to run in the evenings (daily). If my primary hdd fails, all I would have to do it physically replace it with the mirrored one.

First off, is this possible? If so, could someone help me to create the script?

Or if dd isn't the best solution could you recommend another. I do not currently have a raid config, but I have also read about rsync and such...

Any help is greatly appreciated.
 
Old 12-19-2005, 07:16 PM   #2
cs-cam
Senior Member
 
Registered: May 2004
Location: Australia
Distribution: Gentoo
Posts: 3,544
Blog Entries: 4

Rep: Reputation: 57
dd is over-rated. Something basic would be to setup a cron job to run in the evenings and just have it do this:
Code:
cat /dev/hda > /dev/hdb
However I think that a RAID setup might be better here, you can run a software RAID so you wouldn't need to buy any hardware or anything. I know what RAID does but I've never actually used it so I can't help you any further with that sorry but somebody else will come along with their opinion shortly I'm pretty sure
 
Old 12-19-2005, 08:06 PM   #3
ctroyp
Member
 
Registered: Sep 2005
Distribution: Fedora Core 4 / CentOS
Posts: 92

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by cs-cam
dd is over-rated. Something basic would be to setup a cron job to run in the evenings and just have it do this:
Code:
cat /dev/hda > /dev/hdb
However I think that a RAID setup might be better here, you can run a software RAID so you wouldn't need to buy any hardware or anything. I know what RAID does but I've never actually used it so I can't help you any further with that sorry but somebody else will come along with their opinion shortly I'm pretty sure
Using either dd or cat, will it copay all files bit for bit even if it is in use? Running a webserver, it is hard to tell if anyone will be logged on...
 
Old 12-19-2005, 09:30 PM   #4
cs-cam
Senior Member
 
Registered: May 2004
Location: Australia
Distribution: Gentoo
Posts: 3,544
Blog Entries: 4

Rep: Reputation: 57
Yeah, cat will do the same job but I reckon you'll get weird results if files are in use with either program. RAID is probably the only sane option.
 
Old 12-21-2005, 07:01 PM   #5
ctroyp
Member
 
Registered: Sep 2005
Distribution: Fedora Core 4 / CentOS
Posts: 92

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by cs-cam
Yeah, cat will do the same job but I reckon you'll get weird results if files are in use with either program. RAID is probably the only sane option.
Problem is with raid though is if a file is deleted or modified and I need to roll back to an previous file, it won't be available??? Is this true? Will I have to run a tape backup, etc?
 
Old 12-21-2005, 09:33 PM   #6
JimBass
Senior Member
 
Registered: Oct 2003
Location: New York City
Distribution: Debian Sid 2.6.32
Posts: 2,100

Rep: Reputation: 49
It seems like you're a little confused. RAID isn't a backup option in the sense of "this changed, let me get the older version". RAID is a hardware level mirror (RAID1 at least) that is there to protect against hardware failure.

What you can/should do is use software RAID to make the 2nd 80 GB drive a mirror (RAID1) of the first. Then partition the 80 gigs you have, and make backup directory or partition. Then you can use cron, cat/dd, or a great piece of software like http://backuppc.sourceforge.net/ to create older version backups on the drive, that way you are doubly protected. The backup software keeps multiple versions of files, and beyond that, the RAID keeps everything cool, so that even if one of your 2 drives fail, all the data will be safe for recovery on the other.

Peace,
JimBass
 
Old 12-21-2005, 10:46 PM   #7
ctroyp
Member
 
Registered: Sep 2005
Distribution: Fedora Core 4 / CentOS
Posts: 92

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by JimBass
It seems like you're a little confused. RAID isn't a backup option in the sense of "this changed, let me get the older version". RAID is a hardware level mirror (RAID1 at least) that is there to protect against hardware failure.

What you can/should do is use software RAID to make the 2nd 80 GB drive a mirror (RAID1) of the first. Then partition the 80 gigs you have, and make backup directory or partition. Then you can use cron, cat/dd, or a great piece of software like http://backuppc.sourceforge.net/ to create older version backups on the drive, that way you are doubly protected. The backup software keeps multiple versions of files, and beyond that, the RAID keeps everything cool, so that even if one of your 2 drives fail, all the data will be safe for recovery on the other.

Peace,
JimBass
So basically, both hdd's are running as RAID1 and I will create an additional partition for running BackupPC. Now I have my redundancy through RAID and a backup solution through BackupPC (on the additional partition on hdb)? If I am understanding this right then I think this will be perfect. Two questions come to mind though...
1)If hda is 80GB, how can I back up to such a small partition on hdb and doesn't RAID1 require that the drives are equal in size?
2)Can you recommend any RAID software? Opensource?

Thanks for the help!
 
Old 12-21-2005, 11:28 PM   #8
JimBass
Senior Member
 
Registered: Oct 2003
Location: New York City
Distribution: Debian Sid 2.6.32
Posts: 2,100

Rep: Reputation: 49
Close, but not quite. The backup partition/directory is part of the RAID1 array. The 2nd 80Gb drive is a perfect clone of the first, in every way. So each of the 80 GB drives will have the backup partition or directory.

With RAID1, your computer won't show up with 160 GB, and a copy of everything. It will show as 80 GB, and that is all. The copy is untouchable, but again, if either hard drive fails/overheats/corrupts/melts/explodes, all your data is safe on the copy of it.

You don't need to make the backup area a partition, that is just an option. You can make the directory /backup on the root of your system, and that is cool too. Making it a partition is fine, it is all a question of what you want to do and how you want to do it.

Both Debian and FC have the option to create software RAID when you partition the disks. It sounds like you already have this box built, so if you don't want to rebuild, you'll need to look into how to create a RAID1 array over an existing install. I'm sure it can be done, but I haven't done it. Search here and at http://www.google.com/linux and you'll find ways to do it.

As an example only, lets say you use Debian and you get to the partitioning of the disks. First, completely erase all the data on both disks, so you have 2 blank 80 GB disks. The you create a single 80 GB partition on each disk, and make the type "RAID space", or some name along those lines. Then you go in to configure the RAID array, make it a RAID1 array and you partition up the 80 GB space as you want. Say 40 Gb for /home, 10 Gb /var 10 GB /usr 10 Gb /backup 9.5 GB / and 500 MB swap. Now each of those partitions is mirrored by the RAID, and you're set come hell or high water.

Peace,
JimBass

Last edited by JimBass; 12-21-2005 at 11:30 PM.
 
Old 12-22-2005, 03:14 AM   #9
Emmanuel_uk
Senior Member
 
Registered: Nov 2004
Distribution: Mandriva mostly, vector 5.1, tried many.Suse gone from HD because bad Novell/Zinblows agreement
Posts: 1,605

Rep: Reputation: 53
One of the main reference for software raid is
www.tldp.org/HOWTO/Software-RAID-HOWTO.html

I like this tutorial (you should not need the kernel compilation)
http://www.epimetrics.com/topics/one...e_topic_id=120

I prefer mdadm to mdtools

It is not because you have a raid1 that you should stop doing
some backups on cds/ dvd as well, from time to time
 
Old 12-22-2005, 08:52 AM   #10
ctroyp
Member
 
Registered: Sep 2005
Distribution: Fedora Core 4 / CentOS
Posts: 92

Original Poster
Rep: Reputation: 15
Thanks so much guys for the advice. I think this is the solution I am after. However, being the newbie that I am, I would like to copy all of the contents of my existing drive (<20GB) to another. This way I can take the server down and setup the raid1 config. And should a problem occur, I will have a copy of the server data.

My question is, if I temporarily attach a 20GB drive to the system, how would I partition it just so I can just copy over the files using cat or dd? Again, this is just so I can have a copy of the relevant files currently on the main drive while I configure the raid1 on the two 80GB drives.

Let me know if I need to clarify further...

Thanks again for the help!
 
Old 12-22-2005, 09:07 AM   #11
Emmanuel_uk
Senior Member
 
Registered: Nov 2004
Distribution: Mandriva mostly, vector 5.1, tried many.Suse gone from HD because bad Novell/Zinblows agreement
Posts: 1,605

Rep: Reputation: 53
do not use dd to copy a bigger partition to a smaller.
In my experience it is uggly.

Maybe look into rsync as well (for the copy of the file)

Anyway, for your backups on the 20 GB you only need one
big partition if you want to. You will just dump the files
in various directories you will create. I am not sure there
is added value in having many partitions on that 20 GB HD.
Maybe somebody else will have comments about that
 
Old 12-22-2005, 09:45 AM   #12
ctroyp
Member
 
Registered: Sep 2005
Distribution: Fedora Core 4 / CentOS
Posts: 92

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by Emmanuel_uk
do not use dd to copy a bigger partition to a smaller.
In my experience it is uggly.

Maybe look into rsync as well (for the copy of the file)

Anyway, for your backups on the 20 GB you only need one
big partition if you want to. You will just dump the files
in various directories you will create. I am not sure there
is added value in having many partitions on that 20 GB HD.
Maybe somebody else will have comments about that
Could I just cat or rsync the '/' directory? Would that make a copy of all the files? There are just so many files in so many different directories that I wouldn't know which ones to grab...
 
Old 02-02-2006, 10:35 AM   #13
rimkus
LQ Newbie
 
Registered: Jan 2006
Posts: 9

Rep: Reputation: 0
If both disks are the same you can:
CODE:
dd if=/dev/sda of=/dev/sdb

When you boot up off the target it will do a filesystem check because it is like turning your system off without shutting it down.

This has worked for me with gentoo, redhat, and slakware.

I would do the dd at night as it takes a while to copy a whole disk.
But it seems to get everything including the partition table and the boot sector.
 
Old 02-02-2006, 10:57 AM   #14
Emerson
LQ Guru
 
Registered: Nov 2004
Location: Saint Amant, Acadiana
Distribution: Gentoo ~arch
Posts: 5,872

Rep: Reputation: Disabled
For just one-time backup I would use tar.
 
Old 02-02-2006, 03:13 PM   #15
TigerOC
Senior Member
 
Registered: Jan 2003
Location: Devon, UK
Distribution: Debian Etc/kernel 2.6.18-4K7
Posts: 2,380

Rep: Reputation: 49
I am a great fan of rsync for a number of reasons in this kind of application. The initial run could be quite long but thereafter rsync can be used to update only those files that have changed and delete files that no longer exist. It is also very easy to set up a script to run as a cron job.
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Need help on mirror HDD max321 Linux - Newbie 13 07-31-2006 06:04 AM
how to make mirror image of one hdd to 2 hdd raj_1 General 1 12-02-2004 07:19 PM
Creating root mirror vanibhat Linux - Hardware 2 11-29-2004 10:34 AM
How to make mirror image of linux partion to one1 HDD TO 2 HDD raj_1 Linux - General 2 11-04-2004 02:45 AM
Creating Local Update Mirror wyohman Mandriva 9 12-28-2003 09:03 AM


All times are GMT -5. The time now is 02:23 AM.

Main Menu
Advertisement
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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration