Better swap alignment
We ran into this when fixing the zuul02 swap partition. Essentially parted complained that our alignments weren't optimal. After some googling the Internet said that using multiples of 8 tends to be safe. We shifted the offset from 1MB to 8MB to start the partition and the warnings went away. Add this change into make_swap.sh to automate this for future servers. Change-Id: Iad3ef40cf2c1e064482d49bd722c3de4354ec74d
This commit is contained in:
parent
51e3976273
commit
0d7c02f132
@ -24,8 +24,10 @@ if [ `grep SwapTotal /proc/meminfo | awk '{ print $2; }'` -eq 0 ]; then
|
||||
SWAPFILE=/swapfile
|
||||
MEMKB=`grep MemTotal /proc/meminfo | awk '{print $2; }'`
|
||||
# Use the nearest power of two in MB as the swap size.
|
||||
# We also shift by 8MB to start the partitions as apparently
|
||||
# parted and linux prefer things aligned on multiples of 8.
|
||||
# This ensures that the partitions below are aligned properly.
|
||||
MEM=`python3 -c "import math ; print(min(2**int(round(math.log($MEMKB/1024, 2))),8192))"`
|
||||
MEM=`python3 -c "import math ; print(min(2**int(round(math.log($MEMKB/1024, 2))),8192) + 8)"`
|
||||
|
||||
# Avoid using config drive device for swap
|
||||
if [ -n "$DEV" ] && ! blkid | grep $DEV | grep TYPE ; then
|
||||
@ -37,7 +39,7 @@ if [ `grep SwapTotal /proc/meminfo | awk '{ print $2; }'` -eq 0 ]; then
|
||||
|
||||
parted ${DEV} --script -- \
|
||||
mklabel msdos \
|
||||
mkpart primary linux-swap 1 ${MEM} \
|
||||
mkpart primary linux-swap 8 ${MEM} \
|
||||
mkpart primary ext2 ${MEM} -1
|
||||
sync
|
||||
# We are only interested in scanning $DEV, not all block devices
|
||||
|
Loading…
Reference in New Issue
Block a user