Click to See Complete Forum and Search --> : Disk Mirror Script


jefferso
12-04-2003, 03:33 PM
I am running a RH9 server and would like to create a script that will mirror the primary disk to a secondary disk.

He is my disk structure as of right now.

Device Boot Start End Blocks Id System
/dev/sda1 1 4 32098+ de Dell Utility
/dev/sda2 * 5 17 104422+ 83 Linux
/dev/sda3 18 271 2040255 82 Linux swap
/dev/sda4 272 4427 33383070 f Win95 Ext'd (LBA)
/dev/sda5 272 4427 33383038+ 83 Linux

Disk /dev/sdb: 36.4 GB, 36420075008 bytes

So I basically just want all of disk#1 to be mirrored on to disk#2. Now I have not made scripts in the past so this is all new to me. If someone can direct me to a web page or info that would put me on the right path it would be greatly appreciated. The web pages I have looked at have yet to be of any help (propbably just how I am wording my searches).

Thanks in advance.

voidinit
12-04-2003, 04:01 PM
Your Salvation! The Linux Documentation Project! (http://www.tldp.org)

Check out the Advanced Bash Scripting Guide, under guides, not How-to's. It's a bit dated, but very, very pertinent reading!

raz0rblade
12-05-2003, 07:22 PM
I won't right the script for you, but I can tell you what to do.

Basically you need to move all the bits on sda1 to sda2.

This can be accomplished with dd (man dd)
For doing it automatically every X hours, you will need to use cron. (man cron)

Look into perl or bash to write the script in.

There is also RAID 1 which automatically would write the mirror on the fly, not every X mins or hours. It would also be much faster and reliable. If it's mission critcal and can't be lost this is defiantly the route to take.

More info on RAID - http://tldp.org/HOWTO/Software-RAID-HOWTO.html


Good Luck ! :D