Solved

Create new linux software raid without losing data ?

Posted on 2013-01-01
6
722 Views
Last Modified: 2013-02-14
Hi,

I would like to request an assistant.

I have new pair additional drives (With ready Data) and i wish to mirror both of the drive .

May i know whether the following command is safe without losing my data ?

mdadm --create /dev/md4 --metadata=0.90 --level=1 --raid-devices=2 missing /dev/sdd1

For your information i have other running raid device on the server and i would like to add the new /dev/md4 .

Appreciates experts comment whether the above command will works without losing the data inside /dev/sdd1 .

Thank you
0
Comment
Question by:smksa
  • 3
  • 2
6 Comments
 
LVL 77

Expert Comment

by:arnold
ID: 38734820
You can not use the existing device /dev/sdd1 as the basis for a new one.

You can use an unused space/partition to create a new raid volume.


Your best bet is to use an unallocated/unused space to create a new md device. Then copy the data into it. You can the remove one member and replacing it with another.

Do you use lvm overlay of raid?i.e. you create /dev/mdi and then use pvcreate /dev/mdi then use vgcreate, lvcreate?

If you can provide what disks you have that are currently unused and the space breakdown of the data as well as what is the total size of the of the raid volume you want.
0
 
LVL 19

Expert Comment

by:jools
ID: 38734862
Before you do anything make sure you have a backup.
0
 
LVL 2

Author Comment

by:smksa
ID: 38735899
Hi,

Actually i already have the following in the current server :

Hard Drive (2 units) (Raid 1)
================

/dev/sda
/dev/sdb

Both of the drive is array for :

/dev/md0
/dev/md1
/dev/md2
/dev/md3

I also have a backup drive :
=====================


/dev/sdc

It is not mounted as a raid array as its only mounted as /backup folder


I wanted to add 2 more drive . 1 unit with data inside, and the other 1 is empty.

So when i plugged in the drive with data it will be detected as /dev/sdd1 and /dev/sde .

I wanted to add into array the new drive with data.

So my question is that whether the data will be wipe off or not after running the following command :

mdadm --create /dev/md4 --metadata=0.90 --level=1 --raid-devices=2 missing /dev/sdd1

I hope this additional info will helps.

Appreciates your assistant.
0
The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

 
LVL 77

Accepted Solution

by:
arnold earned 500 total points
ID: 38736816
You have two drives, one with data /dev/sdd and one empty.
Use the /dev/sde to create the raid volume. Copy the data onto this RAID volume from /dev/sdd1

i.e.
fdisk /dev/sde
partition /dev/sde with two partitions of equal size or just one partition
mdadm --create /dev/md4 --level=1 --raid-devices=2 missing /dev/sde1

mkfs.ftype /dev/md4 if using raw partitions
if using LVM overlay on raid
http://www.thegeekstuff.com/2010/08/how-to-create-lvm/
pvcreate /dev/md4
vgcreate VolGroupxx /dev/md4
lvcreate
vgcreate -L size -n "name of logical volume" VolGroupxx

mkfs.ftype /dev/VolGroupxx/<name of logical volume"
mkfs.ftype /dev/mapper/VolGroupxx-<name of logical volume>

mkdir -p /mnt/src /mnt/dst
mount /dev/sdd1 /mnt/src
mount /dev/mapper/VolGroupxx-<name of logical volume> /mnt/dst
cd /mnt/src
find .  -print  | cpio -pdvmu /mnt/dst
once the data is copied and verified.
you can repartition /dev/sdd
http://www.howtoforge.com/replacing_hard_disks_in_a_raid1_array
and use mdadm --detail /dev/md4
mdadm --manage /dev/md4 --add /dev/sdd1

If you use raw partition, it might be possible to create the array using existing partition without loosing data as you have listed, but I tend to use the two step process to avoid issues.
Make sure you have a backup of the data and then go ahead and try it. you would not need to create a file system as it already exists.
0
 
LVL 2

Author Comment

by:smksa
ID: 38736913
Hi,

Since i had a backup , i have gone ahead and run the command as follows :

[root@vps1 ~]# mdadm --create /dev/md4 --metadata=0.90 --level=1 --raid-devices=2 missing /dev/sdd1
mdadm: /dev/sdd1 appears to contain an ext2fs file system
    size=976760000K  mtime=Mon Dec 31 00:02:37 2012
Continue creating array? y
mdadm: array /dev/md4 started.
[root@vps1 ~]#


After that i mount the /dev/md4 and all the data is intact.
0
 
LVL 77

Expert Comment

by:arnold
ID: 38736976
great.
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

You ever wonder how to backup Linux system files just like Windows System Restore?  Well you can use Timeshift in Linux to perform those similar action.  This tutorial will show you how to backup your system files and keep regular intervals. Note…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…

820 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