This will cover installation and administrating RAID devices
Configuring RAID devices
Partitioning
Partitioning
Installed gparted which helps with the alignment. There is drop down menu for alignment.
sudo apt-get install gparted
sudo parted -a optimal /dev/sdb mklabel gpt
sudo parted -a optimal /dev/sdb mkpart primary 1 -1
Check the partition alignment
sudo parted /dev/sdb align-check opt 1
mdadm configuration
Make sure that the mdadm commands are installed
sudo apt-get install -y mdadm
Now create the md device
Chunk Size – How much is written at one time. default 64KB, 128KB, happy medium, larger if only containing large files.
sudo mdadm --create --verbose /dev/md0 --level=5 --chunk=64 --raid-devices=4 /dev/sdc1 /dev/sdd1 /dev/sdg1 /dev/sdh1
sudo mdadm --create --verbose /dev/md1 --level=5 --chunk=64 --raid-devices=4 /dev/sde1 /dev/sdf1 /dev/sdi1 /dev/sdj1
sudo mdadm --create --verbose /dev/md1 --level=5 --chunk=512 --raid-devices=4 /dev/sdd1 /dev/sde1 /dev/sdh1 /dev/sdi1
sudo mdadm --create --verbose /dev/md0 --level=5 --chunk=64 --raid-devices=4 --metadata=1.2 /dev/scd1 /dev/sdd1 /dev/sdg1 /dev/sdh1
sudo mdadm --create --verbose /dev/md1 --level=5 --chunk=64 --raid-devices=4 --metadata=1.2 /dev/sde1 /dev/sdf1 /dev/sdi1 /dev/sdj1
You can watch the array being constructed by looking at /proc/mdstat
sudo watch cat /proc/mdstat
Create the filesystem
# chunk size = 64kB (see chunk size advise above)
# block size = 4kB (recommended for large files, and most of time)
# stride = chunk / block in this example 64kB / 4k = 16
# stripe-width = stride * ( (n disks in raid5) – 1 ) this example: 16 * ( (3) – 1 ) = 48
sudo mkfs.ext4 /dev/md0 -b 4096 -E stride=16,stripe-width=48 -m 0
sudo mkfs.ext4 /dev/md1 -b 4096 -E stride=16,stripe-width=48 -m 0
sudo mkfs.ext4 /dev/md1 -b 4096 -E stride=128,stripe-width=384 -m 0
sudo mkfs.ext4 /dev/vg00/apps -b 4096 -E stride=16,stripe-width=48 -m 0
sudo mkfs.ext4 /dev/vg00/home -b 4096 -E stride=16,stripe-width=48 -m 0
sudo mkfs.ext4 /dev/vg00/backup -b 4096 -E stride=16,stripe-width=48 -m 0
sudo mkfs.ext4 /dev/vg00/films -b 4096 -E stride=16,stripe-width=48 -m 0
sudo mkfs.ext4 /dev/vg00/tv -b 4096 -E stride=16,stripe-width=48 -m 0
sudo mkfs.ext4 /dev/vg00/vmachines -b 4096 -E stride=16,stripe-width=48 -m 0
sudo mkfs.ext4 /dev/vg00/library -b 4096 -E stride=16,stripe-width=48 -m 0
sudo mkfs.ext4 /dev/vg00/music -b 4096 -E stride=16,stripe-width=48 -m 0
sudo mkfs.ext4 /dev/vg00/software -b 4096 -E stride=16,stripe-width=48 -m 0
sudo mkfs.ext4 /dev/vg00/mirrors -b 4096 -E stride=16,stripe-width=48 -m 0
sudo mkfs.ext4 /dev/vg00/inbox -b 4096 -E stride=16,stripe-width=48 -m 0
sudo mkfs.ext4 /dev/vg00/overflow -b 4096 -m 0
Add the devices to mdadm.conf
sudo mdadm --detail --scan
mdadm: metadata format 00.90 unknown, ignored.
ARRAY /dev/md0 level=raid5 num-devices=4 metadata=00.90 UUID=88f78c9f:6bdbb9fd:a9fc308a:72465bea
sudo vi /etc/mdadm/mdadm.conf
....
ARRAY /dev/md0 level=raid5 num-devices=4 metadata=00.90 UUID=88f78c9f:6bdbb9fd:a9fc308a:72465bea
ARRAY /dev/md0 level=raid5 num-devices=4 metadata=00.90 UUID=2ee693a8:9d216541:3cae24c4:a253f63b
Remove an array
sudo mdadm --manage --stop /dev/md0
LVM Configuration
sudo apt-get -y install lvm2
Overview
* Create a Physical Volume on the md device (can create multiple PV to span multiple disks)
* Create a Volume Group in the physical volume
* Create multiple logical volumes in the volume group
* Create a file system in each of the logical volumes
Physical Volumes
View available disks
lvmdiskscan
–metadatatype 2 = use the newer version 2 meta-data format
–dataalignment 128K = Maybe not needed any more?
pvcreate --metadatasize 2048k /dev/md0
pvcreate --metadatasize 2048k /dev/md1
pvdisplay
pvscan
Volume Groups
sudo vgcreate vg00 /dev/md0 /dev/md1 /dev/sdb1
sudo vgdisplay vg00
sudo vgcreate vg01 /dev/md1
sudo vgdisplay vg01
sudo vgs
sudo vgscan
Logical Volumes
Create a mirror
sudo lvcreate -L 300G -m1 -n apps vg00 /dev/md0 /dev/md1 /dev/sdb1
sudo lvcreate -L 500G -m1 -n home vg00 /dev/md0 /dev/md1 /dev/sdb1
sudo lvcreate -L 100G -m1 -n backup vg00 /dev/md0 /dev/md1 /dev/sdb1
Specify the undelying device to go on
sudo lvcreate -L 5500G -n films vg00 /dev/md0
sudo lvcreate -L 4500g -n tv vg00 /dev/md0
sudo lvcreate -L 500G -n vmachines vg00 /dev/md1
sudo lvcreate -L 400G -n library vg00 /dev/md1
sudo lvcreate -L 1000G -n music vg00 /dev/md1
sudo lvcreate -L 600G -n software vg00 /dev/md1
sudo lvcreate -L 900G -n mirrors vg00 /dev/md1
sudo lvcreate -L 100G -n inbox vg00 /dev/md1
sudo lvcreate -L 450G -n overflow vg00 /dev/sdb1
View the results
sudo lvdisplay -v /dev/vg00/tv
sudo lvscan
sudo lvs -a -o +devices
Mount the file systems
sudo vi /etc/fstab
/dev/vg00/apps /media/apps ext4 rw,noatime,errors=remount-ro 0 1
/dev/vg00/home /media/home ext4 rw,noatime,errors=remount-ro 0 1
/dev/vg00/backup /media/backup ext4 rw,noatime,errors=remount-ro 0 1
/dev/vg00/films /media/films ext4 rw,noatime,errors=remount-ro 0 1
/dev/vg00/tv /media/tv ext4 rw,noatime,errors=remount-ro 0 1
/dev/vg00/vmachines /media/vmachines ext4 rw,noatime,errors=remount-ro 0 1
/dev/vg00/library /media/library ext4 rw,noatime,errors=remount-ro 0 1
/dev/vg00/music /media/music ext4 rw,noatime,errors=remount-ro 0 1
/dev/vg00/software /media/software ext4 rw,noatime,errors=remount-ro 0 1
/dev/vg00/mirrors /media/mirrors ext4 rw,noatime,errors=remount-ro 0 1
/dev/vg00/inbox /media/inbox ext4 rw,noatime,errors=remount-ro 0 1
Repairing
Partition the device
The first command copies the partition table of sda to sdb (be careful not to mix these up). The second command randomizes the GUID on the disk and all the partitions. This is only necessary if the disks are to be used in the same machine, otherwise it’s unnecessary.
sudo apt-get install gdisk
sudo sgdisk -R=/dev/sdb /dev/sda
sudo sgdisk -G /dev/sdb
Now add the device into the array
sudo mdadm --add /dev/md0 /dev/sdd1
watch cat /proc/mdstat
References
Tuning EXT4
RAID using mdadm
RAID 5 with mdadm
Linux Home networking: Creating RAID
Partitioning and RAID
Ubuntu Desktop LVM
Redhat LVM documentation
Howto Easily Setup RAID 5 with LVM
RAID and LVM
LVM on RAID
Testing Ubuntu LVM Alignment
LVM Cheat Sheet