CIS 191B
Lab 7x: Extra Credit
The purpose of this lab is similar to lab 7 in that we are going to offload the storage under the /home directory to its own filesystem. What is different is that the filesystem will be formatted on a RAID 1 structure that will provide mirroring of the data under the /home directory. You will use the original CentOS Virtual Machine for this lab, since the Midterm VM already has a home filesystem.
Background
RAID I provides redundancy in a storage environment by writing data to two devices at the same time. This technique also provides failover protection, since if one of the devices fails, the data can still be accessed on the other device. Normally the two devices would be
separate disks, but in this lab we will use separate partitions to represent the two devices.
After setting up the RAID-based home filessytem, you will simulate a failed device and
recover by adding a "new" device.
Procedure
Step I
Configure the RAID-1 Device
- Boot CentOS to single user mode.
- Create two new partitions, (sda6 and sda7) each one consisting of 63 cylinders, (514MB)
with a partition id of 0xfd.
- Be sure to run partprobe after writing out the fdisk configuration.
- Run the following command to associate these two partitions with one device, (/dev/md0):
mdadm -C /dev/md0 --level=1 -n 2 /dev/sda6 /dev/sda7
Step II
Create and configure the /home filesystem
- Format the RAID device with a filesystem:
mkfs -t ext3 -L /home -R stride=32 /dev/md0
Note: the -R stride setting sets the RAID devices chunk size in filesystem blocks.
What is the block size of this filesystem?
- Add the entry to /etc/fstab so that this filesystem will mount automatically at boot time.
- Mount the filesystem to /mnt and move all the home directories under /home to /mnt
- Unmount /mnt and use the following command to test your fstab:
mount -a
- Verify the correct operation of your new device with the command:
mdadm --detail /dev/md0
Save this output to a file called lab7x.
Testing
Now that you have your new RAID filesystem mounted and operational, you will simulate a bad
disk, and perform a system recovery.
- Log on as a regular user on a different tty, and create a file in your home directory.
- As root, simulate a device failute with the command:
mdadm /dev/md0 -f /dev/sda6
What indication is there that you have a failure? What does mdadm --detail say? Can
the user still access his/her file? Create a new file?
Save the mdadm --detail output to your lab7x file.
- Now you will remove the failed device, insert a new one, and add it back to the array:
- Remove the failed device (/dev/sda6) with the command:
mdadm /dev/md0 -r /dev/sda6
- Zero out the device, thus simulating a brand new device:
dd if=/dev/zero of=/dev/sda6 bs=1k
This will take a few seconds at which time you will get a disk full warning.
- Now add the device back into the array:
mdadm /dev/md0 -a /dev/sda6
Give this command some time to complete; it has to re-create the filesystem
- Can the user still access his/her data?
You have successfully hot-swapped a RAID device without interrupting the user.
Turnin
Your report for this lab should be the lab7x file that you have been updating along the way.
It should show the output of the mdadm --detail
command three different times:
- Before the failure
- After the failure
- After the fix.
Copy this file, lab7x to your home directory on opus.