I have, by default, 250MB of swap space in Ubuntu, and I want to expand it to a larger size. I need 800MB, which I think will be enough to open several applications without having to hit the current limit of swap. I hope someone can help me.
You can always create swap fileto add more swap space. This is not same (in every aspect) as swap partition but it will be easy and dynamic. Change Use any of terminal applications to run commands. All command should be run with root privileges, to do this you can either add 1. Create empty file:
If you want to make 3Gb file then change count value to 2. Bake swap file:
3. Bring up on boot:
4. Activate:
If everything goes wellyou should see that more swap space is available for use. You can use following commands to check your new swap and confirm that it is active:
|
|||||||||||||||||||||
|
GUI method for increasing the size of swap partitionAnother way to increase the swap size is to use the GParted partition Editor. In short, you resize the swap partition, then right click on it and choose "Swapon". It's easier to boot gparted-live-disk or an Ubuntu live disk (so that the all
You must be able to increase the size of swap partition only if there is an unallocated space present before or after the swap partition. If there was no unallocated space (the space which we are trying to add with swap partition) below or above the swap partition, then we have to resize the partitions and get that unallocated space. Case 1 - unallocated space present before or after the swap partition
In the above screenshot, I had 11.4 GB of unallocated space before the linux-swap and 12.8 GB after the swap partition.
Case 2 - unallocated space is between the partitions
In the above screenshot, the unallocated space which we wants to add to the swap partition was between
Case 3 - if the unallocated space was present outside the Extended partition)
I had an unallocated space of 18 GB just below to the extended partition.To add this space to the linux-swap partition(which was present inside the extended partition),we have to follow the below steps,
NOTE: Don't forget to take backup of all your important datas before proceeding the above operations. |
|||||||||
|
|
You can also use from the
If you already have a Simple
|
|
1-up for
fallocate, a lot better than dd if your fs supports it. Those one-liners still feels hard to read, could be easier to study if those would be broken down to actual commands?
– Sampo Sarrala
Jan 24 '16 at 8:49
|
|
In my case I already had a swap file which I thought was 1GB but when I looked at it more closely it was only 256 MB big and when pre-compiling my rails assets the server would run out of memory
I created my swap file as described here: https://stackoverflow.com/a/34885004/784318 Now the line that creates an empty file called
Now to resize the swapfile I had to do these simple steps:
The file was created (536870912 / 1024 / 1024 = 512 MB):
Using |
|||||||||
|
|
how to add a swap file
note!: bs=1M count=1000 ==> 1GB (bs * count = size in megabytes ) other example : sudo dd if=/dev/zero of=/swap.img bs=10M count=100
add this line to your fstab (/etc/fstab)
|
|||
|
|






gparted. If such space is not available, perhaps because your active (booted) partition is using all the non-swap space, thengpartedwill not allow you to decrease the size of the active partition in order to create unallocated space. In this case you can re-install Ubuntu in order to create a larger swap space. – H2ONaCl Apr 4 '17 at 20:48