0

I have replaced windows with Ubuntu 14.04. My Windows was on drive c & I have formatted drive c with the Ubuntu but during the OS installation unknowingly I had assigned 105mb of swap memory, but now I want to increase my swap memory. I had checked many relevant questions & answers for this but did feed need. I don't have any unallocated space for this. My c drive is 137gb on which approximate 97 gb is free & on d drive I am having free space up to 25gb. Please let me know how I can increase my swap memory without causing any data loss.

2 Answers 2

2

You must decide which directory with enough space to create the swap file, you suppose is in /, (/swapfile).

Open a terminal,

Press Ctrl+Alt+T

Run it for 2 Gb (bs=2048):

sudo -i
dd if=/dev/zero of=/swapfile bs=2048 count=256k
mkswap /swapfile
swapon /swapfile

Now You can ensure that the swap is permanent by adding it to the fstab file.

Continue running in the terminal:

nano /etc/fstab

Change the line:

UUID=c9eb230e-ab85-4bc0-b24f-06caeac4d953 none            swap    sw              0       0

To:

 /swapfile       none    swap    sw      0       0 

Ctrl + O, save file. Ctrl + X, close nano.

Continue running:

echo 10 | tee /proc/sys/vm/swappiness
echo vm.swappiness = 10 | tee -a /etc/sysctl.conf
chown root:root /swapfile 
chmod 0600 /swapfile
reboot

That's all.

1

Just copy paste the following line in terminal and it will create 2 GB of swap

sudo su

Then Copy Pate the following

mkdir /swap && cd /swap && fallocate -l 2g 2GB.swap && mkswap 2GB.swap && swapon 2GB.swap && echo "# # # Swap File # # #" >> /etc/fstab && echo "/swap/2GB.swap    none                   swap               sw                       0       0" >> /etc/fstab && chmod 0600 2GB.swap && mount -a

Does it make sense to create swap partitions for new installations nowadways?

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .