Tuesday, 30 May 2017

Create swap after ubuntu installation

Create swap after ubuntu installation


For newer version of ubuntu swap is very important. Question is why?

1. On hibernate system save all data from ram to swap.
2. When ram is full, swap is used as a secondary ram

Recently released ubuntu uses caching in ram. Its means save recently closed application data in ram, so that when you will use the application again it can load it quickly. Cache increase performance. For that ram becomes full (2GB or less). When ram fill with cache and system needs more ram it backup old cache in swap. If you dont have a swap then your system behave slow when ram is full.

What happen if you have already installed your system without swap partition? Fortunately ubuntu has option to create a swap as file.

Step 1: Allocate a file  sudo fallocate -l 2048m /mnt/swap_file.swap

Step 2: Change permission sudo chmod 600 /mnt/swap_file.swap

Step 3: Format the file for swapping device  sudo mkswap /mnt/swap_file.swap

Step 4: Add swap  sudo swapon /mnt/swap_file.swap

Step 5: Open fstab  sudo gedit /etc/fstab

Step 6: Add entry in fstab  /mnt/swap_file.swap none swap sw 0 0 


source : here
download
alternative link download

Like the Post? Do share with your Friends.