I did not provide swap space while installing Ubuntu. How shall i give the swap space now? I've a multibooted system with win xp and ubuntu. please help
2 Answers
This will create a swap file of 512MB, using space from /dev/sda5
since you're only using up about 8% of it.
Just press Ctrl+Alt+T on your keyboard to open Terminal. When it opens, run the command(s) below:
sudo dd if=/dev/zero of=/swapfile bs=1024 count=512k sudo mkswap /swapfile
Finish up by activating the swap file:
sudo swapon /swapfile
To make the swap permanent add it to the fstab file.
sudo gedit /etc/fstab
Paste in the following line:
/swapfile none swap sw 0 0
And finally set up the correct permissions on the swap file:
sudo chown root:root /swapfile
sudo chmod 0600 /swapfile
Source:DigitalOcean

- 107,631
-
will it affect any data on sda5 which i already have in it and will be safely able to access that data in windows OS too ? because i saw many suggestions to first make partition first using GParted. – Kattybilly Jun 30 '13 at 06:33
-
@Kattybilly Yes! Better to use GParted. Thus, with a little attention you can see exactly what you do. – Radu Rădeanu Jun 30 '13 at 06:37
-
It won't, since this will create a swap file. But its best to create a swap partition instead of a swap file. – Mitch Jun 30 '13 at 06:39
-
@Mitch so how to go forward after creating a swap partition using GParted ? – Kattybilly Jun 30 '13 at 06:45
-
Make sure that you do that from Live CD, since the partition has to be un-mounted. But once you finish all the needed steps, all you have to do is reboot. By the way how much RAM do you have in your machine? – Mitch Jun 30 '13 at 06:53
First you must to free up some space and make a swap partition using a program like GParted.
After you made a new swap partition, follow this answer: https://askubuntu.com/a/33700/147044.
To calculate the size of swap partition, use this answer: https://askubuntu.com/a/49138/147044.

- 169,590
swapon -s
, anddf
. – Mitch Jun 30 '13 at 06:06output of df: 'Filesystem 1K-blocks Used Available Use% Mounted on /dev/sda5 20634772 4021872 15564708 21% / udev 500452 4 500448 1% /dev tmpfs 203276 884 202392 1% /run none 5120 0 5120 0% /run/lock none 508184 152 508032 1% /run/shm none 102400 32 102368 1% /run/user'
– Kattybilly Jun 30 '13 at 06:29