# Adding swapfile and building new AMI

**URL:** <https://forums.suse.com/t/adding-swapfile-and-building-new-ami/6864>\
**Category:** RancherOS\
**Created:** [July 14, 2017, 1:37pm UTC](https://forums.suse.com/t/adding-swapfile-and-building-new-ami/6864 "2017-07-14T13:37:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sra](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/sra/32/1514_2.png) [@sra](https://forums.suse.com/u/sra)\
**Post date:** [July 14, 2017, 1:37pm UTC](https://forums.suse.com/t/adding-swapfile-and-building-new-ami/6864/1 "2017-07-14T13:37:32Z")

</div>

I need to create a new AMI for (right now v1.0.3) of rancher OS in a few AWS regions. The AMI should be identical to the official but with a swapfile pre-allocated.

I can’t seem to find instructions for this process on the documentation site. The closest I’ve been able to come so far is to boot an existing instance of rancher and attach a volume as indicated in [this post](http://forums.suse.com/t/how-to-build-rancheros-amis/1672) but then use:

`ros install -c cloud-config.yml -d /dev/xvdf`

Unfortunately then the host reboots. Is there a toolchain that can be used outside of aws to do this? Is this the wrong approach?

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![sra](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/sra/32/1514_2.png) [@sra](https://forums.suse.com/u/sra)\
**Post date:** [July 18, 2017, 11:52am UTC](https://forums.suse.com/t/adding-swapfile-and-building-new-ami/6864/2 "2017-07-18T11:52:13Z")

</div>

Anyone got any ideas here?

---

<div class="post-metadata">

**Author:** ![sra](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/sra/32/1514_2.png) [@sra](https://forums.suse.com/u/sra)\
**Post date:** [July 27, 2017, 4:16pm UTC](https://forums.suse.com/t/adding-swapfile-and-building-new-ami/6864/3 "2017-07-27T16:16:51Z")

</div>

Hi @SvenDowideit would you be able to point me to any ami building tooling that you guys use so I can accomplish this, or suggest an alternative?

Thanks in advance

---

<div class="post-metadata">

**Author:** ![SvenDowideit](https://sea2.discourse-cdn.com/flex022/user_avatar/forums.suse.com/svendowideit/32/2159_2.png) [@SvenDowideit](https://forums.suse.com/u/SvenDowideit)\
**Post date:** [October 3, 2017, 2:11am UTC](https://forums.suse.com/t/adding-swapfile-and-building-new-ami/6864/4 "2017-10-03T02:11:32Z")

</div>

I use a script based cloud-init to format my disks and then install on initial startup - for example [https://github.com/SvenDowideit/bin-dir/blob/master/cloud-configs/airgap/install-bastion.sh](https://github.com/SvenDowideit/bin-dir/blob/master/cloud-configs/airgap/install-bastion.sh)

or conversely, you can use [https://github.com/rancher/os-packer](https://github.com/rancher/os-packer) to generate a custom AMI
