Ubuntu - create raid from existing install and adding a new drive.
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.
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.
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).
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.
wesly_chen
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.
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.
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.
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?
wesly_chen
> 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
bmsjeff
ASKER
$ 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
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
bmsjeff
ASKER
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
wesly_chen
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)
http://ascend4.org/Installing_Raid_1_on_Existing_Ubuntu_Server
but don't want to format the first drive. Is that possible?