Mdadm (software RAID in Linux)

Status
Not open for further replies.

Per Hansson

Posts: 1,978   +234
Staff member
Hi guys!

Trying to get a software RAID-1 array to work the way I want it to...

I'm using the program mdadm to create my array

I use this program because it's under development and supports a feature to send a mail when something goes wrong in the array...

I used this command to create the array:

Code:
# mdadm --create --verbose /dev/md0 --level=1 --raid-devices=2 /dev/sda /dev/sdb

That works just fine, the array is created and the mirror made (takes a while of course)

When it's done the array is started...

But if I shut down my server and then start it again the array will not automatically start...

So I need to manually give it this command:

Code:
# mdadm -A /dev/md0 /dev/sda /dev/sdb

However I would want this to happen automatically... (I assume the array should also be stopped when the server is shutdown/restarted?)

I could of course just add it to the same file I use to start apache and everything else but I'm not sure that is the right thing to do...

I.e. what runlevel would be the right one to initiate it on?

Keep in mind that I'm a total newbie to Linux, this is being done on a Red Hat 9 test server but when successfull will also be implemented on the Techspot server running RH7.3...

I guess what I'm really looking for is a guide on this(a book perhaps?) i.e. you should do it like this and that because of that and that...
 
I would add the line "mdadm -A /dev/md0 /dev/sda /dev/sdb" to a file called raidinit. Place the file in the /bin directory & mark it as "exectutable".

Then it's only a matter of doing a symbolic link of the file to the different directories in /etc/rc.d/ that correspond to runlevel 1 to 5.

To do so, type the command "ln -s /bin/raidinit /etc/rc.d/rc1.d/raidinit" to add the raidinit to the startup of the Runlevel 1.

I believe you also mentionned a command to properly shutdown the RAID array ( "mdadm -A /dev/md0 /dev/sda /dev/sdb" ).

Create a file called raidshutdown & copy it to the bin directory & then do a symbolic link to the /etc/rc.d/rc0.d/ & /etc/rc.d/rc6.d/ ( 0 = Shutdown, 6 = Reboot ).
 
Ok, I think I'm understanding what you are saying...

Will try it out tonight and report back

I'm still intrested in a good book or site explaining all this for me though... Since I'm a newbie to Linux.... (but not RAID in general) so the book should be about Linux implementation of RAID...
 
Hmm, did some changes to the machine and rebooted it but now it wont come back online again...

Will have to investigate what went wrong tomorrow (the test server is at another location from me...)

Though I suspect I restarted to quickly before recreating the array (was testing something) so it was prolly not done and thus all dat was lost, it's fortunate this is a test server ;-)
 
Yes, I sure was correct...

I had rebooted before the new array had been created and thus the boot failed....

(How far the array creation process has come can be verified in the /proc/mdstat file...)

Had to manually boot from the other harddrive and now everything is fine again...

But this brings me back to the point of when to init the array...

Because as I saw now a failed harddrive made the system unable to boot....

So perhaps I should not have the boot loader on the harddrive at all, or atleast have a floppy ready which the system can be manually booted from...

However it feels like someone smarter than me should already have figured out a good solution to this...

So I'll rephrase my question: how can I make my boot process "smart" so if booting from one drive fails the system tries the other one? Completely automatically of course
 
Status
Not open for further replies.
Back