#!/bin/bash
#
# $Id$
#
# The author disclaims all copyrights and releases this script into the
# public domain.
#
# Beta script to generate KickStart 'part' directives to setup disk
# configuration.
#
# http://sial.org/howto/kickstart/
# given amount of RAM in Megabytes, echos sizes of swap partitions
# needed by system to standard output
swap_sizes () {
TOTAL_RAM=$1
# has this limit been raised in 2.6 kernels? If so, could use the
# KickStart 'swap --recommended' syntax instead
MAX_SWAP_SIZE=2048
# research/server systems need 2x swap of RAM; less heavily used systems
# could get away with far less
SWAP_SPACE=$((TOTAL_RAM * 2))
if [ $SWAP_SPACE -lt $MAX_SWAP_SIZE ]; then
SWAP_SIZES=$SWAP_SPACE
else
COUNT=$((SWAP_SPACE / MAX_SWAP_SIZE))
while [ $COUNT -gt 0 ]; do
SWAP_SIZES=${SWAP_SIZES:+$SWAP_SIZES }$MAX_SWAP_SIZE
COUNT=$((COUNT-1))
done
fi
echo $SWAP_SIZES
}
#TOTAL_RAM=`free -m | grep ^Mem: | awk '{print $2}'`
SWAP_PART=1
TOTAL_SWAP=
for SIZE in `swap_sizes 2048`; do
echo logvol swap --fstype swap --name=swap$SWAP_PART --vgname=volgroup1 --size=$SIZE
SWAP_PART=$((SWAP_PART + 1))
TOTAL_SWAP=$((TOTAL_SWAP + SWAP_PART))
done
# TODO then take disk total, subtract off TOTAL_SWAP, space used for non-
# LVM partitions, and figure out how much disk we have left over...