Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Create new linux software raid without losing data ?

Posted on 2013-01-01
6
Medium Priority
?
753 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 80

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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 80

Accepted Solution

by:
arnold earned 2000 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 80

Expert Comment

by:arnold
ID: 38736976
great.
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

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…
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Suggested Courses
Course of the Month9 days, 11 hours left to enroll

879 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