Remove MD RAID

Posted on 2010-01-05
Last Modified: 2013-12-16
I have a server running CentOS 5 with 3 physical disks. The history of the server is a little weird, but the thing I need to do is get rid of a RAID-1 set on /dev/md0 and leave a good working single partition.

What would my process be? I was thinking of removing the second disk from /dev/md0, and then working on the first disk with a Rescue CD... mainly changing the partition type to 83, modifying fstab, grub.conf, and reinstalling grub.

Will this work and leave me with a properly mountable drive? Is there something else that should be done in the process?

Question by:InterWorks
    LVL 7

    Accepted Solution

    Yeah, that's exactly how to do it. Full steps:

    Stop the array:
    mdadm --stop /dev/md0

    remove the array

    mdadm --remove /dev/md0

    remove the superblock from the disks:

    mdadm --zero-superblock /dev/sda /dev/sdb

    modify all the references to md0 in the various config files, fstab, etc.
    Reinstall grub.

    Just to be on the safe side, I'd backup the partition, you never know! ;)

    LVL 76

    Expert Comment

    Before going the above suggested route could you describe the setup?
    I.e. you have a pair of drives that make up md0 as a RAID 1.
    You have one remaining Drive.
    Better yet, post the fstab before proceeding to trying anything suggested below!

    an option could be to break the md0 RAID while leaving it running (i.e. remove one of the drives.)
    i.e. if /dev/sda and /dev//sdb make up the md0 device, separating the /dev/sdb from the setup might be an option while letting the system continue to operate. (double check syntax)
    mdadm manage /dev/md0 --fail /dev/sdb
    mdamd manage /dev/md0 --remove /dev/sdb

    now you can repartition /dev/sdb as you need
    make new file systems on the /dev/sdb parition created above.
    mount each partition one at a time on /mnt
    then run on the /dev/md0 partition:
    find . -print | cpio -pdvmu /mnt
    one you have the data from /dev/md0 copied to /dev/sdb*
    you can modify the fstab to point the appropriate partition to the new location.

    If something does not work, you'll still be able to enter the OS in singleuser mode and alter the fstab to the prior state.
    LVL 1

    Author Comment

    I'll give that a whirl in our upcoming maintenance window (1/16), thanks for the speedy response, and I'll close the question based on the outcome.

    One final question before then, after running "mdadm --remove /dev/md0", there will still be the ability to reconstruct that original set from one of my two disks? I was thinking of leaving one of the mirrors untouched, while working on the first one.
    LVL 7

    Expert Comment

    If you remove /dev/md0, you can rebuild the setup starting from the untouched disk. With the disk zeroed (i.e. without even the raid superblock) you shouldn't have any problem to boot from it. After that, you just create a new raid 1 array, with a missing disk (the disk you're going to use to rebuild the array) and an empty disk:

    mdadm --create /dev/md0 --level=1 --raid-disks=2 missing /dev/sdb1

    then copy the contents from the existing disk to the raid, reinstall grub, etc. etc. After all is set, you can readd the disk to the array to have the fully functional mirror.
    Most of the steps are outlined here:

    LVL 1

    Author Closing Comment

    Once the array is stopped, you cant remove it. Removing is for failed disks, not the entire raid set.

    On top of this, I changed the partition types away from FD back to 83 to avoid  boot time errors trying to reconstruct the array.

    Thanks for the help!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    rdate is a Linux command and the network time protocol for immediate date and time setup from another machine. The clocks are synchronized by entering rdate with the -s switch (command without switch just checks the time but does not set anything). …
    SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
    Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
    Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now