Disclaimer

This information HAS errors and is made available WITHOUT ANY WARRANTY OF ANY KIND and without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. It is not permissible to be read by anyone who has ever met a lawyer or attorney. Use is confined to Engineers with more than 370 course hours of engineering.
If you see an error contact:
+1(785) 841 3089
inform@xtronics.com

Make a raid with /home on it


Assumptions and Basics

Let's assunme the system is installed on a pair of SSD and you want home to be on a mirror raided pair of spinning drives. (You would install on to a raid of two SSD for a system raid. )

Basic command line

Below - anything that starts with "$" is a command to enter at the shell (AKA CLI ) Anything at the end of a command after a ";" is a comment. Find out more about a command by : $man command ; where command is the actual command name - man is short for manual. The command line has tab complete that helps guess the rest of a path or command name.


You will work from the command line as root. When you start the computer do not start the gui. If the gui screen comes up there is an option for console login - login as root.

Install tools

Install wajig - it makes installing easier - read more about wajig at:

Wajigl ; might be a bit out of date.
$ apt-get install wajig
$ wajig update ; update the list of package versions to the latest
$ wajig installrs wajig ; install with both the recommended and suggested packages besides the dependent packages
$ wajig install mdadm rsync parted sfdisk ; install two packages 
$ wajig distupgrade ; (get all the latest packages installed) 


Add drives to the system

While the computer is running - plug in the first spinning drive - next do:

$ tail /var/log/syslog ; tail prints out the last few lines of a file 

this will tell you which drive got plugged in - will look something like this:

Oct 12 20:21:05 malaysia kernel: [962350.746539] scsi 4:0:0:0: 
Direct-Access ATA Hitachi HDT72101 ST6O PQ: 0 ANSI: 5
Oct 12 20:21:05 malaysia kernel: [962350.747020] sd 4:0:0:0: [sde] 
1953525168 512-byte logical blocks: (1.00 TB/931 GiB)
Oct 12 20:21:05 malaysia kernel: [962350.747075] sd 4:0:0:0: [sde] Write
 Protect is off
Oct 12 20:21:05 malaysia kernel: [962350.747078] sd 4:0:0:0: [sde] Mode 
Sense: 00 3a 00 00
Oct 12 20:21:05 malaysia kernel: [962350.747095] sd 4:0:0:0: [sde] Write
 cache: enabled, read cache: enabled, doesn't support DPO or FUA
Oct 12 20:21:05 malaysia kernel: [962350.747226]  sde: sde1
Oct 12 20:21:05 malaysia kernel: [962350.761088] sd 4:0:0:0: [sde] 
Attached SCSI disk

From this I know the drive is /dev/sde

Below I will suppose you have two drives /dev/sde /dev/sdf (your drives will likely be different names ) with the two partitions you create on them /dev/sde1 /dev/sdf1

Partition Drives

IF the drives are less than 2T - use the sfdisk command to partition them. Other wise larger drives will need parted see see - using parted

$ sfdisk /dev/sde ; this tool lets you remove, edit, create partitions

delete any old partition -create a new partition - select linux raid as the type (FD)

Repeat with the second drive

The size of the partition needs to be >> exactly<< the same for both drives.

You should now have /dev/sde1 /dev/sdf1 - you can see them in the list of partitions by:

$cat /proc/partitions

Create the raid

$ mdadm -Cv /dev/md0 -l1 -n2 /dev/sde1 /dev/sdf1  ; this says to create a level1 Raid of 2 drives

(same as $mdadm --create /dev/md0 --level 1 --raid-devices=2 /dev/sde1 /dev/sdf1)


Where /dev/dm0 will be your raid device and /dev/sde1 and /dev/sdf1 are the partitions you created on /dev/sde and /dev/sdf


next check the raid by doing:

$ cat /proc/mdstat

Should look something like this after it syncs - you don't have to wait for it to sync:

Personalities : [raid1] 
md0 : active raid1 sde1[2] sdf1[1]
 2930262904 blocks super 1.2 [2/2] [UU]
 
unused devices: <none>

Update /etc/mdadm/mdadm.conf

$ /usr/share/mdadm/mkconf > /etc/mdadm/mdadm.conf


Make a file system

Make a files system on /dev/md0 - I would use jfs - you might want ext4 so as to be more standard.

$ mkfs.ext4 /dev/md0 ; puts a ext4 file system on raid md0

make a directory to mount the raid temporarily

$ mkdir /mnt ; we are creating a place to mount the drive

Mount the raid

Tell the system what type with the -t
$ mount /dev/md0 -t ext4 /mnt 


Copy /home over to the new raid

$ rsync -auHxv /home /mnt/ ; after it is finished you can 
$ls /mnt  ; and you should see the home directory.

Now we tell the system to use the new raid for home

edit /etc/fstab

$ pico /etc/fstab

Don't remove anything - add one line:

/dev/md5 /home ext4 defaults 0 0

Now reboot and all should be good.

After rebooting you can look at :

$cat /proc/mdstat ; see the state of the raid - it will probably still be syncing.. 
$ mount ; will show what is mounted


I have notes on partitioning bigger drives for the latest BIOS's here:

Growing_Partitions_and_file_systems#using_parted

More notes on doing raid stuff - sort of out of date - here:

Raid


Top Page wiki Index