Create an existing hard disk (partition) lossless as RAID1

Source: Internet
Author: User

Background

If you now have a hard disk (partition) in use, if you want to set it to RAID1, you do not need to copy the data out and then create the RAID1.
This hard disk can be set to downgrade RAID1, then add a new hard disk and then activate RAID1, the entire process data lossless.

Reference:
Https://debian-administration.org/article/238/Migrating_To_RAID1_Mirror_on_Sarge

Body

migrating to RAID1 Mirror on Sarge
Posted by Philcore in Thu 8 Sep 2005 at 21:03

Tags:filesystems, RAID, RAID1, Sarge
A guide to migrating to RAID1 on a working Debian Sarge installation which is installed on a single drive.

I suggest reading the following links:migrating to a mirrored raid using grub, grub and RAID mini-howto.

My Setup:

/DEV/SDA = = Original drive with data
/dev/sdb = = new 2nd drive.
(It is assumed so you have RAID1-enabled in your kernel.)

First of all install MD tools:

Apt-get Install Mdadm
The change of the system types on partitions your want to mirror on the old drive to FD (RAID AutoDetect) using [S]fdisk. Don ' t change the swap partition! Your finished drive should resemble this output:

[Email protected] root]# sfdisk-l/DEV/SDA

disk/dev/sda:8942 cylinders, 255 heads, Sectors/track
Units = Cylinders of 8225280 bytes, blocks of 1024x768 bytes, counting from 0

Device Boot Start End #cyls #blocks Id System
/DEV/SDA1 * 0+ 242 243-1951866 FD Linux raid AutoDetect
/DEV/SDA2 243 485 243 1951897+ FD Linux RAID AutoDetect
/DEV/SDA3 486 607 122 979965, Linux Swap/solaris
/DEV/SDA4 608 8923 8316 66798270 5 Extended
/dev/sda5 608+ 1823 1216-9767488+ fd Linux raid AutoDetect
/dev/sda6 1824+ 4255 2432-19535008+ fd Linux raid AutoDetect
/dev/sda7 4256+ 4377 122-979933+ fd Linux raid AutoDetect
/dev/sda8 4378+ 8923 4546-36515713+ fd Linux raid AutoDetect
Now use the Sfdisk to duplicate partitions from the old drive to the new drive:

sfdisk-d/DEV/SDA | Sfdisk/dev/sdb
Now use Mdadm to create the raid arrays. We mark the first drive (SDA) as "missing" so it doesn ' t wipe out of our existing data:

Mdadm--create/dev/md0--level 1--raid-devices=2 missing/dev/sdb1
Repeat for the remaining RAID volumes md1,md2, etc ....

Mdadm--create/dev/md1--level 1--raid-devices=2 missing/dev/sdb2
Now, the volumes is ready to create filesystems for the raid devices. My example shows using Ext3, but pick the filesystem of your choice. Again, make sure the kernel support for your selected filesystem.

Mkfs.ext3/dev/md0
Mkfs.ext3/dev/md1
etc...
Now mount the new RAID volumes. I mount them under The/mnt directory:

Mount/dev/md0/mnt
CP-DPRX//mnt

Create an existing hard disk (partition) lossless as RAID1

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.