Transfer HDD Software Raid from IB-NAS-4220-B to workstation computer

I'm writing this post because I want to get away from my Raidsonic IB-NAS-4220-B, a dedicated network access storage (NAS) device. Instead I want to put the two S-ATA hard disks into my Ubuntu linux home server. It should use software raid1 just as the NAS did before and I don't want to change anything with the disks. I just want to plug them in and be able to mount them. This is possible with the kernel module md from the package mdadm. Read on if you want to know how it works...

basic configuration

First check if kernel module md is loaded on the Ubuntu server.
If it is not installed then get it (choose not to install an MTA if you do not really want to send warning e-mails in cases of degrading statuses):

sudo apt-get install mdadm
# and load the kernel module
sudo modprobe md

Check again, if the kernel module md is loaded:

sudo lsmod | grep md

Now you can append a new line md to /etc/modules in order to load the module at startup.

move an md raid from one to another computer (or from IB-NAS-4220B to Ubuntu PC)

http://forums.whirlpool.net.au/forum-replies-archive.cfm/1099675.html
http://ubuntuforums.org/showthread.php?t=850229

Just transfer the disks to your new computer, install mdadm (described above) and run

sudo mdadm --assemble --scan

This will add entries to the config file: /etc/mdadm/mdadm.conf

create a new raid 1 instead

http://users.softlab.ece.ntua.gr/~ttsiod/tricks.html#raid1

create the partitions on the disks you want to use. This can be done using fdisk: choose n for new partition then create a partition taking the whole disk. Start the partitions used as elements of the raid array on cylinder one instead of the default cylinder zero in order to have no problems with disk lables. if the two hdds are of a different size you must create two partitions of same number of cylinders (size). now choose t for type and select fd (Linux RAID). Commit changes with w.

Now create the raid 1 array:

sudo mdadm --create --verbose /dev/md0 --auto=yes --level=0 --raid-devices=2 /dev/hde1 /dev/hdg1

then you can format it (with the ext3 file system for e.g.):

sudo mkfs.ext3 /dev/md0

add a mount point

howto fstab (syntax and fstab options, how to label, examples, references): http://ubuntuforums.org/showthread.php?t=283131

Add an entry for the device /dev/md0 to /etc/fstab:

/dev/md0 /mymountpoint ext3 defaults 0 2

If you want the raid array to work with spindown etc. then replace defaults by noatime, or relatime (see http://www.lesswatts.org/tips/disks.php for the effects). The second last number tells the dump command (backup) to ignore the file system and the last number tells it to scan the filesystem 2, to do it with priority 1 or to not check it 0.

if mdadm ist not run automatically on startup, then: Create a file in the folder /etc/init.d/ called mdadm-custom, with the same ownership (root/root) and permissions (755) as the other files:

#!/bin/sh
#################################
# Custom work for mdadm on boot #
#################################
# I don't specify a specific array. This will assemble all.
mdadm --assemble --scan
# Start the monitoring process
#nohup mdadm --monitor --mail=philipp --delay=300 /dev/md1 &

Then, in your /etc/rcS.d create a symlink to this file:

sudo ln -s /etc/init.d/mdadm-custom /etc/rcS.d/S29mdadm-custom.sh

where the S29 is a number smaller then the number in front of the mountall script, actually: S35mountall.sh and smaller than the filesystem check link number S30checkfs.sh. This way, the custom script will run before the mountall.

raid knowledge

howto setup at time of installation and howto replace failed devices: http://advosys.ca/viewpoints/2007/04/setting-up-software-raid-in-ubuntu-server/

check status of the raid system:

cat /proc/mdstat

spindown

When making use of the linux software raid (mdadm) adjust the values of the physical drives for spindown. Not the device handle /dev/md0! ( http://forums.whirlpool.net.au/forum-replies-archive.cfm/1065111.html )

check status of a hardddisk:

sudo hdparm -C /dev/sda

put a harddisk to standby (spindown):

sudo hdparm -y /dev/sda

to configure spindown time use the next code block where the value -S means the factor x 5s it will take until spindown from the manpage for longer timeouts: "Values from 241 to 251 specify from 1 to 11 units of 30 minutes, yielding timeouts from 30 minutes to 5.5 hours. A value of 252 signifies a timeout of 21 minutes. A value of 253 sets a vendor-defined timeout period between 8 and 12 hours, and the value 254 is reserved. 255 is interpreted as 21 minutes plus 15 seconds. Note that some older drives may have very different interpretations of these values."

# set HD spindown to 5 minutes 
hdparm -S60 /dev/sda
# set HD spindown to 30 minutes
hdparm -S 241 /dev/sda

in case it doesn't work as you wish, take a look at http://de.nas-4220.org/index.php/Tools#Spindown_Tracking_Tool

for spindown to work after reboots save the settings in the file /etc/hdparm.conf

command_line {
       sudo hdparm -S 240 /dev/sdb
}
command_line {
       sudo hdparm -S 240 /dev/sdc
}

read out hdd temperature

install:

sudo apt-get install hddtemp smartmontools

use:

sudo hddtemp /dev/sdb

for more see:

sudo smartctl -a /dev/sdb

resources

Comments