Increasing swap space and removing previous swap space on ubuntu?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP












0















I have a virtual machine (hosted online) with 2Gb swap space.



free -m



 total used free shared buffers cached
Mem: 1995 438 1557 37 22 190
-/+ buffers/cache: 225 1770
Swap: 1998 0 1998


Since the swap space was small, I tried to increase it to 4GB.



Doing swapon -s, returned this result (not sure what it means since I don't have a second hard disk sda2)



Filename Type Size Used Priority
/dev/sda2 partition 2046972 0 -1


df -H



Filesystem Size Used Avail Use% Mounted on
/dev/sda1 25G 19G 4.3G 82% /
udev 1.1G 4.1k 1.1G 1% /dev
tmpfs 210M 492k 209M 1% /run
none 4.1k 0 4.1k 0% /sys/fs/cgroup
none 5.3M 0 5.3M 0% /run/lock
none 1.1G 0 1.1G 0% /run/shm
none 105M 0 105M 0% /run/user


So I did



swapoff -a #deactivating previous swap space
fallocate -l 4G /swapfile #creating a swapfile
chmod 600 /swapfile #giving permissions
mkswap /swapfile #making swap the file
swapon /swapfile #activating swap on the file
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab #stabilizying swap for it to be there after next reboot


Now I have the swap space I needed



free -m



 total used free shared buffers cached Mem: 1995 1153 842 64 116 
455
-/+ buffers/cache: 581 1414 Swap: 4095 0 4095


But, the 2GB of the previous swap space are still considered occupied if I do a df (maybe they will be free at the next reboot?) and my fstab has two entries for swap space.



# <file system> <mount point> <type> <options> <dump> <pass>
/dev/sda1 / ext4 errors=remount-ro,relatime 0 1
/dev/sda2 swap swap defaults 0 0
proc /proc proc defaults 0 0
sysfs /sys sysfs defaults 0 0
devtmpfs /dev devtmpfs rw 0 0
/swapfile none swap sw 0 0


In this situation, how I may proceed to finalize the procedure? I have to remove the second line referring to swap in the fstab? (I mean /dev/sda2 swap swap defaults 0 0) It is safe to reboot?










share|improve this question






















  • /dev/sda2 is a second partition on your computer. That is, it shares space on your disk - you can see this in sudo fdisk -l /dev/sda output. Removing the partition will be difficult while you're running the system; it can be done but you won't be able to recover the space to use on the ext4 partition while you're running the system.

    – Thomas Ward
    Jan 9 at 14:35












  • I would have add only 2G and keep both swap area, with device in higher priority. (see man 8 swapon)

    – Archemar
    Jan 9 at 14:49















0















I have a virtual machine (hosted online) with 2Gb swap space.



free -m



 total used free shared buffers cached
Mem: 1995 438 1557 37 22 190
-/+ buffers/cache: 225 1770
Swap: 1998 0 1998


Since the swap space was small, I tried to increase it to 4GB.



Doing swapon -s, returned this result (not sure what it means since I don't have a second hard disk sda2)



Filename Type Size Used Priority
/dev/sda2 partition 2046972 0 -1


df -H



Filesystem Size Used Avail Use% Mounted on
/dev/sda1 25G 19G 4.3G 82% /
udev 1.1G 4.1k 1.1G 1% /dev
tmpfs 210M 492k 209M 1% /run
none 4.1k 0 4.1k 0% /sys/fs/cgroup
none 5.3M 0 5.3M 0% /run/lock
none 1.1G 0 1.1G 0% /run/shm
none 105M 0 105M 0% /run/user


So I did



swapoff -a #deactivating previous swap space
fallocate -l 4G /swapfile #creating a swapfile
chmod 600 /swapfile #giving permissions
mkswap /swapfile #making swap the file
swapon /swapfile #activating swap on the file
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab #stabilizying swap for it to be there after next reboot


Now I have the swap space I needed



free -m



 total used free shared buffers cached Mem: 1995 1153 842 64 116 
455
-/+ buffers/cache: 581 1414 Swap: 4095 0 4095


But, the 2GB of the previous swap space are still considered occupied if I do a df (maybe they will be free at the next reboot?) and my fstab has two entries for swap space.



# <file system> <mount point> <type> <options> <dump> <pass>
/dev/sda1 / ext4 errors=remount-ro,relatime 0 1
/dev/sda2 swap swap defaults 0 0
proc /proc proc defaults 0 0
sysfs /sys sysfs defaults 0 0
devtmpfs /dev devtmpfs rw 0 0
/swapfile none swap sw 0 0


In this situation, how I may proceed to finalize the procedure? I have to remove the second line referring to swap in the fstab? (I mean /dev/sda2 swap swap defaults 0 0) It is safe to reboot?










share|improve this question






















  • /dev/sda2 is a second partition on your computer. That is, it shares space on your disk - you can see this in sudo fdisk -l /dev/sda output. Removing the partition will be difficult while you're running the system; it can be done but you won't be able to recover the space to use on the ext4 partition while you're running the system.

    – Thomas Ward
    Jan 9 at 14:35












  • I would have add only 2G and keep both swap area, with device in higher priority. (see man 8 swapon)

    – Archemar
    Jan 9 at 14:49













0












0








0








I have a virtual machine (hosted online) with 2Gb swap space.



free -m



 total used free shared buffers cached
Mem: 1995 438 1557 37 22 190
-/+ buffers/cache: 225 1770
Swap: 1998 0 1998


Since the swap space was small, I tried to increase it to 4GB.



Doing swapon -s, returned this result (not sure what it means since I don't have a second hard disk sda2)



Filename Type Size Used Priority
/dev/sda2 partition 2046972 0 -1


df -H



Filesystem Size Used Avail Use% Mounted on
/dev/sda1 25G 19G 4.3G 82% /
udev 1.1G 4.1k 1.1G 1% /dev
tmpfs 210M 492k 209M 1% /run
none 4.1k 0 4.1k 0% /sys/fs/cgroup
none 5.3M 0 5.3M 0% /run/lock
none 1.1G 0 1.1G 0% /run/shm
none 105M 0 105M 0% /run/user


So I did



swapoff -a #deactivating previous swap space
fallocate -l 4G /swapfile #creating a swapfile
chmod 600 /swapfile #giving permissions
mkswap /swapfile #making swap the file
swapon /swapfile #activating swap on the file
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab #stabilizying swap for it to be there after next reboot


Now I have the swap space I needed



free -m



 total used free shared buffers cached Mem: 1995 1153 842 64 116 
455
-/+ buffers/cache: 581 1414 Swap: 4095 0 4095


But, the 2GB of the previous swap space are still considered occupied if I do a df (maybe they will be free at the next reboot?) and my fstab has two entries for swap space.



# <file system> <mount point> <type> <options> <dump> <pass>
/dev/sda1 / ext4 errors=remount-ro,relatime 0 1
/dev/sda2 swap swap defaults 0 0
proc /proc proc defaults 0 0
sysfs /sys sysfs defaults 0 0
devtmpfs /dev devtmpfs rw 0 0
/swapfile none swap sw 0 0


In this situation, how I may proceed to finalize the procedure? I have to remove the second line referring to swap in the fstab? (I mean /dev/sda2 swap swap defaults 0 0) It is safe to reboot?










share|improve this question














I have a virtual machine (hosted online) with 2Gb swap space.



free -m



 total used free shared buffers cached
Mem: 1995 438 1557 37 22 190
-/+ buffers/cache: 225 1770
Swap: 1998 0 1998


Since the swap space was small, I tried to increase it to 4GB.



Doing swapon -s, returned this result (not sure what it means since I don't have a second hard disk sda2)



Filename Type Size Used Priority
/dev/sda2 partition 2046972 0 -1


df -H



Filesystem Size Used Avail Use% Mounted on
/dev/sda1 25G 19G 4.3G 82% /
udev 1.1G 4.1k 1.1G 1% /dev
tmpfs 210M 492k 209M 1% /run
none 4.1k 0 4.1k 0% /sys/fs/cgroup
none 5.3M 0 5.3M 0% /run/lock
none 1.1G 0 1.1G 0% /run/shm
none 105M 0 105M 0% /run/user


So I did



swapoff -a #deactivating previous swap space
fallocate -l 4G /swapfile #creating a swapfile
chmod 600 /swapfile #giving permissions
mkswap /swapfile #making swap the file
swapon /swapfile #activating swap on the file
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab #stabilizying swap for it to be there after next reboot


Now I have the swap space I needed



free -m



 total used free shared buffers cached Mem: 1995 1153 842 64 116 
455
-/+ buffers/cache: 581 1414 Swap: 4095 0 4095


But, the 2GB of the previous swap space are still considered occupied if I do a df (maybe they will be free at the next reboot?) and my fstab has two entries for swap space.



# <file system> <mount point> <type> <options> <dump> <pass>
/dev/sda1 / ext4 errors=remount-ro,relatime 0 1
/dev/sda2 swap swap defaults 0 0
proc /proc proc defaults 0 0
sysfs /sys sysfs defaults 0 0
devtmpfs /dev devtmpfs rw 0 0
/swapfile none swap sw 0 0


In this situation, how I may proceed to finalize the procedure? I have to remove the second line referring to swap in the fstab? (I mean /dev/sda2 swap swap defaults 0 0) It is safe to reboot?







ubuntu swap






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jan 9 at 14:26









Sasha GrievusSasha Grievus

1133




1133












  • /dev/sda2 is a second partition on your computer. That is, it shares space on your disk - you can see this in sudo fdisk -l /dev/sda output. Removing the partition will be difficult while you're running the system; it can be done but you won't be able to recover the space to use on the ext4 partition while you're running the system.

    – Thomas Ward
    Jan 9 at 14:35












  • I would have add only 2G and keep both swap area, with device in higher priority. (see man 8 swapon)

    – Archemar
    Jan 9 at 14:49

















  • /dev/sda2 is a second partition on your computer. That is, it shares space on your disk - you can see this in sudo fdisk -l /dev/sda output. Removing the partition will be difficult while you're running the system; it can be done but you won't be able to recover the space to use on the ext4 partition while you're running the system.

    – Thomas Ward
    Jan 9 at 14:35












  • I would have add only 2G and keep both swap area, with device in higher priority. (see man 8 swapon)

    – Archemar
    Jan 9 at 14:49
















/dev/sda2 is a second partition on your computer. That is, it shares space on your disk - you can see this in sudo fdisk -l /dev/sda output. Removing the partition will be difficult while you're running the system; it can be done but you won't be able to recover the space to use on the ext4 partition while you're running the system.

– Thomas Ward
Jan 9 at 14:35






/dev/sda2 is a second partition on your computer. That is, it shares space on your disk - you can see this in sudo fdisk -l /dev/sda output. Removing the partition will be difficult while you're running the system; it can be done but you won't be able to recover the space to use on the ext4 partition while you're running the system.

– Thomas Ward
Jan 9 at 14:35














I would have add only 2G and keep both swap area, with device in higher priority. (see man 8 swapon)

– Archemar
Jan 9 at 14:49





I would have add only 2G and keep both swap area, with device in higher priority. (see man 8 swapon)

– Archemar
Jan 9 at 14:49










0






active

oldest

votes











Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f493473%2fincreasing-swap-space-and-removing-previous-swap-space-on-ubuntu%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Unix & Linux Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f493473%2fincreasing-swap-space-and-removing-previous-swap-space-on-ubuntu%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown






Popular posts from this blog

How to check contact read email or not when send email to Individual?

Bahrain

Postfix configuration issue with fips on centos 7; mailgun relay