Results 1 to 6 of 6

Thread: CentOS Linux: Convert RAID0 to RAID1

  1. #1
    Junior Member
    Join Date
    Nov 2009
    Location
    Perth, Western Australia
    Posts
    4
    Thanks
    0
    Thanked 1 Time in 1 Post
    Rep Power
    0

    Default CentOS Linux: Convert RAID0 to RAID1

    Hi,

    I inadvertently, during a Centos6.4 installation, left the default RAID type to 0, for the partition storing /.
    I would really prefer it as RAID1. Other than re-installing everything, is there a way to convert without data loss?

    Thanks in advance.

  2. #2
    Never say die nixcraft's Avatar
    Join Date
    Jan 2005
    Location
    BIOS
    Posts
    4,514
    Thanks
    17
    Thanked 808 Times in 511 Posts
    Rep Power
    10

    Default

    No, not possible. Backup all data and reinstall OS.
    All [Solved] threads are closed by mods / admin to avoid spam issues. See Howto mark a thread as [Solved]


  3. #3
    Junior Member
    Join Date
    Nov 2009
    Location
    Perth, Western Australia
    Posts
    4
    Thanks
    0
    Thanked 1 Time in 1 Post
    Rep Power
    0

    Default

    I considered doing that, but I actually managed to get it done.

    If you want, I can post the method that I used.

    Bill.

  4. #4
    Junior Member
    Join Date
    Jan 2014
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Default

    Quote Originally Posted by BillWest View Post
    I considered doing that, but I actually managed to get it done.

    If you want, I can post the method that I used.

    Bill.
    Please post the method.

  5. #5
    Junior Member
    Join Date
    Nov 2009
    Location
    Perth, Western Australia
    Posts
    4
    Thanks
    0
    Thanked 1 Time in 1 Post
    Rep Power
    0

    Default

    Ok, here it is.

    Method.

    No guarantees given. It worked for me, several times.
    I did a couple of practice runs on a spare machine, I suggest you do the same.

    My RAID0 was on /dev/md2, using physical partitions /dev/sda3 and /dev/sdb3.
    I used this for my "/" partition. I forgot to set it to RAID1 at install time.

    I also had /boot, /home and /storage, all on separate RAID1 partitions.

    I used /storage to backup my "/" partition

    /storage was stored on /dev/md4, using physical partitions /dev/sda6 and /dev/sdb6.


    I used 2 CDs/DVDs: LiveCD from Knoppix, and Centos6.5 Install DVD.

    1. Boot with the Knoppic LiveCD, and get in to graphical mode.

    Enable and mount the RAID0 array:

    Code:
    # mdadm --assemble /dev/md2 /dev/sd[ab]3
         # mkdir /mnt/tmp1
         # mount /dev/md2 /mnt/tmp1
    2. Enable and mount the RAID1 array:

    Code:
    # mdadm --assemble /dev/md4 /dev/sd[ab]6
         # mkdir /mnt/tmp2
         # mount /dev/md4 /mnt/tmp2
    3. Backup the "/" folders on /dev/md2:

    Code:
    # cd /mnt/tmp1
         # cp -pR * /mnt/tmp2
    Note that if any items start with a ".", such as ".dbus", do eg:

    Code:
     # cp -apR .dbus /mnt/tmp2
    4. Unmount and disable /dev/md2

    Code:
    # cd /mnt
    # umount tmp1
    # mdadm --stop /dev/md2
    5. Create a new RAID1 array:

    Code:
     # mdadm -Cv /dev/md2 -l1 -n2 /dev/sd[ab]3
    (ie create verbose, level 1, 2 devices)

    6. Wait for the process to complete, and watch it:

    Code:
     # watch -n 5 cat /proc/mdstat
    7. When it is done, create a file system, eg:

    Code:
     # mkfs.ext4 /dev/md2
    8. Next, mount the new file system:

    Code:
     # mount /dev/md2 /mnt/tmp1
    9. Copy the files/folders back:

    Code:
     # cp -apR /mnt/tmp2/* /mnt/tmp1
    and don't forget items starting with "."

    10. Update your system's mdadm.conf file (usually stored in /etc)

    Code:
     # mdadm --detail --scan | grep md2 >> /mnt/tmp1/etc/mdadm.conf
    Edit that file, to comment out the older entry for /dev/md2

    11. /boot/grub/grub.conf, and /etc/fstab will require editing, to remove referenceces to the now defunct UUID entries.
    I replaced the relevant UUID entries with physical entries such as /dev/md2.

    12. Exit from Knoppix, and reboot with the Centos6 DVD. Choose RESCUE mode.
    Once at a text screen, type:

    Code:
     # chroot /mnt/sysimage
    13. Create a backup of the current /boot/initramfs (replace version_number as required):

    Code:
     # cp -p /boot/initramfs-version_number.img /boot/initramfs-version_number.img.bak
    14. Create a new initramfs:

    Code:
     # dracut -f -H /boot/initramfs-2.6.32-359.el6.x86_64.img 2.6.32-358.el6.x86_64
    (obviously use the correct numbers for your system).

    15. sync, and exit the Centos Rescue mode. Reboot.

    All going well, it should reboot as hoped for.

    As stated earlier, this worked for me. No guarantees given nor implied.

    Enjoy!
    Last edited by nixcraft; 21st January 2014 at 03:40 PM.

  6. #6
    Junior Member
    Join Date
    Jan 2014
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Rep Power
    0

    Default

    Thanks Bill.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [Solved] Linux / Unix: Convert ip into domain name
    By spik2kush in forum Networking, Firewalls and Security
    Replies: 2
    Last Post: 9th July 2011, 10:53 AM
  2. Linux convert doc to pdf file
    By myfoot in forum CentOS / RHEL / Fedora
    Replies: 2
    Last Post: 25th April 2011, 05:17 PM
  3. How to configure Raid1?
    By Rahul.Kolan in forum Linux software
    Replies: 1
    Last Post: 25th November 2009, 04:51 PM
  4. about raid1 on CentOS 5.1
    By linuxss in forum CentOS / RHEL / Fedora
    Replies: 4
    Last Post: 27th August 2008, 12:08 PM
  5. software RAID1
    By sumit in forum Linux hardware
    Replies: 1
    Last Post: 17th July 2007, 01:24 AM

Tags for this Thread

Posting Permissions

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