How to enlarge swap space on a linux VPS in order to compile an R package?
By Michael Henderson •
Matt Lacey explained how to compile dplyr on low memory VPS. He managed to install dplyr by adding a larger swap space. Unfortunately this operation is not permitted on my VPS (Virtual Private Server): "swapon failed: Operation not permitted". Here is the output:
$ sudo fallocate -l 1G /swapfile
$ sudo chmod 600 /swapfile
$ sudo mkswap /swapfile
Setting up swapspace version 1, size = 1048572 KiB
no label, UUID=3bfbcf12-6b81-46b4-96b0-7de37fa1640b
$ sudo swapon /swapfile
swapon: /swapfile: swapon failed: Operation not permitted
$ cat /proc/swaps
Filename Type Size Used Priority
/dev/null partition 131072 3060 -1EDIT I used other instructions from digitalocean to create a swap file. But they failed too:
sudo swapon /var/swap.img
swapon: /var/swap.img: swapon failed: Operation not permittedThere is a related issue in the dplyr package's repository.
Are there other, recommended ways to enlarge the swap space?
81 Answer
No, you can either:
- Add a parttion to page to,
- or add a file (as you tried) to page to,
- or add more physical memory,
- or ask the VPS provider to allocate more resources.
Alternatively, you could compile it on a different host and upload it to the VPS. (e.g. compile, create .rpm or whatever package manager you use on the VPS, upload that rpm).
3