Storage & Automated OS Install


Virtualizing storage

Utilizing storage more efficiently

Storage Snapshots


Logical Volume Manager

Components of LVM

Name Description
Physical Volume (PV) physical device (typically a hdd)
Volume Group (VG) Collection of PV's
Logical Volume (LV) Slice of a VG to create a partition
Physical Extent (PE) Chunks of data in a PV with the same size
Logical Extent (LE) Chunks of data in a LV with the same size

LVM Howto (a bit dated, but still relevant)

LVM Example

  1. Two disk partitions: sda1 (800MB) & sdb1 (400MB)
  2. Format each partition into a PV
  3. The PV's are divided up into 4MB chunks (PE): sda1 (200PE) / sdb1 (100PE)
  4. Create a VG using sda1 and sda2
  5. Create an LV of size 1GB (uses linear mapping by default)
  6. Total of 250 LE's are required
  7. 200PE's are used in sda1, 50PE's are used in sdb1, 50PE are free
  8. Create a filesystem from the LV and mount it
  9. PROFIT!

LVM Visualized


LVM commands

$ yum install lvm2

# Note: I created loop1/2 using dd and losetup
$ pvcreate /dev/loop0 /dev/loop1
  Physical volume "/dev/loop0" successfully created
  Physical volume "/dev/loop1" successfully created

$ vgcreate lvm /dev/loop0 /dev/loop1
  Volume group "lvm" successfully created

$ lvcreate -n home -L 1G lvm
  Logical volume "home" created

$ mkfs.ext4 /dev/lvm/home
$ mount /dev/lvm/home /mnt

LVM commands

All commands start with pv, vg or lv

pvchange   pvcreate   pvmove     pvresize   pvscan
pvck       pvdisplay  pvremove   pvs

vgcfgbackup    vgconvert      vgextend       vgmknodes      vgs
vgcfgrestore   vgcreate       vgimport       vgreduce       vgscan
vgchange       vgdisplay      vgimportclone  vgremove       vgsplit
vgck           vgexport       vgmerge        vgrename

lvchange     lvm          lvmdump      lvreduce     lvscan
lvconvert    lvmchange    lvmetad      lvremove
lvcreate     lvmconf      lvmpolld     lvrename
lvdisplay    lvmconfig    lvmsadc      lvresize
lvextend     lvmdiskscan  lvmsar       lvs

Useful tricks with LVM

Issues with LVM


Software (mdadm or LVM)


RAID Levels

Level Min disks Description
RAID0 2 Striping
RAID1 2 Mirroring
RAID5 3 Block-level striping with distributed parity
RAID6 4 Block-level striping with double distributed parity
RAID10 / RAID1+0 4 Striped set from a series of mirrored drives

Hot spares can automate rebuilds (i.e. RAID5+1 & RAID6+1)

RAID Issues

Automated Linux Installation

Typical Installation

What if...

Netboot / PXE

Netbooting in Action


Use cases for Netboot

Netboot install steps

  1. System start up, BIOS check
  2. Boot from network device (i.e. PXE)
  3. Gets an IP address and information on where the TFTP server is
  4. Grabs the initial boot image (i.e. pxelinux)
  5. PXELINUX downloads Linux kernel/initrd image and sends any kernel arguments

Anaconda / Kickstart

Anaconda is the installation program used by Redhat derivatives

Kickstart is the automation method to install Redhat machines

Kickstart Config File

Comprised of three sections

ks.cfg: Command configuration

lang en_US.UTF-8
keyboard us
network --bootproto=dhcp
rootpw cs312
firewall --disabled
selinux --permissive
timezone UTC
bootloader --location=mbr
clearpart --all --initlabel
auth --enableshadow --passalgo=sha512 --kickstart
firstboot --disabled
user --name=cs312 --plaintext --password cs312

ks.cfg: Package to installation/removal


ks.cfg: Arbitrary Shell Commands

%pre --interpreter /bin/bash
echo "This is run before the install phase begins"

%post --interpreter /bin/bash
echo "This is run in a chroot of the installed system"

Kickstart install steps

  1. System boots from PXELINUX with ks=<URL> set as a kernel argument.
  2. System boots up, tries to get an IP address and attempts to download the ks file using the URL above.
  3. Using the ks file, installs the systems. If the ks file doesn't answer all needed questions, installation will stop for user interaction.
  4. Install with finish and may reboot or shutdown depending on the ks file

DEMO Time!

Time to install CentOS with a Kickstart file!

Demo requirements

Boot using the ks.cfg

linux ks=

LVM and Kickstart

# Create /boot on sda1 with a 512MB size formatted as ext4
part /boot --fstype="ext4" --size=512

# Create a PV partition using the rest of the disk
# 100 implies 100% in this case instead of size in MB because --grow is
# specified
part pv.01 --grow --size=100

# Create a VG named lvm
volgroup lvm pv.01

# Create an LV named swap using the recommended size and format it
# as swap
logvol swap --vgname=lvm --name=swap --fstype="swap" --recommended

# Create a rootfs named root 20GB in size and format it as ext4
logvol / --vgname=lvm --name=root --fstype="ext4" --size=20480

Other useful ks features

# Set mirror for installation
url --url=

# Add updates repo too
repo --name=updates --baseurl=

# Setup the installer in a VNC session using a password
vnc --password=cs312

# Run misc commands after the OS install
%post --interpreter /bin/bash --log=/root/post-install.log
echo "%cs312 ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers

Exercise #1

Exercise #1 Video

Exercise #2

NOTE: You need to add noverifyssl to the ks line when using gists

Exercise #2 Video


Class Announcements