inside the mind of a linux admin

RAID: Rebuilding a Foreign disk by hand

While replacing a bad drive with a drive that used to be part of another RAID array configuration, the RAID refused to automatically rebuild, thinking that I might want to import the configuration from this disk (or that there’s data on there that I might need).

Simply inserting the drive doesn’t make the controller rebuild the array with that disk. Here’s how to manually make the drive get along with the rest of the new array:

(Note: this is a 64 bit server, so the MegaCli client I’m using is called “MegaCli64”, if you are not running x64, you can simply substitute the commands below with the path to your megacli binary.)

server:~# MegaCli64 -PDlist -aALL -a0
Enclosure Device ID: 32
Slot Number: 4
Firmware state: Unconfigured(bad)
Secured: Unsecured
Locked: Unlocked
Foreign State: Foreign

Based on the information obtained above, I now know that the disk drive I just replaced is [32:4] ([enclosureid:slotnumber]) and is currently being reported as ‘Unconfigured(bad)’.

To bring this drive back online run:

server:~# MegaCli64 -PDMakeGood -PhysDrv[32:4] -a0
Adapter: 0: EnclId-32 SlotId-4 state changed to Unconfigured-Good.

The controller will now recognize the disk as being a “foreign” one. This does not mean it was made in Japan (though, it likely was). It means it has detected some RAID configuration/data on it and thus, considers it as a disk being part of an array that may be imported into current controller configuration. Because of this, it will not automatically rebuild until you force it to.

Now you can ask the controller to scan for foreign configurations and remove them:

server:~# MegaCli64 -CfgForeign -Scan -a0
There are 1 foreign configuration(s) on controller 0.

server:~# MegaCli64 -CfgForeign -Clear -a0
Foreign configuration 0 is cleared on controller 0.

The disk should now be available for rebuilding into your new RAID array. To confirm, run this:

server:~# MegaCli64 -PDList -a0
Enclosure Device ID: 32
Slot Number: 4
Firmware state: Unconfigured(good), Spun Up
Foreign State: None

Excellent. We have a good, recognized (yet still unconfigured) drive now. Now we have all we need to add the disk back into the new array, and rebuild:

Get the disk [32:4] back into array 1, as disk 4:

server:~# MegaCli64 -PdReplaceMissing -PhysDrv[32:4] -array1 -row4 -a0
Adapter: 0: Missing PD at Array 1, Row 4 is replaced

And finally start rebuilding it:

server:~# megacli -PDRbld -Start -PhysDrv[32:4] -a0
Started rebuild progress on device(Encl-32 Slot-4)

Now, sit back, relax, grab a smoke and wait for it to rebuild itself into your new RAID array. Not so foreign anymore, huh?


Related Posts

How to revert back to X11 / Xorg from Wayland

Wayland is intended as a “simpler replacement for X”, and is getting quite a bit of hype around the Linux community. So much so, that it’s the default in the latest versions of Fedora, GNOME, KDE and others. While Wayland may be the future, it really is in future. At least for Ubuntu 17.10. The […]

Read More

Touchpad stops working after sleep + resume (Fedora 26 on Dell XPS)

After recently upgrading my Dell XPS 13 w/Touchscreen to Fedora 26, the touchpad suddenly stopped working upon resuming from sleep mode. It was reproduced 100% of the time, and required a complete restart in order to get the touchpad working again. There have been several forum posts and bug reports regarding others experiencing these exact […]

Read More


  • Time Master on Wednesday, July 20, 2011

    Thank you, that was helpful.

  • Sean on Wednesday, October 10, 2012

    Thanks for the excellent description!

  • name withheld on Thursday, July 28, 2016

    -array1 how did you get that?

  • Erik on Friday, July 29, 2016

    it’s the first array

  • Erik on Friday, July 29, 2016

    very welcome, happy it helped!

  • Erik on Friday, July 29, 2016

    sure thing!

  • Rob on Friday, April 20, 2018

    Very helpfull

Leave a Reply

Your email address will not be published. Required fields are marked *

Tweeter button Facebook button Myspace button