Provision a Centos 7.9 virtual machine and provision additional disks for RAID configuration.
- Copy
.env.example
as.env
- Add/Update environment variables as needed
source .env
to load variables into the current session
Update Vagrantfile.yml to configure the VMs that will be created.
# bring the VM up
vagrant up
# connect via ssh
vagrant ssh centos7-raid
# stop the vm
vagrant halt
# delete the vm
vagrant destroy
Download the role and collection dependencies:
cd roles
ansible-galaxy install --roles-path . -r requirements.yml
ansible-galaxy collection install -r requirements.yml
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
# 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
# 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
For this to happen, we need to add an entry in /etc/fstab file
vim /etc/fstab
# LABEL=/data /data ext4 defaults 1 2
# list all the mounting with UUID
blkid
# list block devices
lsblk -f
Volume management creates a layer of abstraction over physical storage, allowing you to create logical storage volumes.
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.
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
- In LVM, a volume group is divided up into logical volumes.
yum reinstall lvm2
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
lvmdiskscan
pvdisplay
pvscan
pvs
vgcreate vg1 /dev/sdb /dev/sdc /dev/sdd /dev/sde
vgdisplay vg1
vgscan
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
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
To increase the size of a logical volume, use the lvextend command.
lvextend -l +100%FREE /dev/vg1/lv4
mkfs.xfs /dev/vg1/lv4
mount /dev/vg1/lv4 /mnt
df
- Configuring an LVM pool with RAID using the storage RHEL System Role
- Managing local storage using RHEL System Roles
- Simple Partitioning with Ansible Storage Role
- Introduction to Ansible for Linux System Roles
- linux-system-roles
- LVM Configuration Examples
- RHEL 7 - Storage Administration Guide
- RHEL 7 - Logical Volume Manager Administration
- RHEL 7 - RAID Logical Volumes
- Vagrant Box bento/centos-7.9
- Vagrant Disks Documentation
- Add Disk Storage to VirtualBox on Centos7
- Simple Partitioning with Ansible Storage Role – Storage APIs
- Ansible 2.8 User Guide
- Vagrant Advanced Examples
- Ansible tips and tricks | Sample Ansible setup | Sample directory layout
- Red Hat Enterprise Linux (RHEL) System Roles
- Logical Volume Manager (LVM) versus standard partitioning in Linux
- Ansible best practices: using project-local collections and roles
- Ansible Tower - Ansible Galaxy Support