1

I create the ubuntu vm by vagrant. I want to add the swap to vm.

the steps:

mkdir /swapfile
cd /swapfile
sudo dd if=/dev/zero of=swap bs=1024 count=2000000
sudo mkswap -f  swap
sudo swapon swap
add /swapfile/swapfile none swap defaults 0 0 to /etc/fstab

It works:

vagrant@vagrant-ubuntu-trusty-64:/swapfile$ free -m
             total       used       free     shared    buffers     cached
Mem:           489        203        286          0         11         81
-/+ buffers/cache:        110        379
Swap:         1953          0       1953

But when i exit the vm, then login, the swap is missing. How to make the swap permanent?

2

You create a directory called /swapfile and a file called swap but in the /etc/fstab you refer to /swapfile/swapfile instead of /swapfile/swap

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.