We help IT Professionals succeed at work.

Ubuntu - create raid from existing install and adding a new drive.

bmsjeff
bmsjeff asked
on
1,010 Views
Last Modified: 2012-05-11
I know nothing of Linux, but do know windows.
I have an exising Ubuntu installation on a desktop and want to test creating RAID1.
I install a second HDD in the box.  How do I go about installing RAID from scratch?

I would like to Format drive 2, Create a RAID1 partition, and Mirror the data from drive1.
Details please.
Comment
Watch Question

Author

Commented:
I have looked at:
http://ascend4.org/Installing_Raid_1_on_Existing_Ubuntu_Server
but don't want to format the first drive.  Is that possible?
CERTIFIED EXPERT

Commented:
No formatting.

First step is planning.  What kind of Raid do you want?  What do you really want?  Redundancy (mirroring) or Huge volumes (Stripping) or a mixture of both.

Here is something for you to read on
http://www.linuxhomenetworking.com/wiki/index.php/Quick_HOWTO_:_Ch26_:_Linux_Software_RAID

You will make RAID volumes.  Based on that you will be making partitions, and on those partitions you would do the formatting (put appropriate file systems).

https://help.ubuntu.com/community/Installation/SoftwareRAID
CERTIFIED EXPERT

Commented:
When you would start building raid, the data will be erased.  So if you have an existing data, please make sure to back it up.

Author

Commented:
I put RAID1.
So the drives have to be created before data is placed on them.

What should I do to backup the existing drive so that I can place it back on the newly created RAID1 partition.
Top Expert 2011

Commented:
For safety, you might want to buy another hrad disk do disk clone with your original drive first.
The boot up from the clone drive to verify cloning ok.
Then add another disk to do the software raid.
If everything run smoothly, then you can re-use the original drive.
You don't need to worry about if something went wrong and you still can put back the original disk.

For disk clone, you can use Ghost or clonezilla
http://clonezilla.org/
CERTIFIED EXPERT

Commented:
You have to make sure that the permissions and ownerships of all files and folders stay intact.  You can either create tar archives or you may simply do rsync.

Where would you store?  Do you have any storage device like NAS or any thing that would carry your data?

With tar you could use options like

tar Ppcvfz archive.tgz /path
You can create tar in some attached storage.

If you can transfer files by rsync, you need simply

rsync -avuz /path dest
Destination may be mounted or remote over ssh.

Other option could be to simply use a new drive, create the RAID on it and then transfer image from old to new.

Author

Commented:
so can I place raid on an existing disk or must I start with a formatted disk?
CERTIFIED EXPERT

Commented:
You can but it would wipe off everything currently on it.  You have to transfer data somewhere before proceeding.

Author

Commented:
ok, trying to wrap my head around this:

$ grep /dev/md /etc/fstab
# /dev/md0

$ df -h / /home
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda1              19G  2.7G   15G  16% /
/dev/md0              128G   43G   79G  36% /home

$ cat /proc/mdstat
Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10]
md0 : active raid1 sda3[0]
      134801344 blocks [2/1] [U_]
     
unused devices: <none>

$ sudo mdadm --query --detail /dev/md0
/dev/md0:
        Version : 00.90.03
  Creation Time : Tue Jul  8 19:18:47 2008
     Raid Level : raid1
     Array Size : 134801344 (128.56 GiB 138.04 GB)
  Used Dev Size : 134801344 (128.56 GiB 138.04 GB)
   Raid Devices : 2
  Total Devices : 1
Preferred Minor : 0
    Persistence : Superblock is persistent

    Update Time : Wed May 18 21:34:32 2011
          State : active, degraded
 Active Devices : 1
Working Devices : 1
 Failed Devices : 0
  Spare Devices : 0

           UUID : 0553725a:cf84abcf:68ceeaf4:7264baec
         Events : 0.48058

    Number   Major   Minor   RaidDevice State
       0       8        3        0      active sync   /dev/sda3
       1       0        0        1      removed


So, I think, I have a single drive with one RAID1 partition (md0)  
The second drive is obviously missing.
I am going to install a new, unformatted drive into the box.

This should give me something like:
$ cat /proc/mdstat
Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10]
md0 : active raid1 sda3[0]
      134801344 blocks [2/2] [U_]

I would then run
sudo mdadm --add /dev/md0 /dev/sdb3

or would I use this command?
sudo mdadm --manage --add /dev/md0 /dev/sdb3

What is the difference?
Let me know if I am missing anything.

Author

Commented:
I place a new drive into the box and run:
sudo mdadm --add /dev/md0 /dev/sdb3

and I get:
mdadm: cannot find /dev/sdb3: No such file or directory

do I need to format/partition before doing this?  What is the process?
Top Expert 2011

Commented:
> do I need to format/partition before doing this?
You need to use fdisk to partition /dev/sdb to be the same as /dev/sda first.

Please post the output of
sudo fdisk -l

Author

Commented:
$ sudo fdisk -l
[sudo] password for khudson:

Disk /dev/sda: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x0004a40a

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1        2432    19535008+  83  Linux
/dev/sda2            2433        2675     1951897+  82  Linux swap / Solaris
/dev/sda3            2676       19457   134801415   fd  Linux raid autodetect

Disk /dev/sdb: 160.0 GB, 160041885696 bytes
255 heads, 63 sectors/track, 19457 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x00000000

Disk /dev/sdb doesn't contain a valid partition table

Disk /dev/md0: 138.0 GB, 138036576256 bytes
2 heads, 4 sectors/track, 33700336 cylinders
Units = cylinders of 8 * 512 = 4096 bytes
Disk identifier: 0x00000000

Disk /dev/md0 doesn't contain a valid partition table


Top Expert 2011

Commented:
sudo fdisk /dev/sdb
n
p
1
<Enter>         # for start sector
2432 <Enter> # for end sector
n
p
2
<Enter>
2675 <Enter>
n
p
3
<Enter>
19457 <Enter>
t
3
fd
w

Author

Commented:
Just so I can conceptualize before I perform
sudo fdisk /dev/sdb
n = ???
p = primary
1 = first partition
<Enter>         # for start sector
2432 <Enter> # for end sector
n = ???
p = primary
2 = second partition
<Enter> # for start sector (implies next available sector)
2675 <Enter> # for end sector
n = ???
p = primary
3 = third partition
<Enter> # for start sector (implies next available sector)
19457 <Enter> # for end sector
t = ???
3 = ???
fd = ???
w = write command

Top Expert 2011

Commented:
in fdisk , press m for menu
n : add new partition
t: toggle the partition type
fd: is the type show on /dev/sda3 (md)
  You might want to change /dev/sdb2 to type 82 (swap)

Author

Commented:
So it would be:???

sudo fdisk /dev/sdb
n
p
1
<Enter>         # for start sector
2432 <Enter> # for end sector
n
82
2
<Enter>
2675 <Enter>
n
p
3
<Enter>
19457 <Enter>
t
3
fd
w
Top Expert 2011
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
Thanks Wesly.  Your help is very much appreciated.

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.