Comment 5 for bug 499522

Revision history for this message
Scott Moser (smoser) wrote : Re: [Bug 499522] Re: swap turned off

On Tue, 26 Jan 2010, Eric Hammond wrote:

> Hi, it's me (again) trying to make sure that power users have the
> ability to control what they want (again).
>
> Is there a document or can you point me to code where the swap is
> automatically turned on?

line 288 at
http://bazaar.launchpad.net/%7Esmoser/ec2-init/ec2-init.devel/annotate/head%3A/ec2init/__init__.py
defines enable_swap()

it tries to get information from the datasource (the metadata service). if
that fails, it uses 'blkid' to identify everything that it thinks is swap.
In ec2, the metadata service shouldn't ever fail.

> I'd like to be able to turn off swap in my /etc/fstab in my AMI and not
> have ec2-init override this.
>
> If necessary, I suppose I can turn off swap again later, but I get
> uncomfortable when the ec2-init keeps changing things out from under me
> after I have set them in my image (like it currently does with
> /etc/apt/sources.list).

I could make a user data option for this, but I think its easy enough to
make a user script do 'swapoff -a', or more permenantly:
   sed -i 's,\(.*swap.*\),#\1,' /etc/fstab

The code to enable swap runs only once per instance.

Note, that as it is in our images, this is the same behavior as before.
On i386 you get swap, on amd64 you don't (per the meta-data service).

ie, the metadata service says:
 'block-device-mapping': {'ami': 'sda1',
                          'ephemeral0': 'sda2',
                          'root': '/dev/sda1',
                          'swap': 'sda3'},

ec2-init is just respecting that.