Run restrict-memory element later in image build

Since grub isn't installed by DIB until finalise.d/51 we need to
make sure the restrict-memory element happens after that, so it can
find and alter the grub configs accordingly.

Also make it apply the updated configuration, similar to how
nodepool/scripts/restrict_memory.sh does it.

Change-Id: I854f3bd1850594811cc8957f7a9263c33dfe6826
This commit is contained in:
Jeremy Stanley 2015-02-23 19:27:41 +00:00
parent d5390c0072
commit a2551dfef6

View File

@ -25,7 +25,13 @@ set -e
# cpu resources can be used without the risk of becoming dependent on more
# memory.
if [ -f /etc/default/grub ] ; then
sed -i -e 's/^GRUB_TIMEOUT=[0-9]\+/GRUB_TIMEOUT=0/' -e 's/#\?GRUB_CMDLINE_LINUX=""/GRUB_CMDLINE_LINUX="mem=8G"/g' /etc/default/grub
sed -i -e 's/^GRUB_TIMEOUT=[0-9]\+/GRUB_TIMEOUT=0/' -e 's/#\?GRUB_CMDLINE_LINUX="/GRUB_CMDLINE_LINUX="mem=8G /g' /etc/default/grub
if which update-grub &> /dev/null ; then
update-grub
else
# If update-grub isn't available, use grub2-mkconfig directly
/usr/sbin/grub2-mkconfig -o /boot/grub2/grub.cfg
fi
elif [ -f /boot/grub/grub.conf ] ; then
sed -i -e 's/^timeout=[0-9]\+/timeout=0/' -e 's/\(^\s\+kernel.*\)/\1 mem=8G/' /boot/grub/grub.conf
fi