<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
Bowie Bailey wrote:
<blockquote cite="mid:4C10EB40.1040201@BUC.com" type="cite">
<pre wrap="">Robert Heller wrote:
</pre>
<blockquote type="cite">
<pre wrap="">At Wed, 9 Jun 2010 16:50:53 -0700 CentOS mailing list <a class="moz-txt-link-rfc2396E" href="mailto:centos@centos.org"><centos@centos.org></a> wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Hi,
I've used mdadm for years now to manage software raids.
The task of using fdisk to first create partitions on a spare drive
sitting on a shelf (raid 0 were my 1st of 2 drives failed) is kind of
bugging me now.
After using fdisk to create the same partition layout on the new drive
as is on the existing drive and then using mdadm to finish every thing
up is a little tedious.
Any one have an idea how to have a sort of hot plug were I just swap
out the drive and it rebuilds?
</pre>
</blockquote>
<pre wrap="">sfdisk is your friend (from man sfdisk):
-d Dump the partitions of a device in a format useful as input to
sfdisk. For example,
% sfdisk -d /dev/hda > hda.out
% sfdisk /dev/hda < hda.out
will correct the bad last extended partition that the OS/2 fdisk
creates.
So:
1) plug in replacement disk.
2) partition it:
# sfdisk -d /dev/sdX | sfdisk /dev/sdY
Where /dev/sdX is an existing disk and /dev/sdY is the replacement disk
3) add the partition(s) to the array(s):
# mdadm /dev/mdI ... -a /dev/sdYI
# mdadm /dev/mdJ ... -a /dev/sdYJ
# mdadm /dev/mdK ... -a /dev/sdYK
# mdadm /dev/mdL ... -a /dev/sdYL
No reason not to put all of the above in a script...
</pre>
</blockquote>
<pre wrap=""><!---->
Agreed. And I have... :)
The script is designed to add a third drive to a raid1 set. I use this
with a removable drive to get a backup of the system that can be taken
off-site.
The sleeps in this script are probably a bit excessive, but they are
designed to let the system fully process each command before the next
one is given. I found that certain things would not work properly
without a pause in there. Since I only run this once a month, it's not
a big deal if it takes a couple of minutes to run.
Just posting this in case it proves useful to anyone.
</pre>
</blockquote>
Thanks - great idea - I'll play with it<br>
<blockquote cite="mid:4C10EB40.1040201@BUC.com" type="cite">
<pre wrap=""></pre>
<pre wrap="">
<hr size="4" width="90%">
_______________________________________________
CentOS mailing list
<a class="moz-txt-link-abbreviated" href="mailto:CentOS@centos.org">CentOS@centos.org</a>
<a class="moz-txt-link-freetext" href="http://lists.centos.org/mailman/listinfo/centos">http://lists.centos.org/mailman/listinfo/centos</a>
</pre>
</blockquote>
</body>
</html>