Merge "Better swap alignment"
This commit is contained in:
commit
5c08804102
@ -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…
x
Reference in New Issue
Block a user