Results 1 to 10 of 10

Thread: Linux Raid-1, how to remove without losing data

  1. #1
    Join Date
    Nov 2008
    Location
    London, UK
    Posts
    7

    Default Linux Raid-1, how to remove without losing data

    Hi,
    I've realized that I don't need my Linux Raid setup and I was thinking of removing it, hopefully without losing the data.
    I've understood that the Linux Raid partitions can be read only when in a RAID.
    My RAID-1 partition (/dev/md0) is only used for data, so any change would not impact the os or the boot process.

    My plan is (using Partitioner) is:
    - remove the RAID-1
    - create an new RAID-1 with only one of the two disk, say A (is it possible to make a RAID-1 with only 1 disk?)
    - format the other disk B and copy the file from A to B
    - format A and reuse it

    What do you think? Do I need to this or is there a better way? Will I be able to create a RAID-1 with only 1 disk?

    Thanks

    Stefano

  2. #2
    Join Date
    Jun 2008
    Location
    UTC+10
    Posts
    9,941
    Blog Entries
    4

    Default Re: Linux Raid-1, how to remove without losing data

    Just remove one of the two components from the RAID-1 array and reformat it. The array will then become degraded, surviving only on one partition. Then copy from the degraded array to the recovered partition. Naturally back up your data first, if you can.

  3. #3

    Default Re: Linux Raid-1, how to remove without losing data

    It's a multi-step process, to really remove the RAID though.

    mdadm options

    -f, --fail
    -r, --remove

    To get a device out of the md. If you don't do that, you can't rely on it not getting re-added. The RAID devices are made to be darn persistent, as they err on side of automagic recovery.


    After copying data over, then you can stop the array.

    -S, --stop

    If you have used RAID on whole disk, and then partitioned, and use RAID there, it may be wise to zero the super block, to avoid confusion later with the original device, which can get activated by mistake by Live CD or Installer disk later.

    When it's stopped, you should be able to use the device as normal disk one, and reformat, without the RAID configuration coming back to haunt you.

  4. #4
    Join Date
    Nov 2008
    Location
    London, UK
    Posts
    7

    Default Re: Linux Raid-1, how to remove without losing data

    Thanks robopensuse and ken_yap.
    I understand that, given the fact that raid devices tend to be readded to the array, is better to remove the drive through mdadm.
    I'll study how it works.
    However I'm not sure I understand the super block part. Is there a mark on the drive that says it is/was part of a raid array?
    Robopensuse do you have some web reference?

    Thanks

  5. #5
    Join Date
    Jun 2008
    Location
    UTC+10
    Posts
    9,941
    Blog Entries
    4

    Default Re: Linux Raid-1, how to remove without losing data

    mdadm is in fact the only utility you should use deal with the array. You can remove an element in such a way that it will not be automatically added next boot. That's how the array is broken up so that a failed element can be replaced. After that, the sysadmin normally readds and resyncs manually.

    A RAID array partition has its own type and metadata, and is a container for any normal filesystem inside. That's how the system can know which partitions are array elements.

  6. #6
    Join Date
    Nov 2008
    Location
    London, UK
    Posts
    7

    Default Re: Linux Raid-1, how to remove without losing data

    I've removed /dev/sdb1 from /dev/md0 (that now should include only /dev/sdc1).
    However before even trying to reformat /dev/sdb1 I wanted to be sure that nothing happens to /dev/sdc1.
    Is there a way to check that /dev/sdb1 is defentiley out of the array?

    mdamd -E /dev/sdb1 seems to say that the drive is still in the array.

    linux:/home/stefano # mdadm -E /dev/sdb1
    /dev/sdb1:
    Magic : a92b4efc
    Version : 01
    Feature Map : 0x1
    Array UUID : d33c8c13:e2843c9f:1920f072:524a16c1
    Name : 0
    Creation Time : Sat May 3 14:53:38 2008
    Raid Level : raid1
    Raid Devices : 2

    Used Dev Size : 488391728 (232.88 GiB 250.06 GB)
    Array Size : 488391728 (232.88 GiB 250.06 GB)
    Super Offset : 488391984 sectors
    State : clean
    Device UUID : ee975d47:305d7fc3:41d70330:74d8fa20

    Internal Bitmap : -234 sectors from superblock
    Update Time : Sat Jan 17 11:03:55 2009
    Checksum : d4ba1806 - correct
    Events : 58


    Array Slot : 0 (0, 1)
    Array State : Uu

    However,

    linux:/home/stefano # mdadm --monitor --delay=300 /dev/md0
    Jan 17 11:49:41: DegradedArray on /dev/md0 unknown device

    BTW, my /etc/mdadm.conf is a bit ambigous, isn't it ?

    DEVICE partitions
    ARRAY /dev/md0 level=raid1 UUID=d33c8c13:e2843c9f:1920f072:524a16c1

    Why 'partitions' and not the device name? Yast Partitioner did that.


    Thanks

    Stefano

  7. #7
    Join Date
    Nov 2008
    Location
    London, UK
    Posts
    7

    Default Re: Linux Raid-1, how to remove without losing data

    I think this says that sdb1 and sdc1 are still in the array. Anybody could please confirm? Does it meanr that remove failed?

    Thanks!

    linux:/home/stefano # mdadm --query /dev/sdc1
    /dev/sdc1: is not an md array
    /dev/sdc1: device 1 in 2 device unknown raid1 array. Use mdadm --examine for more detail.
    linux:/home/stefano # mdadm --query /dev/sdb1
    /dev/sdb1: is not an md array
    /dev/sdb1: device 0 in 2 device unknown raid1 array. Use mdadm --examine for more detail.

  8. #8
    Join Date
    Jun 2008
    Location
    UTC+10
    Posts
    9,941
    Blog Entries
    4

    Default Re: Linux Raid-1, how to remove without losing data

    To see the status of the array and its components, use --detail on the md device. So, for example:

    Code:
    mdadm --detail /dev/md0
    or

    Code:
    cat /proc/mdstat
    for a more concise output.

  9. #9
    Join Date
    Nov 2008
    Location
    London, UK
    Posts
    7

    Default Re: Linux Raid-1, how to remove without losing data

    Excellent, /dev/sdb1 is out of the array.
    Thanks for your help.

    linux:/home/stefano # mdadm --detail /dev/md0
    /dev/md0:
    Version : 01.00.03
    Creation Time : Sat May 3 14:53:38 2008
    Raid Level : raid1
    Array Size : 244195864 (232.88 GiB 250.06 GB)
    Used Dev Size : 488391728 (465.77 GiB 500.11 GB)
    Raid Devices : 2
    Total Devices : 1
    Preferred Minor : 0
    Persistence : Superblock is persistent

    Intent Bitmap : Internal

    Update Time : Sat Jan 17 12:11:18 2009
    State : active, degraded
    Active Devices : 1
    Working Devices : 1
    Failed Devices : 0
    Spare Devices : 0

    Name : 0
    UUID : d33c8c13:e2843c9f:1920f072:524a16c1
    Events : 1086

    Number Major Minor RaidDevice State
    0 0 0 0 removed
    1 8 33 1 active sync /dev/sdc1

  10. #10

    Default Re: Linux Raid-1, how to remove without losing data

    Quote Originally Posted by ken_yap View Post
    mdadm is in fact the only utility you should use deal with the array.
    Yes, I meant in certain cases it's good to use madm --zero-super-block.

    RAID doesn't just go by the partition types, that you can change with cfdisk/sfdisk and other partitioning tools.

    It really tries to avoid loosing it's device, but that becomes a problem when you break it up, and put data on an old part of it, that may have stale elements left there that get stumbled on at a later date when you least expect it after making other changes; if you don't stop it in the correct way.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •