/vm-raid-lab

Setting up and configuring RAID disks

Primary LanguagePython

vm-raid-lab

Provision a Centos 7.9 virtual machine and provision additional disks for RAID configuration.

Getting Started

Create .env file

  1. Copy .env.example as .env
  2. Add/Update environment variables as needed
  3. source .env to load variables into the current session

Configure VMs

Update Vagrantfile.yml to configure the VMs that will be created.

Starting and Stopping the VM

# bring the VM up
vagrant up

# connect via ssh
vagrant ssh centos7-raid

# stop the vm
vagrant halt

# delete the vm
vagrant destroy

Downloading dependencies

Download the role and collection dependencies:

cd roles
ansible-galaxy install --roles-path . -r requirements.yml
ansible-galaxy collection install -r requirements.yml

Running the Ansible Playbook

To execute the playbook to configure the VM execute the following:

# run the playbook against a specific vm
ansible-playbook playbook.yml --limit centos7-raid

Standard Partitioning

Partition a drive and create a file system

# list devices
ls /dev/sd*

# partition with fdisk
fdisk /dev/sdb

# list devices
ls /dev/sd*

# create a file system
# /sbin/mkfs.ext4 -L /data /dev/sdb1

Mount the filesystem

# create a directory for the mounting
mkdir /data

# mount the drive to the created directory
mount /dev/sdb1 /data

# show all the current mounted systems
mount

Mount the filesystem automatically

For this to happen, we need to add an entry in /etc/fstab file

vim /etc/fstab
# LABEL=/data     /data   ext4    defaults        1       2

Check mounting

# list all the mounting with UUID
blkid

# list block devices
lsblk -f

Logical Volumes

Volume management creates a layer of abstraction over physical storage, allowing you to create logical storage volumes.

LVM Architecture

The underlying physical storage unit of an LVM logical volume is a block device such as a partition or whole disk. This device is initialized as an LVM physical volume (PV).

To create an LVM logical volume, the physical volumes are combined into a volume group (VG). This creates a pool of disk space out of which LVM logical volumes (LVs) can be allocated.

LVM Logical Volume Components

LVM Components

Describes the components of an LVM Logical volume.

  • Physical Volumes
    • The underlying physical storage unit of an LVM logical volume is a block device such as a partition or whole disk. To use the device for an LVM logical volume, the device must be initialized as a physical volume (PV). Initializing a block device as a physical volume places a label near the start of the device.
  • Volume Groups
    • Physical volumes are combined into volume groups (VGs). This creates a pool of disk space out of which logical volumes can be allocated.
  • Logical Volumes
    • In LVM, a volume group is divided up into logical volumes.
      • Linear Volumes
      • Striped Logical Volumes
      • RAID Logical Volumes
      • Thinly-Provisioned Logical Volumes (Thin Volumes)
      • Snapshot Volumes
      • Thinly-Provisioned Snapshot Volumes
      • Cache Volumes

Install the lvm packages

yum reinstall lvm2

Initializing Physical Volumes

Use the pvcreate command to initialize a block device to be used as a physical volume. Initialization is analogous to formatting a file system.

pvcreate /dev/sdb  /dev/sdc  /dev/sdd  /dev/sde

Scanning for Block Devices

lvmdiskscan

Displaying Physical Volumes

pvdisplay
pvscan
pvs

Creating Volume Groups

vgcreate vg1 /dev/sdb  /dev/sdc  /dev/sdd  /dev/sde
vgdisplay vg1
vgscan

RAID Logical Volumes

LVM supports RAID0/1/4/5/6/10

# 2-Way RAID1
lvcreate --type raid1 -m 1 -L 1G -n lv1 vg1

# RAID5 array (3 stripes + 1 implicit parity drive)
lvcreate --type raid5 -i 3 -L 1G -n lv2 vg1

# RAID6 array (3 stripes + 2 implicit parity drives)
lvcreate --type raid6 -i 3 -L 1G -n lv3 vg1

# 2-way RAID10 array with 3 stripes that is 10 gigabytes in size with a maximum recovery rate of 128 kiB/sec/device
lvcreate --type raid10 -i 2 -m 1 -L 9G --maxrecoveryrate 128 -n lv4 vg1

Displaying Logical Volumes

There are three commands you can use to display properties of LVM logical volumes: lvs , lvdisplay , and lvscan .

lvs
lvdisplay -v /dev/vg1/lv4
lvscan

Growing Logical Volumes

To increase the size of a logical volume, use the lvextend command.

lvextend -l +100%FREE /dev/vg1/lv4

Creating an XFS File System

mkfs.xfs /dev/vg1/lv4

Mount Logical Volume

mount /dev/vg1/lv4 /mnt
df

Resources