[Maas-devel] MAAS nodes and swap
Andreas Hasenack
andreas at canonical.com
Mon Nov 11 13:52:03 UTC 2013
On Mon, Nov 11, 2013 at 10:00 AM, Andreas Hasenack <andreas at canonical.com>wrote:
> Hi, thanks for the pointers.
>
> I'm looking at /etc/maas/preseeds, and some of those files are
> cloud-config files. In particular I see curtin_userdata, which seems to
> imply that I could add my swap setup script in there, and have it used by
> the fastpath installer (curtin).
>
> Attached is what I came up with for when using the fastpath installer. If
you have a second disk (vdb), it will use that as swap. Otherwise, it will
create a swap file image on /.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ubuntu.com/archives/maas-devel/attachments/20131111/d60b2721/attachment.html>
-------------- next part --------------
--- curtin_userdata.orig 2013-11-11 13:48:57.104917044 +0000
+++ curtin_userdata 2013-11-11 13:49:13.004917045 +0000
@@ -1,4 +1,21 @@
#cloud-config
+setupswap:
+ - &setup_swap |
+ if [ -e /dev/vdb ]; then
+ mkswap -f /dev/vdb -L swap
+ swapline="/dev/vdb none swap sw 0 0"
+ echo "Setting up swap on /dev/vdb"
+ elif [ ! -f $TARGET_MOUNT_POINT/swap.img ]; then
+ dd if=/dev/zero of=$TARGET_MOUNT_POINT/swap.img bs=100M count=10
+ mkswap $TARGET_MOUNT_POINT/swap.img
+ swapline="/swap.img none swap sw 0 0"
+ echo "Setting up swap on /swap.img"
+ fi
+ if [ -z "$swapline" ]; then
+ echo "Couldn't setup swap"
+ elif ! grep -q swap $TARGET_MOUNT_POINT/etc/fstab; then
+ echo "$swapline" >> $TARGET_MOUNT_POINT/etc/fstab
+ fi
debconf_selections:
maas: |
{{for line in str(curtin_preseed).splitlines()}}
@@ -6,6 +23,7 @@
{{endfor}}
late_commands:
maas: [wget, '--no-proxy', '{{node_disable_pxe_url|escape.shell}}', '--post-data', '{{node_disable_pxe_data|escape.shell}}', '-O', '/dev/null']
+ swap: [sh, -c, *setup_swap]
power_state:
mode: reboot
More information about the Maas-devel
mailing list