Many vendors provide no default swap partition in their images. If you use Ubuntu, here’s a quick way to add swap space, which is useful when you may run out of allocated physical memory.
$ swapon -s
$ sudo dd if=/dev/zero of=/swapfile bs=1024 count=512k
$ sudo mkswap /swapfile
$ sudo swapon /swapfile
$ swapon -s
$ sudo vi /etc/fstab # add the line below
LABEL=SWAP /swapfile none swap sw 0 0
$ sudo dd if=/dev/zero of=/swapfile bs=1024 count=512k
$ sudo mkswap /swapfile
$ sudo swapon /swapfile
$ swapon -s
$ sudo vi /etc/fstab # add the line below
LABEL=SWAP /swapfile none swap sw 0 0