Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create a RAID-1 of the boot disk and a new disk 2

Status
Not open for further replies.

oskare100

Technical User
Mar 25, 2005
16
SE
Hello,
I had one disk before (/dev/sda) with two partitions, one swap and one ext3 where all the files are located. Now I've added a second disk (/dev/sdb) and want to create a RAID-1 disk of the two disks (based on the current /dev/sda disk). How can I do that? I've installed mdadm but I can't figure out how to create the RAID-1 since I'm running the system on /dev/sda.

Best Regards
Oskar R
 
There was a discussion back in January about adding a RAID volume to your system without reinstalling. Try this thread. Hope it helps.

--== Anything can go wrong. It's just a matter of how far wrong it will go till people think its right. ==--
 
Hello,
Sorry but I don't really understand how to follow that guide, how can I do the following:
2. With fdisk, create a new partition of type fd on your new drive.
5. At this point, /dev/md0 is fully usable. Mount /dev/md0 and copy the contents of /dev/sdb to /dev/md0.
6. Unmount /dev/sdb and mount /dev/md0 in /dev/sdb mount point.
7. With fdisk, repartition /dev/sdb with a partition of type fd.


And my /etc/fstab looks like this so I don't know what to edit:

LABEL=/ / ext3 defaults 1 1
devpts /dev/pts devpts gid=5,mode=620 0 0
tmpfs /dev/shm tmpfs defaults 0 0
proc /proc proc defaults 0 0
sysfs /sys sysfs defaults 0 0
LABEL=SWAP-sda2 swap swap defaults 0 0

Thanks,
Oskar
 
Also, I created /dev/md0 and /dev/md1 now by misstake when I tried another guide and now I can't remove them... They are based on /dev/sdb1 and /dev/sdb2. How can I remove /dev/md0 and /dev/md1 now to be able to continue without reinstalling the system again?
 
Was busy these few days and I needed some time to test a "live" raid migration so that I could give you a detailed step-by-step guide. The link I provided gave general pointers on how to accomplish the task and expects the reader to navigate the details.

To remove/deactivate existing RAID volumes: mdadm -S /dev/md[x], where [x] is the RAID device.

Here is the scenario on my test machine. I've got 2 drives - sda & sdb. sda is partitioned into 2 parts - sda1 (OS) & sda2 (swap).

1. Partition sdb in 1 of 2 ways*:
1a. Follow the same sizing as sda. You will get: same storage capacity, double swap space.
1b. Half the swap partition size of sda. You will get: bigger storage space, same swap space with 2 drives.

Be sure to set sdb1 partition type as fd.

2. Create your RAID volume. mdadm -C /dev/md0 --force --level=1 --raid-device=2 /dev/sdb1 missing.

3. Create you file system & swap.
mkfs -t ext3 /dev/md0
mkswap /dev/sdb2

4. Mount /dev/md0 somewhere. I mounted it on /mnt.

5. Copy (cp -R) everything from sda1 to /mnt EXCEPT /proc & /sys.

6. Create empty proc & sys folders in /mnt. mkdir /mnt/proc /mnt/sys

7. Mount the proc filesystem to /mnt/proc. mount -t proc proc /mnt/proc

8. chroot into /mnt. chroot /mnt

9. Edit /etc/fstab & /boot/grub/grub.conf (or menu.lst) and change all references of sda1 to md0. Change the reference of you swap from sda2 to sdb2 too.

10. Create the /etc/mtab file. cat /proc/mounts > /etc/mtab

11. Install the grub boot loader on sdb. Invoke the grub shell with grub. In the shell type in:
grub> root (hd1,0)
grub> setup (hd1)
grub> quit

12. Reboot your machine and unplug sda to see if your system boots up.

Now, if up to this point you system boots up fine, it's time to add sda into the mix. Remember to plug sda back into your system.

13. If sda1 and sdb1 are of different sizes (because you followed step 1b), repartition sda1 to have the same size. Else just change the partition type to fd.

14. Add sda1 into your RAID volume. mdadm /dev/md0 --add /dev/sda1. You can check the rebuild status with mdadm --detail /dev/md0.

15. Done.

* There is no point in mirroring your swap partition. Some have reported a performance penalty in doing so. Sacrificing swap space for storage is regarded by some as a big NO-NO. Besides, the additional storage gains will usually be in the 256MB to 512MB range (negligible).

--== Anything can go wrong. It's just a matter of how far wrong it will go till people think its right. ==--
 
zeland, I gave you a star whether it's fully correct or not. That post and research was way beyond the call! Nice work!

D.E.R. Management - IT Project Management Consulting
 
As this was a one-off thing that I did sometime back, it was never documented. Now however, I see that a number of people have a need for such a method. So as not to let my experience go to waste, I thought that it would be a good experiment to try it again and made sure I document it down this time.

I went through the initial process about 3 times just to get the hang of it and make sure the method works. On the 4th pass I started to document the steps. I did a 5th pass according to the steps documented just to verify. However, after repeating something over and over again, some steps become instinctive and tend get left out of the documentation.

I hope that our friend oskare100's success in this endeavor would serve as a validation to the steps above.

--== Anything can go wrong. It's just a matter of how far wrong it will go till people think its right. ==--
 
A star from me too, and please considder putting
it in the FAQ-section to. :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top