25 November 2009

Slackware 12.2 - Moving to RAID-1

New RAID tools that come with Slackware 12.2 is "mdadm" not "mkraid".
I want to move my Salckware 12.2 had installed sata HDD to software RAID with RAID-1 (mirror).
Again, this is a my success story. Let's go.

Recent system
Hard disk 1 sata 160 gb with Slackware 12.2 installed.

I have installed Slackware 12.2 and he working fine. But its better if have backup system when HDD crash.
That is often situation can happen.
Partiton information:
d1 = /dev/sda
/dev/sda1 /
/dev/sda2 /user/local
/dev/sda3 swap
/dev/sda4 /home

New Harddisk recommended use same size or model:

1.View Harddisk d1 (Slackware 12.2 installed)
#fdisk /dev/sdb
Device boot Start End Blocks Id System
/dev/sdb1 * 1 250 2150025 83 Linux
/dev/sdb2 251 1135 3500250 83 Linux
/dev/sdb3 1136 1452 2514575 82 Linux swap
/dev/sdb4 1453 2509 50251425 83 Linux

2.จัดเตรียม d2
make partition with the same structure of "d1" but set type to "fd (Linux raid autodetect)" to let Slackware auto detect RAID on start up.
#fdisk /dev/sdb
#fdisk /dev/sdc

Device boot Start End Blocks Id System
/dev/sdc1 * 1 250 2150025 fd Linux raid autodetect
/dev/sdc2 251 1135 3500250 fd Linux raid autodetect
/dev/sdc3 1136 1452 2514575 82 Linux swap
/dev/sdc4 1453 2509 50251425 fd Linux raid autodetect

3.Make RAID Drive from created partition:

#mdadm -Cv /dev/md0 -l1 -n2 /dev/sdb1 /dev/sdc1
#mdadm -Cv /dev/md1 -l1 -n2 /dev/sdb2 /dev/sdc2
#mdadm -Cv /dev/md3 -l1 -n2 /dev/sdb1 /dev/sdc4
-l = RAID level [0, 1, 5]
-n = Amount of disk
-c = Block size default 64 may be 128 if you want.

Start RAID:
#mdadm -A /dev/md0 /dev/sdb1 /dev/sdc1
#mdadm -A /dev/md1 /dev/sdb2 /dev/sdc2
#mdadm -A /dev/md3 /dev/sdb4 /dev/sdc4

4.Make file system:
# mkreiserfs /dev/md0
# mkreiserfs /dev/md1
# mkreiserfs /dev/md3

5.Copy Slackware system from /dev/sda* to /dev/md*
#mount /dev/md0 /mnt
#mkdir -p /mnt/usr/local
#mkdir -p /mnt/home

Mount other drive:
#mount /dev/md1 /mnt/usr/local
#mount /dev/md3 /mnt/home

Copy From old HDD:
#cp -a /bin /mnt
#cp -a /boot /mnt
#cp -a /etc /mnt
#cp -a /home /mnt
#cp -a /lib /mnt
#cp -a /root /mnt
#cp -a /sbin /mnt
#cp -a /tmp /mnt
#cp -a /usr /mnt
#cp -a /var /mnt

#mkdir -p /mnt/mnt
#mkdir -p /mnt/proc

6.Set to boot from RAID Device:
#vi /mnt/etc/lilo.conf
Edit or append the line that include:

boot = /dev/md0
raid-extra-boot = mbr
root = /dev/md0

Run lilo
#lilo -r /mnt

6.Reboot and Set BIOS
Set BIOS to First boot from /dev/sdb or secondary harddisk.
When login to Slackware you can check that Slackware working on raid?
#df -m
it should look like this:

/dev/md0 /
/dev/md1 /user/local
/dev/sda3 swap
/dev/md3 /home

7.Add /dev/sda in RAID to make spare harddisk.
Make partition like (1.)
#fdisk /dev/sda
#mdadm /dev/md0 --add /dev/sda1
#mdadm /dev/md1 --add /dev/sda2
#mdadm /dev/md3 --add /dev/sda4

run lilo to set mbr boot

Wait RAID to syn untill 100% you can check by:
#mdadm --detail /dev/md0

More RAID command
Remove harddisk from RAID system of fail.
#mdadm /dev/md0 --fail /dev/sdb1 --remove /dev/sdb1
Or you can shutdown and remove harddisk and open again it will auto syn from spare hardisk.

Check all RAID information:
#mdadm --detail --scan

Check each RAID information
#mdadm --detail /dev/md0
#mdadm --detail /dev/md1
#mdadm --detail /dev/md3

### Good luck to you.###

No comments:

Post a Comment