# Properly disassemble raid1 (mdadm)

## Kwark

I'm using mdadm for a mirrored (RAID1) setup for several partitions (/, /home etc).

Right now I need to disassemble this array and remount all partitions using their "normal" devices.

Eg. /dev/sdb5 instead of /dev/md1

This particular raid will stay disassembled, no need to keep any traces of it.

Can I just changed the partition types from raid-autodetect (FD) to reiserfs,ext3,.. , edit grub.conf, /etc/fstab and reboot?

I have no physical access to this machine, but have serial access (from bios to console), so that's not really a problem.

(No cdrom though)

----------

## Veldrin

Basically you could just use those partitions directly...

but this would probably cause a rebuild every time the system gets booted, and you would loos all the redundant space. 

I would do the following:

switch to single user mode

split the raid as usual (stop one disk, then 'remove it). take sda, and leave sdb in the array. 

change the partition type to linux native (IIRC 83)

create the new partition/filesystem on the 'lose'disk (sda), mount them, and copy all data over. 

adjust fstab to use the sole (sda) disk

adjust grub to use sda as boot resp. root device.

reinstall grub in sda (just to be sure)

reboot the system.

destroy the remaining raid part by stopping mdadm, and creating new partitions/filesystems on sdb.

cleanup of mdadm.conf

these instructions come by heart - please verify every step, and ask if there are any questions.

V.

----------

## frostschutz

You can stop the RAID and then remove the RAID metadata using mdadm, this way the devices won't be recognized as RAID anymore. However, whether you can use the underlying partitions directly or not, depends on the RAID metadata version you were using. If the metadata was at the end of the device, there is no problem - if it was at the beginning, you may not be able to use the partitions.

----------

## Kwark

I'm going to try it with the /tmp partition (reiserfs fs).

This is /dev/md3 with /dev/sda7 and /dev/sdb7. How about these steps:

1. reboot single mode (serial console, no physical access)

2. mdadm --stop /dev/md3

3. mdadm --zero-superblock /dev/sda7

    mdadm --zero-superblock /dev/sdb7

4. remove from /etc/mdadm.conf

5. restart mdadm

6. fdisk

   - change /dev/sda7, /dev/sdb7 filesystem type to reiserfs

7. edit /etc/fstab

   - /dev/md3 -> /dev/sdb7

8 mount /tmp

----------

## Veldrin

I might have missed the part, where you do not want/need to keep its contents...

I that case mdadm --zero-superblock is an option. But if you are going to to reacreate the partitions either way (assuming that --zero-superblock does destroy them), then I might be superfluous.

you might want to umount /dev/md3 (resp /tmp) first, before you mess around. 

the rest looks fine. 

V.

----------

## Kwark

I do need to keep the contents of the partitions.

I just tried it with my /tmp and I didn't need to change the partition type with fdisk, it reverted to reiserfs when I stopped the md and cleared the superblock.

This is how it should work, right? The data is there alright.

----------

## Veldrin

Looking good. 

yes it should...

V.

----------

## Kwark

Ok, I changed reverted all partitions except for for / (md1) and /boot (md0).

Is it possible to unmount and move the root partition (md1) in single mode?

----------

## Kwark

I'm in the last steps on my migration. Only the new root/boot to go.

Recap:

/dev/md0 = old /boot       (now stopped + removed)

/dev/md1 = old /              (still mounted at the moment)

/dev/md0 = new / + /boot         (not yet mounted as /)

- The HD with the old partitions will be removed after migration and replaced with another HD.

- The new root partition (including /boot) is /dev/md0.

- All root data is copied there and special dirs like /dev, /sys, /proc etc are made.

- grub has been setup manually in the MBR of the new root raid partition (md0):

  root (hd0,0), setup(hd0)

What would be the correct final steps? Am I missing something?

- Reboot

- Change bios to search boot from the new HD first

- In grub console, change the root= to /dev/md0

  (I know I can do this in a new entry)

/boot/grub/device.map in both the new and old situation both list (hd0)=/dev/sda and (hd1)=/dev/sdb

And both grub.conf 's contain the same root(hd0,0) line in their config, while they should be referring to different HD's.

(sdb is the old, sda is the new)

----------

