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.
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
The tools used here are
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.
Trying directly by
dmsetup may fail like:
# dmsetup remove /dev/mapper/ddfs1_...
device-mapper: remove ioctl on ddf1_49424d202020202010000073101403b141c2c9e96c8236dbp1 failed: Device or resource busy
We may try the
dmraid tool. Assume the disk is
Remove RAID status by
# 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 1024204253954048
ERROR: writing metadata to /dev/sdb, offset 2000398933504 sectors, size 0 bytes returned 0
ERROR: 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 in
1024+0 records out
524288 bytes (524 kB) copied, 0.00216637 s, 242 MB/s
Check the RAID devices again by
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.