This tutorial is written by one of our customers who successfully applied software RAID10 on his server without KVM and only by use of Rescue Mode.
It gives you the idea of how to apply different type of RAID on your server simply by using dedicated panel in your client account.
Software RAID10 Tutorial by Alberto Nakayama:
================================
Woops I haven’t read it ’till now, here’s a how-to.
On the example the /home partition is the one that have almost all of the HD space.
It’s been made using raid1 for /boot and raid10 for all other partitions.
===================================
1) To begin I’ll asume that you are on the SSH of your recently installed server with Linux on SDA.
2) Let’s create some partitions on the SDB disk. This oneliner will create a 200M active partition (for /boot), a 50G partition (for the system), a 4G partition (for swapping) and the last one for /home with all the resting space. All the partitions are changed to “Linux raid autodetect”.
echo -e “n\np\n1\n\n+200M\nn\np\n2\n\n+50G\nn\np\n3\n\n+4G\nn\np\n4\n\n\nt\n1\nfd\nt\n2\nfd\nt\n3\nfd\nt\n4\nfd\na\n1\nw\n” | fdisk /dev/sdb
3) Let’s copy that partitioning to all other disks
sfdisk -d /dev/sdb | sfdisk /dev/sdc
sfdisk -d /dev/sdb | sfdisk /dev/sdd
4) Now we mount some needed modules
modprobe linear
modprobe raid0
modprobe raid1
modprobe raid10
5) And start all the RAID disks with one missing partition for each one of them
mdadm –create –level=1 –force –assume-clean –metadata=0.9 –raid-devices=4 /dev/md0 /dev/sdb1 /dev/sdc1 /dev/sdd1 missing
mdadm –create –level=10 –force –assume-clean –metadata=0.9 –raid-devices=4 /dev/md1 /dev/sdb2 /dev/sdc2 /dev/sdd2 missing
mdadm –create –level=10 –force –assume-clean –metadata=0.9 –raid-devices=4 /dev/md2 /dev/sdb3 /dev/sdc3 /dev/sdd3 missing
mdadm –create –level=10 –force –assume-clean –metadata=0.9 –raid-devices=4 /dev/md3 /dev/sdb4 /dev/sdc4 /dev/sdd4 missing
6) Now, let’s format the disks. I’ve chosen ext4 but you can use any format you like like ext3 or reiserfs.
mkfs.ext4 /dev/md0
mkfs.ext4 /dev/md1
mkswap /dev/md2
mkfs.ext4 /dev/md3
7) Let’s save the array disk’s data on file
mdadm –examine –scan >> /etc/mdadm.conf
Now we have to make a new initrd file so that it loads the raid module on-boot. This is needed for CentOS and probable Debian based systems too. Remember to delete any rd_NO_* line on the kernel line because that may avoid your server from loading the raid disks.
mkinitrd –fstab=/mnt/server/etc/fstab –with=raid1 –with=raid10 –preload=raid10 –preload=raid1 /boot/initrd-raid-`uname -r`.img `uname -r`
nano /boot/grub/menu.lst
9) Let’s mount the new arrays on /mnt and copy all the system into them.
mkdir /mnt/server
mount /dev/md1 /mnt/server/
cd /mnt/server/
cp -ax / .
mkdir /mnt/server/boot
mount /dev/md0 /mnt/server/boot
cd /mnt/server/boot
cp -ax /boot/* .
10) Now, change the old SD disks to the new MD disks, add the last one to get mounted as /home. We’ll only edit the copy that’s already inside the array disk so that if you need to boot with sda to fix something, you’ll be able to do it.
nano /mnt/server/etc/fstab
11) Now, let’s install grub on all the new /boot partitions
grub
root (hd0,0)
setup (hd0)
root (hd1,0)
setup (hd1)
root (hd2,0)
setup (hd2)
root (hd3,0)
setup (hd3)
quit
12) With our fingers crossed, we execute reboot
- If after some time your machine don’t boot up (give it at least 5 minutes), you can boot into recovery mode and change the file /boot/grub/menu.lst to boot with /dev/sda2 again, so you can start over and see what went wrong on the logfiles.
- Otherwise if it worked, we have to add SDA to the array
13) First let’s copy the partitions
sfdisk -d /dev/sdb | sfdisk /dev/sda
14) Then add it to the /boot raid and reinstall grub once it has finished
mdadm –add /dev/md0 /dev/sda1
(wait ’till it finishes, its just a few seconds)
grub
root (hd0,0)
setup (hd0)
exit
15) Then we add all the other partitions to their corresponding array disk
mdadm –add /dev/md1 /dev/sda2
mdadm –add /dev/md2 /dev/sda3
mdadm –add /dev/md3 /dev/sda4
16) Wait till they all sync up and you’re ready to go.
PS: You can cat the file /proc/mdstat to know how much has been synced and how much you have to wait, it will probably take a few hours on large disks.