Hi,
I've been searching for answers for two days and didn't find any definite answers on building RAID1 on SPARC. The main problem was with SILO (Sparc Improved boot LOader): can it boot from RAID partition or not. So I just tried it and it works.
I've done this on Debian, but it should be applicable to all Linux distributions.
Setup RAID1 on T5220 with 2 disks /dev/sda and /dev/sdb.
Here's the setup:
Currently only /dev/sda is active and sliced into 3 partitions:
/dev/sda1 is /boot (ext2)
/dev/sda2 is / (ext3)
/dev/sda4 is swap
/dev/sda3 only marks the whole disk. Like c partition on BSD.
/boot has ext2 since the installation. I really don't know why, but I'm keeping it.
First thing's first: compile support for RAID in the kernel (modules won't do)!
Second: using fdisk, change id of all the partitions you would like to add to RAID array to Linux raid autodetect (fd).
Copy the partition table to the next disk:
$ sudo dd if=/dev/sda of=/dev/sdb bs=512 count=1
$ sudo fdisk -l /dev/sda
Disk /dev/sda (Sun disk label): 255 heads, 63 sectors, 17848 cylinders
Units = cylinders of 16065 * 512 bytes
Device Flag Start End Blocks Id System
/dev/sda1 0 12 96390 fd Linux raid autodetect
/dev/sda2 12 17088 137162970 fd Linux raid autodetect
/dev/sda3 0 17848 143364060 5 Whole disk
/dev/sda4 17088 17848 6104700 fd Linux raid autodetect
$ sudo fdisk -l /dev/sdb
Disk /dev/sdb (Sun disk label): 255 heads, 63 sectors, 17848 cylinders
Units = cylinders of 16065 * 512 bytes
Device Flag Start End Blocks Id System
/dev/sdb1 0 12 96390 fd Linux raid autodetect
/dev/sdb2 12 17088 137162970 fd Linux raid autodetect
/dev/sdb3 0 17848 143364060 5 Whole disk
/dev/sdb4 17088 17848 6104700 fd Linux raid autodetect
Using mdadm, create md devices with only one member!
$ sudo mdadm -C /dev/md0 -l 1 -n 2 missing /dev/sdb1
$ sudo mdadm -C /dev/md1 -l 1 -n 2 missing /dev/sdb2
$ sudo mdadm -C /dev/md2 -l 1 -n 2 missing /dev/sdb4
NOTE:
When creating md devices, it is wiser to name them the same as the disk devices are named, so that, for example, md2 includes sda2 and sdb2, md3 includes sda3 and sdb3 and so on. That removes the possible brain damage when adding more than 3 partitions in RAID.
Create filesystem on md0 and md1:
$ sudo mkfs -t ext2 /dev/md0
$ sudo mkfs -t ext3 /dev/md1
Mount both devices and copy data:
$ sudo mkdir /mnt/md0 /mnt/md1
$ sudo mount /dev/md0 /mnt/md0
$ sudo mount /dev/md1 /mnt/md1
$ sudo rsync -auHxv /boot/* /mnt/md0
$ sudo rsync -auHxv --exclude=/proc/* --exclude=/sys/* --exclude=/mnt/* /* /mnt/md1
$ for i in /mnt/md*; do
> sudo umount $i
> done
Unmount /boot and add the device to /dev/md0 and unswap /dev/sda4 and add it to /dev/md2:
$ sudo umount /boot
$ sudo mdadm /dev/md0 -a /dev/sda1
$ sudo mount /dev/md0 /boot
$ sudo swapoff /dev/sda4
$ sudo mdadm /dev/md2 -a /dev/sda4
$ sudo mkswap /dev/md2
$ sudo swapon /dev/md2
Edit /etc/fstab and replace /dev/sda devices with /dev/md:
$ cat /etc/fstab
# /etc/fstab: static file system information.
#
# <file system> <mount point> <type> <options> <dump> <pass>
proc /proc proc defaults 0 0
#/dev/sda2 / ext3 errors=remount-ro 0 1
#/dev/sda1 /boot ext2 defaults 0 2
#/dev/sda4 none swap sw 0 0
/dev/scd0 /media/cdrom0 udf,iso9660 user,noauto 0 0
/dev/md0 /boot ext2 defaults 0 2
/dev/md1 / ext3 errors=remount-ro 0 1
/dev/md2 none swap sw 0 0
Edit silo.conf and replace only root option from:
root=/dev/sda2
to
root=/dev/md1
Everything else stays the same:
$ cat /boot/silo.conf
root=/dev/md1
partition=1
default=Linux
read-only
timeout=100
image=/vmlinuz
label=Linux
initrd=/initrd.img
Create mdamd.conf from mdadm output:
$ sudo mdadm --detail --scan > /tmp/mdadm.conf && sudo mv /tmp/mdadm.conf /etc/mdadm/mdadm.conf
$ cat /etc/mdadm/mdadm.conf
ARRAY /dev/md1 level=raid1 num-devices=2 metadata=00.90 UUID=1e0247b6:38abf547:5dec9e91:f507770d
ARRAY /dev/md0 level=raid1 num-devices=2 metadata=00.90 UUID=8a086292:710ef67f:5dec9e91:f507770d
ARRAY /dev/md2 level=raid1 num-devices=2 metadata=00.90 UUID=c78000c5:1a4d6dc4:9ee3339d:45c4c887
NOTE:
Perhaps even better method for creating mdamd.conf would be by using --examine instead of --detail, which doesn't include metadata information and removes occasional error regarding metadata version.
Reboot. After the system boots, add the remaining /dev/sda2 (ex root) to /dev/md1.
Wait for the devices to sync and you are finished.
$ sudo mdadm /dev/md1 -a /dev/sda2
At any point you can examine status of your RAID by reading /proc/mdstat:
$ cat /proc/mdstat
Personalities : [linear] [raid0] [raid1] [multipath] [raid6] [raid5] [raid4]
md2 : active raid1 sda4[0] sdb4[1]
6104576 blocks [2/2] [UU]
md0 : active raid1 sda1[1] sdb1[0]
96320 blocks [2/2] [UU]
md1 : active raid1 sda2[1] sdb2[0]
137162880 blocks [2/2] [UU]
unused devices: <none>
That's it. OS boots from RAID partition. I even unplugged the disk to see the effects and it holds and boots. The only thing left was to force Linux to rescan the SCSI controller for devices once the removed disk was reinserted. This was done with a simple shell script:
#!/bin/sh
for i in /sys/class/scsi_host/host*; do
echo "- - -" > ${i}/scan
done
Any comments and/or questions are welcome.