# Disable swap on Linux?

**URL:** <https://discuss.elastic.co/t/disable-swap-on-linux/283266>\
**Category:** Elasticsearch\
**Created:** [September 3, 2021, 10:05am UTC](https://discuss.elastic.co/t/disable-swap-on-linux/283266 "2021-09-03T10:05:33Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![riahc3](https://avatars.discourse-cdn.com/v4/letter/r/d6d6ee/32.png) [@riahc3](https://discuss.elastic.co/u/riahc3)\
**Post date:** [September 3, 2021, 10:05am UTC](https://discuss.elastic.co/t/disable-swap-on-linux/283266/1 "2021-09-03T10:05:34Z")

</div>

Hello

Reading this [Disable swapping | Elasticsearch Guide [master] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/master/setup-configuration-memory.html) it seems the general advice is to disable swap completely....That being said, I have Elastic, Logstash and Kibana all installed on the same server.

Is it still a good idea to disable it?

Thank you

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [September 5, 2021, 10:17pm UTC](https://discuss.elastic.co/t/disable-swap-on-linux/283266/2 "2021-09-05T22:17:20Z")

</div>

Yep, still do it for Elasticsearch.

---

<div class="post-metadata">

**Author:** ![riahc3](https://avatars.discourse-cdn.com/v4/letter/r/d6d6ee/32.png) [@riahc3](https://discuss.elastic.co/u/riahc3)\
**Post date:** [September 6, 2021, 7:22am UTC](https://discuss.elastic.co/t/disable-swap-on-linux/283266/3 "2021-09-06T07:22:17Z")

</div>

I was gonna disable it system wide.

I ask this since you said "still do it for Elasticsearch"

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [September 6, 2021, 11:08pm UTC](https://discuss.elastic.co/t/disable-swap-on-linux/283266/4 "2021-09-06T23:08:02Z")

</div>

Yes that's what I mean, do it system wide, because Elasticsearch will be better off with it off.

---

<div class="post-metadata">

**Author:** ![riahc3](https://avatars.discourse-cdn.com/v4/letter/r/d6d6ee/32.png) [@riahc3](https://discuss.elastic.co/u/riahc3)\
**Post date:** [September 9, 2021, 2:40pm UTC](https://discuss.elastic.co/t/disable-swap-on-linux/283266/5 "2021-09-09T14:40:10Z")

</div>

OK, thank you.

---

<div class="post-metadata">

**Author:** ![rugenl](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rugenl/32/12887_2.png) [@rugenl](https://discuss.elastic.co/u/rugenl)\
**Post date:** [September 9, 2021, 3:04pm UTC](https://discuss.elastic.co/t/disable-swap-on-linux/283266/6 "2021-09-09T15:04:22Z")

</div>

Yes, for "well behaved" systems, but sometimes they don't behave 🙂

What happens without swap when the system is critically low on memory? OOM Killer will usually kill the process that will free the most memory, which may be the elasticsearch process.

IMHO, having system swap available ([see this](https://haydenjames.io/linux-performance-almost-always-add-swap-space/)) and setting bootstrap.memory\_lock for elasticsearch may let your system recover from some low memory events without OOM Killer sacrificing some processes.

Moving unreferenced memory pages to swap disk IS cost effective. It's REFREENCING swapped pages that causes problems.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [October 7, 2021, 3:04pm UTC](https://discuss.elastic.co/t/disable-swap-on-linux/283266/7 "2021-10-07T15:04:59Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
