2022-10-11 09:32 PM - edited 2022-10-11 09:42 PM
# This is a bash script to automate partitioning with Logical Volume Manager (LVM) on a new NetWitness Packet Hybrid VM.
# These default parameters are supposed to allow for 30 days of Raw capture (packets), and 90 days of meta,
# based on the NW Virtual Hybrid Sizing Calculator, when traffic rates average 2 Mbps, or around 20 GB/day
# Retention: 2Mbps or 20GB/day - 30 days Raw/90 days Meta - Add 4 hard drives, 99G, 5G, 20G, 600G
# Adjust according to retention requirements using NW Virtual Hybrid Sizing Calculator v1.0.xlsx
# Alternative configurations for packetdb drive can be halved/quartered (300G/150G) drive, for Raw retention of 15 days/7 days
# Retention: 2Mbps/20GB/day - 15 days Raw / 90 days Meta - Add 4 hard drives. 99G, 5G, 20G, 300G
# Retention: 2Mbps/20GB/day - 7 days Raw / 90 days Meta - Add 4 hard drives. 99G, 5G, 20G, 150G
# To customize for other environments use the NW Virtual Hybrid Sizing Calculator v1.0.xlsx
# Instructions
# After fresh iso is installed, paste this text into new file called nwhybridlvm, or copy this file to the hybrid
# chmod +x nwhybridlvm
# ./nwhybridlvm
#!/bin/bash
# terminate on errors - was used to test the script
# set -e
# pvcreate - the files system names must be changed to coincide with the
# volumes mounted by your system
pvcreate /dev/sdb
sleep 1
pvcreate /dev/sdc
sleep 1
pvcreate /dev/sdd
sleep 1
pvcreate /dev/sde
sleep 1
# vgcreate
# this script builds a volume group with a single physical volume.
vgcreate concentrator /dev/sdb
sleep 1
vgcreate index /dev/sdc
sleep 1
vgcreate decodersmall /dev/sdd
sleep 1
vgcreate decoder /dev/sde
sleep 1
# lvcreate
# create logical volumes
lvcreate -L 5G -n decoroot decodersmall
sleep 1
lvcreate -L 5G -n decosess decodersmall
sleep 1
lvcreate -L 5G -n decoinde decodersmall
sleep 1
lvcreate -l 100%FREE -n decometa decodersmall
sleep 1
lvcreate -l 100%FREE -n decopack decoder
sleep 1
lvcreate -L 5G -n concroot concentrator
sleep 1
lvcreate -L 4G -n concsess concentrator
sleep 1
lvcreate -l 100%FREE -n concmeta concentrator
sleep 1
lvcreate -l 100%FREE -n concinde index
sleep 1
# mkfs
mkfs.xfs /dev/decodersmall/decoroot
sleep 1
mkfs.xfs /dev/decodersmall/decoinde
sleep 1
mkfs.xfs /dev/decodersmall/decosess
sleep 1
mkfs.xfs /dev/decodersmall/decometa
sleep 1
mkfs.xfs /dev/decoder/decopack
sleep 1
mkfs.xfs /dev/concentrator/concroot
sleep 1
mkfs.xfs /dev/concentrator/concsess
sleep 1
mkfs.xfs /dev/concentrator/concmeta
sleep 1
mkfs.xfs /dev/index/concinde
sleep 1
# mount
mkdir /var/netwitness/decoder
sleep 1
mount /dev/mapper/decodersmall-decoroot /var/netwitness/decoder
sleep 1
mkdir /var/netwitness/concentrator
sleep 1
mount /dev/mapper/concentrator-concroot /var/netwitness/concentrator
sleep 1
mkdir /var/netwitness/decoder/sessiondb
sleep 1
mkdir /var/netwitness/decoder/packetdb
sleep 1
mkdir /var/netwitness/decoder/index
sleep 1
mkdir /var/netwitness/decoder/metadb
sleep 1
mkdir /var/netwitness/concentrator/metadb
sleep 1
mkdir /var/netwitness/concentrator/sessiondb
sleep 1
mkdir /var/netwitness/concentrator/index
sleep 1
mount /dev/mapper/decodersmall-decosess /var/netwitness/decoder/sessiondb
sleep 1
mount /dev/mapper/decoder-decopack /var/netwitness/decoder/packetdb
sleep 1
mount /dev/mapper/decodersmall-decoinde /var/netwitness/decoder/index
sleep 1
mount /dev/mapper/decodersmall-decometa /var/netwitness/decoder/metadb
sleep 1
mount /dev/mapper/concentrator-concsess /var/netwitness/concentrator/sessiondb
sleep 1
mount /dev/mapper/concentrator-concmeta /var/netwitness/concentrator/metadb
sleep 1
mount /dev/mapper/index-concinde /var/netwitness/concentrator/index
# SE Linux relabeled - turns out isn't needed
# restorecon -R /
# sleep 10
# Edit fstab
cp -p /etc/fstab /etc/fstab.bak
echo "/dev/mapper/decodersmall-decoroot /var/netwitness/decoder xfs noatime,nosuid 1 2" >> /etc/fstab
echo "/dev/mapper/decodersmall-decosess /var/netwitness/decoder/sessiondb xfs noatime,nosuid 1 2" >> /etc/fstab
echo "/dev/mapper/decoder-decopack /var/netwitness/decoder/packetdb xfs noatime,nosuid 1 2" >> /etc/fstab
echo "/dev/mapper/decodersmall-decoinde /var/netwitness/decoder/index xfs noatime,nosuid 1 2" >> /etc/fstab
echo "/dev/mapper/decodersmall-decometa /var/netwitness/decoder/metadb xfs noatime,nosuid 1 2" >> /etc/fstab
echo "/dev/mapper/concentrator-concroot /var/netwitness/concentrator xfs noatime,nosuid 1 2" >> /etc/fstab
echo "/dev/mapper/concentrator-concsess /var/netwitness/concentrator/sessiondb xfs noatime,nosuid 1 2" >> /etc/fstab
echo "/dev/mapper/concentrator-concmeta /var/netwitness/concentrator/metadb xfs noatime,nosuid 1 2" >> /etc/fstab
echo "/dev/mapper/index-concinde /var/netwitness/concentrator/index xfs noatime,nosuid 1 2" >> /etc/fstab
diff /etc/fstab /etc/fstab.bak