# Failed to create swap on install

**URL:** https://meta.discourse.org/t/failed-to-create-swap-on-install/179095
**Category:** Self-hosting
**Tags:** server-resources
**Created:** [February 9, 2021, 5:14pm UTC](https://meta.discourse.org/t/failed-to-create-swap-on-install/179095 "2021-02-09T17:14:19Z")
**Posts on this page:** 18
**Page:** 1

<div class="post-metadata">

### Author: ![abdurrehman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/abdurrehman/32/209023_2.png) [@abdurrehman](https://meta.discourse.org/u/abdurrehman)
#### Post date: [February 9, 2021, 5:14pm UTC](https://meta.discourse.org/t/failed-to-create-swap-on-install/179095/1 "2021-02-09T17:14:19Z")

</div>

I’m following the [official install](https://meta.discourse.org/t/142537?silent=true) guide, and when I run this command.

`./discourse-setup`

I’m getting this error message.

```
root@server:/var/discourse# ./discourse-setup
WARNING: Discourse requires at least 2GB of swap when running with 2GB of RAM
or less. This system does not appear to have sufficient swap space.

Without sufficient swap space, your site may not work properly, and future
upgrades of Discourse may not complete successfully.

Ctrl+C to exit or wait 5 seconds to have a 2GB swapfile created.
install: cannot remove '/swapfile': Operation not permitted
fallocate: fallocate failed: Text file busy
mkswap: error: /swapfile is mounted; will not make swapspace
swapon: /swapfile: swapon failed: Device or resource busy
/swapfile swap swap auto 0 0
vm.swappiness = 10
Failed to create swap: are you root? Are you running on real hardware, or a fully virtualized server?

```

I have VPS of 2GB RM and 50 GB SSD and did set up a sub-domain for discourse as well.

Why it gives me that error?

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [February 9, 2021, 5:17pm UTC](https://meta.discourse.org/t/failed-to-create-swap-on-install/179095/2 "2021-02-09T17:17:32Z")

</div>

> [@abdurrehman](#):
>
> `install: cannot remove '/swapfile': Operation not permitted`

This usually means you are not on a “real” VPS, as in it’s not a KVM one. What is your VPS provider and product / plan?

---

<div class="post-metadata">

### Author: ![abdurrehman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/abdurrehman/32/209023_2.png) [@abdurrehman](https://meta.discourse.org/u/abdurrehman)
#### Post date: [February 9, 2021, 5:19pm UTC](https://meta.discourse.org/t/failed-to-create-swap-on-install/179095/3 "2021-02-09T17:19:18Z")

</div>

Oh, didn’t know that and it’s [atlantic.net](http://atlantic.net). Is there a fix for this though?

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [February 9, 2021, 5:27pm UTC](https://meta.discourse.org/t/failed-to-create-swap-on-install/179095/4 "2021-02-09T17:27:27Z")

</div>

This is their free VPS offering? Contact support and ask if this product is KVM or OpenVZ.

---

<div class="post-metadata">

### Author: ![abdurrehman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/abdurrehman/32/209023_2.png) [@abdurrehman](https://meta.discourse.org/u/abdurrehman)
#### Post date: [February 9, 2021, 5:28pm UTC](https://meta.discourse.org/t/failed-to-create-swap-on-install/179095/5 "2021-02-09T17:28:46Z")

</div>

Okay, so on free on it couldn’t be, right?

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [February 9, 2021, 5:31pm UTC](https://meta.discourse.org/t/failed-to-create-swap-on-install/179095/6 "2021-02-09T17:31:06Z")

</div>

Well, if I had to guess I would bet on it not being KVM as it’s simply more expensive. But I guess it doesn’t hurt asking their team, as their FAQs don’t mention the virtualization technology at all.

---

<div class="post-metadata">

### Author: ![abdurrehman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/abdurrehman/32/209023_2.png) [@abdurrehman](https://meta.discourse.org/u/abdurrehman)
#### Post date: [February 9, 2021, 5:49pm UTC](https://meta.discourse.org/t/failed-to-create-swap-on-install/179095/7 "2021-02-09T17:49:30Z")

</div>

I’ll and going to them. Thanks! 🙂

---

<div class="post-metadata">

### Author: ![Timelord](https://avatars.discourse-cdn.com/v4/letter/t/ba9def/32.png) [@Timelord](https://meta.discourse.org/u/Timelord)
#### Post date: [February 10, 2021, 6:13pm UTC](https://meta.discourse.org/t/failed-to-create-swap-on-install/179095/8 "2021-02-10T18:13:27Z")

</div>

If it is a true KVM VPS, then you will [need this article](https://meta.discourse.org/t/create-a-swapfile-for-your-linux-server/13880)

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [February 10, 2021, 6:19pm UTC](https://meta.discourse.org/t/failed-to-create-swap-on-install/179095/9 "2021-02-10T18:19:41Z")

</div>

There is no need to follow that as the current version of `discourse-setup` script takes care of that automatically.

---

<div class="post-metadata">

### Author: ![Timelord](https://avatars.discourse-cdn.com/v4/letter/t/ba9def/32.png) [@Timelord](https://meta.discourse.org/u/Timelord)
#### Post date: [February 10, 2021, 6:20pm UTC](https://meta.discourse.org/t/failed-to-create-swap-on-install/179095/10 "2021-02-10T18:20:59Z")

</div>

It has failed for me on a couple of instances of Ubuntu (different providers) - Ramnode being one.

---

<div class="post-metadata">

### Author: ![abdurrehman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/abdurrehman/32/209023_2.png) [@abdurrehman](https://meta.discourse.org/u/abdurrehman)
#### Post date: [February 10, 2021, 6:27pm UTC](https://meta.discourse.org/t/failed-to-create-swap-on-install/179095/11 "2021-02-10T18:27:52Z")

</div>

Yes, I worked that out by creating the swapfile.

---

<div class="post-metadata">

### Author: ![abdurrehman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/abdurrehman/32/209023_2.png) [@abdurrehman](https://meta.discourse.org/u/abdurrehman)
#### Post date: [February 10, 2021, 6:28pm UTC](https://meta.discourse.org/t/failed-to-create-swap-on-install/179095/12 "2021-02-10T18:28:39Z")

</div>

I have one question though after installation, do I need to keep that file or can remove that anyway?

---

<div class="post-metadata">

### Author: ![Falco](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/falco/32/179432_2.png) [@Falco](https://meta.discourse.org/u/Falco)
#### Post date: [February 10, 2021, 6:35pm UTC](https://meta.discourse.org/t/failed-to-create-swap-on-install/179095/13 "2021-02-10T18:35:52Z")

</div>

What file, the swap file? Yes, you need to keep it.

---

<div class="post-metadata">

### Author: ![abdurrehman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/abdurrehman/32/209023_2.png) [@abdurrehman](https://meta.discourse.org/u/abdurrehman)
#### Post date: [February 10, 2021, 6:45pm UTC](https://meta.discourse.org/t/failed-to-create-swap-on-install/179095/14 "2021-02-10T18:45:14Z")

</div>

Yes, I thought I just needed that for the installation. 😂

---

<div class="post-metadata">

### Author: ![Timelord](https://avatars.discourse-cdn.com/v4/letter/t/ba9def/32.png) [@Timelord](https://meta.discourse.org/u/Timelord)
#### Post date: [February 10, 2021, 6:47pm UTC](https://meta.discourse.org/t/failed-to-create-swap-on-install/179095/15 "2021-02-10T18:47:15Z")

</div>

Don’t remove it, or you are gonna have a bad time.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [February 11, 2021, 2:41pm UTC](https://meta.discourse.org/t/failed-to-create-swap-on-install/179095/16 "2021-02-11T14:41:17Z")

</div>

You’re saying that Discourse-setup failed to create the swap file? Are you able to create a swap file at all? Or does your vm not let you do it?

---

<div class="post-metadata">

### Author: ![abdurrehman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/abdurrehman/32/209023_2.png) [@abdurrehman](https://meta.discourse.org/u/abdurrehman)
#### Post date: [February 11, 2021, 2:53pm UTC](https://meta.discourse.org/t/failed-to-create-swap-on-install/179095/17 "2021-02-11T14:53:49Z")

</div>

Not sure you’re addressing me or @Timelord

If it’s yes then, yeah I was able to create that file, and the installation went well.

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [March 13, 2021, 2:54pm UTC](https://meta.discourse.org/t/failed-to-create-swap-on-install/179095/18 "2021-03-13T14:54:49Z")

</div>

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