How to Clean RAID Signatures on Linux
By Eric Ma | In Hardware, Linux, Tutorial | Updated on Aug 16, 2015
RAID systems such as MegaRAID add signatures to disks to maintain the infomration on these didks. When we simply remove these disks and install them to another server, Linux on the new server may detect these RAID signature infomration and refuses to continue write to the disk. Here is one example that mkfs
reports “apparently in use by the system” and refuses making a filesystem. It is reasonable to do so for the sake of data safety in case someone accidentally moved a disk with useful data.
Shutterstock Free Trial – 10 Free Images. Join Now!ads via Carbon
However, we will need to clean these signatures when we are sure that these disks are not used anymore and we are safe to clean it. The reality is that cleaning the metadata is not that staightforward. In this post, I will discuss common problems and how to fix them to clean the RAID metadata information. The instructions are based on Fedora systems. For other systems, you most likely only need to change the method installing the packages.
Note that the instructions here are dangerous and possibly erase all your data on a disk. Follow these instructions only if you know what you are doing.
Table of Contents
- counters(item,.) . Needed tools ∞
- counters(item,.) . Show RAID devices ∞
- counters(item,.) . Remove RAID device ∞
Needed tools ∞
The tools used here are dmraid
, dmsetup
and dd
. Install needed packages.
# yum install mdadm dmraid
Show RAID devices ∞
Show the RAID devices by
# dmraid -r
It will show the results like
/dev/sdb: ddf1, ".ddf1_disks", GROUP, ok, 3904294912 sectors, data@ 0
You may find the device at:
# ls /dev/mapper/ddf*
Remove RAID device ∞
Here, there are many methods. I show the most easier one to the most hard one. The example here shows that all except the last dd
method failed.
Use dmsetup ∞
Trying directly by dmsetup
may fail like:
# dmsetup remove /dev/mapper/ddfs1_...
The result:
device-mapper: remove ioctl on ddf1_49424d202020202010000073101403b141c2c9e96c8236dbp1 failed: Device or resource busy Command failed
We may try the dmraid
tool. Assume the disk is /dev/sdb
:
DEVICE=/dev/sdb
Remove RAID status by dmraid
:
# dmraid -r -E $DEVICE
In this example, it still failed showing errors as follows.
Do you really want to erase "ddf1" ondisk metadata on /dev/sdb ? [y/n] :y ERROR: ddf1: seeking device "/dev/sdb" to 1024204253954048ERROR: writing metadata to /dev/sdb, offset 2000398933504 sectors, size 0 bytes returned 0ERROR: erasing ondisk metadata on /dev/sdb
If all failed, you may try the powerful dd:
# dd if=/dev/zero of=$DEVICE bs=512 seek=$(( $(blockdev --getsz $DEVICE) - 1024 )) count=1024
1024+0 records in1024+0 records out524288 bytes (524 kB) copied, 0.00216637 s, 242 MB/s
Check the RAID devices again by
dmraid -r
Now it shows:
no raid disks
Now the RAID signature on the disk is successfully cleaned. You can do normal operations on the disk as a new disk now.
References:
http://www.server-world.info/en/note?os=CentOS_6&p==raid_metadata
https://kezhong.wordpress.com/2011/06/14/how-to-remove-bios–raid-metadata-from-disk-on-fedora/
http://serverfault.com/questions/488346/removing–raid-metadata-from-drives
http://djlab.com/2013/07/removing–raid-metadata/