The disks:
1 x 500GB drive (Western Digital Caviar Green GP WD5000AADS) for system software.
2 x 2TB drives (Western Digital Caviar Green GP WD20EARS) that will become one 2TB data storage as I am going to be using an RAID1 setup (meaning the 2TB drives will be mirrored/identical to one-another).
Hardware setup:
I started by installing the 500GB drive in my machine, replacing the failed hard drive. I rebooted and installed Ubuntu 10.10. After installation and setup I shutdown the PC to allow installing the two data drives.
After installing the two data drives I fired up the machine and ........ NOTHING.......PANIC
After some fiddling I noticed in the BIOS settings that apparently the boot drive was automatically assumed to be one of the new data drives. So after setting this back to the 500GB drive containing the fresh install and saving my BIOS setting, my PC was back up and running. Time for setting up the software RAID.
Software setup:
Before starting this setup I began reading up on software RAID on linux (see 'Sources used' section at the end). Next I'll list the steps used to reach my software RAID setup.
installing the mdadm tool
I started by installing the mdadm tool via Ubuntu's Synaptic Package Manager. Once installed I rebooted the machine to see if after reboot the necessary kernel modules related to software RAID would have been loaded automatically.
check install mdadm
To see if the RAID modules were correctly started I issued the following command.
someuser@linuxbox:~$ cat /proc/mdstat
Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10]
unused devices: <none>
list the drives
Before creating the RAID device I needed to know what were the device names of the disks I was going to use.
someuser@linuxbox:~$ sudo fdisk -l
[sudo] password for someuser:
Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00072e62
Device Boot Start End Blocks Id System
/dev/sda1 * 1 59416 477254656 83 Linux
/dev/sda2 59416 60802 11128833 5 Extended
/dev/sda5 59416 60802 11128832 82 Linux swap / Solaris
Disk /dev/sdb: 2000.4 GB, 2000398934016 bytes
255 heads, 63 sectors/track, 243201 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/sdb doesn't contain a valid partition table
Disk /dev/sdc: 2000.4 GB, 2000398934016 bytes
255 heads, 63 sectors/track, 243201 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/sdc doesn't contain a valid partition table
setting partition types
Before you can create your RAID device you also need to set the appropriate partition types for the disks you are going to use. In fdisk you can always enter 'm' as command for help and 'l' to see what are the possible partition types.
someuser@linuxbox:~$ sudo fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x08c32e4e.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-243201, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-243201, default 243201):
Using default value 243201
Command (m for help): t
Selected partition 1
Hex code (type L to list codes): da
Changed system type of partition 1 to da (Non-FS data)
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
someuser@linuxbox:~$ sudo fdisk /dev/sdc
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x1fde476b.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-243201, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-243201, default 243201):
Using default value 243201
Command (m for help): t
Selected partition 1
Hex code (type L to list codes): da
Changed system type of partition 1 to da (Non-FS data)
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
create raid device
Now we are ready to create the RAID device.
someuser@linuxbox:~$ sudo mdadm --create --verbose /dev/md0 --level=mirror --raid-devices=2 /dev/sdb1 /dev/sdc1
mdadm: size set to 1953511936K
mdadm: array /dev/md0 started.
Now the two drives will start synching, you can monitor the synch process like this:
someuser@linuxbox:~$ cat /proc/mdstat
Personalities : [linear] [multipath] [raid0] [raid1] [raid6] [raid5] [raid4] [raid10]
md0 : active raid1 sdc1[1] sdb1[0]
1953511936 blocks [2/2] [UU]
[>....................] resync = 0.5% (10869696/1953511936) finish=401.4min speed=80648K/sec
set the mdadm.conf file
To make sure your system remembers your RAID setup's configuration you need to write it to the mdadm configuration file.
someuser@linuxbox:~$ sudo mdadm --detail --scan --verbose >> /etc/mdadm/mdadm.conf
bash: /etc/mdadm/mdadm.conf: Permission denied
someuser@linuxbox:~$ ls -al /etc/mdadm/mdadm.conf
-rw-r--r-- 1 root root 626 2010-11-28 20:46 /etc/mdadm/mdadm.conf
someuser@linuxbox:~$ sudo chmod a+w /etc/mdadm/mdadm.conf
someuser@linuxbox:~$ sudo mdadm --detail --scan --verbose >> /etc/mdadm/mdadm.conf
someuser@linuxbox:~$ sudo chmod a-w,u+w /etc/mdadm/mdadm.conf
someuser@linuxbox:~$ ls -al /etc/mdadm/mdadm.conf
-rw-r--r-- 1 root root 723 2010-12-04 11:57 /etc/mdadm/mdadm.conf
someuser@linuxbox:~$ cat /etc/mdadm/mdadm.conf
# mdadm.conf
#
# Please refer to mdadm.conf(5) for information about this file.
#
# by default, scan all partitions (/proc/partitions) for MD superblocks.
# alternatively, specify devices to scan, using wildcards if desired.
DEVICE partitions
# auto-create devices with Debian standard permissions
CREATE owner=root group=disk mode=0660 auto=yes
# automatically tag new arrays as belonging to the local system
HOMEHOST <system>
# instruct the monitoring daemon where to send mail alerts
MAILADDR root
# definitions of existing MD arrays
# This file was auto-generated on Sun, 28 Nov 2010 20:46:56 +0100
# by mkconf $Id$
ARRAY /dev/md0 level=raid1 num-devices=2 metadata=00.90 UUID=f41ede30:06fdbe6a:d1cf655b:887f7986
devices=/dev/sdb1,/dev/sdc1
prepare the file system
Once the RAID device is created you can prepare the file system.
Once the RAID device is created you can prepare the file system.
someuser@linuxbox:~$ sudo mkfs.ext3 /dev/md0
prepare mount point
To become useful I needed to mount the RAID device to a mount point accessible to my everyday user.
To become useful I needed to mount the RAID device to a mount point accessible to my everyday user.
mkdir /home/someuser/data
edit the /etc/fstab and add following line:
/dev/md0 /home/someuser/data ext3 user,rw 1 2
sudo mount /home/someuser/data
sudo chown -R someuser.someuser /home/someuser/data
sudo umount /home/someuser/data
mount /home/someuser/data
Now my software RAID setup is ready for usage. Currently it gets mounted in my local home directory. I'll do some basic tests first. After those tests I will move the complete contents of the home directory onto this RAID device.
Sources used:
https://raid.wiki.kernel.org/index.php/RAID_setup
http://linuxconfig.org/Linux_Software_Raid_1_Setup
http://www.linuxhomenetworking.com/wiki/index.php/Quick_HOWTO_:_Ch26_:_Linux_Software_RAID
Geen opmerkingen:
Een reactie posten