howto_manually_create_raid1

Version / Revision: V1.0 / R1
For: Nethserver 6/7

Skill: Advanced Users
Published: 2017-01-19
Review: -

Contact: Nethserver community forum, Giacomo

Description

Manually create a RAID1 on two disks and mount the raid to /var/lib/nethserver With this configuration you an can create a server with this disks layout:

- 2 fast and small disks for the OS - 2 bigger (and possibly slower) disks for data

Disks layout

Let's assume the system is configured ad follow:

- 4 disks: sda, sdb, sdc and sdd - sda and sdb are the disks containing the OS - md1 is the RAID 1 on sda1 and sdb1 for the boot partition - md2 is the RAID 1 on sda2 and sdb2 for the root partition

You can list all disks using this command:

fdisk -l

You can list all configured software raid using this command:

cat /proc/mdstat

We are going to create a new md3 raid on sdc1 and sdb1.

Install required packages

Login to shell using with root, then install parted:

yum -y install parted

Create disks partitions

Create the partition:

parted -s -a optimal /dev/sdc mklabel gpt
parted -s -a optimal /dev/sdc mkpart primary 0% 100%

parted -s -a optimal /dev/sdd mklabel gpt
parted -s -a optimal /dev/sdd mkpart primary 0% 100%

Create RAID 1

Create the RAID on sdc1 and sdd1, execute:

mdadm --create --verbose /dev/md3 --level=1 --raid-devices=2 /dev/sdc1 /dev/sdd1

The system will output something like this:

mdadm: Note: this array has metadata at the start and
    may not be suitable as a boot device.  If you plan to
    store '/boot' on this device please ensure that
    your boot-loader understands md/v1.x metadata, or use
    --metadata=0.90
mdadm: size set to 975452160K
mdadm: automatically enabling write-intent bitmap on large array
Continue creating array? y

Answer y to the question, then the system will proceed to start the new array.

Create the filesystem

You can now create the filesystem on the md3 device:

mkfs.xfs /dev/md3 

Copy existing data

Mount the disk on a temporary directory:

mkdir -p /tmp/data
mount /dev/md3 /tmp/data

Copy existing files using rsync, then unmount the temporary mount point:

rsync -avr /var/lib/nethserver/ /tmp/data/
umount /tmp/data

Configure the system for automount

Save mdadm configuration:

mdadm --detail --scan > /etc/mdadm.conf

Add the new partition to fstab:

echo -e "/dev/md3\t/var/lib/nethserver\txfs\tdefaults\t0 0" >> /etc/fstab

Try to mount it automatically:

mount -a

Done!

Enjoy your NethServer installation.