Files
scylladb/dist/common/scripts/scylla_bootparam_setup
Takuya ASADA 36e831a106 dist/common/scripts/scylla_bootparam_setup: support EC2 paravirtual instances
EC2 paravirtual instances uses pv-grub, which refers /boot/grub/menu.lst (grub0.9x config file) instead of grub2 config file.
So add boot parameters on /boot/grub/menu.lst when the file exists, and the instance is on EC2.

Fixes #1598

Signed-off-by: Takuya ASADA <syuu@scylladb.com>
Message-Id: <1472056875-17512-1-git-send-email-syuu@scylladb.com>
2016-10-27 18:55:05 +03:00

72 lines
2.2 KiB
Bash
Executable File

#!/bin/bash -e
#
# Copyright (C) 2015 ScyllaDB
print_usage() {
echo "scylla_bootparam_setup --ami"
echo " --ami setup AMI instance"
exit 1
}
is_ec2() {
if [ -f /sys/hypervisor/uuid ] && [ "$(head -c 3 /sys/hypervisor/uuid)" = "ec2" ]; then
echo 1
else
echo 0
fi
}
AMI_OPT=0
while [ $# -gt 0 ]; do
case "$1" in
"--ami")
AMI_OPT=1
shift 1
;;
*)
print_usage
;;
esac
done
. /etc/os-release
if [ "$ID" = "ubuntu" ]; then
. /etc/default/scylla-server
else
. /etc/sysconfig/scylla-server
fi
if [ ! -e /etc/default/grub ] && [ ! -e /boot/grub/menu.lst ]; then
echo "Unsupported bootloader"
exit 1
fi
if [ -e /etc/default/grub ]; then
if [ "`grep hugepagesz /etc/default/grub`" != "" ] || [ "`grep hugepages /etc/default/grub`" != "" ]; then
sed -e "s#hugepagesz=2M ##" /etc/default/grub > /tmp/grub
mv /tmp/grub /etc/default/grub
sed -e "s#hugepages=[0-9]* ##" /etc/default/grub > /tmp/grub
mv /tmp/grub /etc/default/grub
fi
if [ $AMI_OPT -eq 1 ]; then
sed -e "s#^GRUB_CMDLINE_LINUX=\"#GRUB_CMDLINE_LINUX=\"clocksource=tsc tsc=reliable hugepagesz=2M hugepages=$NR_HUGEPAGES #" /etc/default/grub > /tmp/grub
else
sed -e "s#^GRUB_CMDLINE_LINUX=\"#GRUB_CMDLINE_LINUX=\"hugepagesz=2M hugepages=$NR_HUGEPAGES #" /etc/default/grub > /tmp/grub
fi
mv /tmp/grub /etc/default/grub
if [ "$ID" = "ubuntu" ] || [ "$ID" = "debian" ]; then
update-grub
else
grub2-mkconfig -o /boot/grub2/grub.cfg
fi
fi
if [ `is_ec2` -eq 1 ] && [ -e /boot/grub/menu.lst ]; then
if [ "`grep hugepagesz /boot/grub/menu.lst`" != "" ] || [ "`grep hugepages /boot/grub/menu.lst`" != "" ]; then
sed -e "s#hugepagesz=2M ##" /boot/grub/menu.lst > /tmp/menu.lst
mv /tmp/menu.lst /boot/grub/menu.lst
sed -e "s#hugepages=[0-9]* ##" /boot/grub/menu.lst > /tmp/menu.lst
mv /tmp/menu.lst /boot/grub/menu.lst
fi
sed -e "s#^kernel\\(.*\\)#kernel\\1 hugepagesz=2M hugepages=$NR_HUGEPAGES #" /boot/grub/menu.lst > /tmp/menu.lst
mv /tmp/menu.lst /boot/grub/menu.lst
fi