Although we cover effects relationships in other places, it is worthwhile revisiting it again. Normally, once a value is worked out for a variable it is not reevaluated again. Effects relationships set relationships between values, so when one changes the other is forced to be reevaluated. The effects relationships below cause _hp_pri_swap to be reevaluated whenever the size of the root disk changes, or when the disk layout is changed.

#The next two statements are used only to establish an effects

#relationship between the _hp_pri_swap variable and _hp_root_disk &

#_hp_disk_layout variables. The value is overwritten below.

#This makes the UI change the swap anytime either of these two

#values change.

init _hp_pri_swap = disk[_hp_root_disk].size init _hp_pri_swap = _hp_disk_layout

Now we have a sanity check based on the size of the root disk. If it is less than 9GB, and primary swap is more than 1GB, and it is the only disk in the root volume or disk group, an error will be given that will force you to change the size of primary swap to be 1GB or less. Note that lgnite-UX won’t set primary swap to more than 1GB under these circumstances - this sanity check is here to prevent it from being set manually.

#Recognize swap size being set too large for the root volume config. ( disk[_hp_root_disk].size < 9000MB & _hp_pri_swap > 1GB & _hp_root_grp_disks == 1 ) {

error+="Primary swap size is too large for root disk. Reduce primary swap size to 1GB, add disks to root volume / disk group, or use a larger disk."

}

Here we set the size of primary swap. Primary swap is sized this way because on lower memory configurations you are more likely to allocate or use device swap, so more swap is required compared to the size of memory. Ignite limits the size of primary swap to 8GB.

#Start with 2x or cap on swap based on memory size ( memory < 4GB ) {

init _hp_pri_swap = (((memory * 2) + 65535KB)/64MB)*64MB

}

( memory >= 4GB ) {

init _hp_pri_swap = 8GB

}

In this section we adjust the size of primary swap for a small root disk. If you only have one disk in the root volume or disk group, and it is less than 9GB in size, primary swap will be set to 1GB. The second part of the configuration checks if the size of the root disk is between 9G and 18GB. Then, if the size of memory is greater than or equal to 4GB, primary swap will be set to 4GB. Otherwise it will be set to 2GB.

# Adjust swap size to deal with small disks.

( disk[_hp_root_disk].size < 9000MB & _hp_root_grp_disks == 1 ) { init _hp_pri_swap = 1GB

}

( disk[_hp_root_disk].size >= 9000MB & disk[_hp_root_disk].size < 18000MB ) { ( memory >= 4GB ) {

init _hp_pri_swap = 4GB } else {

init _hp_pri_swap = 2GB

70