dynamic partition size in a kickstart file
Firas Alshafei
Firas.Alshafei at ventyx.abb.com
Wed Jul 23 16:44:52 UTC 2014
Oguz,
I was doing something similar in my RHEL 5.8 kickstart.
In the pre-script I have a function that calculates swap space based on RAM available:
function func_dynamic_swap(){
# Determine the ammount of RAM available
mem_size_kb=`cat /proc/meminfo | grep MemTotal | awk '{print $2}'`
# Determing the amount of GB RAM - AWK is used to round up since meminfo doesn't provide accurate info
mem_size_gb=`awk -v MSZKB=$mem_size_kb 'BEGIN{printf("%.2f\n",(MSZKB/1024/1024))}' | awk '{printf("%d\n",$1+0.5)}'`
# Set swap value depending on RAM. If RAM is 16GB or
if [ $mem_size_gb -ge 16 ]; then
dyn_swap=$(( ( $mem_size_gb + 2 ) * 1024 ))
else
dyn_swap=$(( 16 * 1024 ))
fi
echo $dyn_swap
}
That should return the value I want. I then use it in another function to create the partitioning
# Set disk sizing values
sizeOverhead=200
sizeSwap=$(func_dynamic_swap)
sizeRoot=20480
sizeVar=5120
sizeUsers=39936
# Create boot partition
echo "part /boot --fstype ext4 --size $sizeBoot --asprimary --ondisk $disk1" >> /tmp/disk-config.ks
# Partition Disk1
echo "part pv.1 --size=1 --grow --ondisk $disk1" >> /tmp/disk-config.ks
# Create Volume Group
echo "volgroup VG1 --pesize $sizePeKB pv.1" >> /tmp/disk-config.ks
# Create logical volumes
echo "logvol swap --fstype swap --name lv_swap --vgname VG1 --size=$sizeSwap" >> /tmp/disk-config.ks
echo "logvol / --fstype ext4 --name lv_root --vgname VG1 --size=$sizeRoot " >> /tmp/disk-config.ks
echo "logvol /var --fstype ext4 --name lv_var --vgname VG1 --size=$sizeVar " >> /tmp/disk-config.ks
echo "logvol /usr/users --fstype ext4 --name lv_users --vgname VG1 --size=$sizeUsers " >> /tmp/disk-config.ks
and call that disk-config.ks file in your kickstart file
################################################################################
# DISK CONFIGURATION
################################################################################
#System bootloader configuration
bootloader --location=mbr
# Clear the Master Boot Record
zerombr
%include /tmp/abb-disk-config
Hope that helps :)
FIRAS ALSHAFEI
Lead Engineer
Email: firas.alshafei at ventyx.abb.com
(O) +1-281-274-5023
(M) +1-330-647-6477
VENTYX
An ABB Company
www.ventyx.com
1601 Industrial Blvd. | Sugar Land TX 77478 | U.S.A.
-----Original Message-----
From: kickstart-list-bounces at redhat.com [mailto:kickstart-list-bounces at redhat.com] On Behalf Of Oguz Yilmaz
Sent: Wednesday, July 23, 2014 6:13 AM
To: Discussion list about Kickstart
Subject: dynamic partition size in a kickstart file
Hello
I want to dynamically set tmpfs size acc.to the ram the server has in my kickstart. Is there a way for such dynamic value setting?
Best Regards,
--
Oguz YILMAZ
_______________________________________________
Kickstart-list mailing list
Kickstart-list at redhat.com
https://www.redhat.com/mailman/listinfo/kickstart-list
More information about the Kickstart-list
mailing list