How to change the swap file size permanently












1















A previous thread explains how to resize the swap file in Ubuntu 18. I used it successfully. But on reboot, the swap file reverts to its previous size. Is there a straightforward way to make that change permanent?



lsblk -f



AME FSTYPE LABEL UUID MOUNTPOINT
loop0 squashf /snap/core/603
loop1 squashf /snap/gnome-lo
loop2 squashf /snap/core18/5
loop3 squashf /snap/hextris/
loop4 squashf /snap/core18/4
loop5 squashf /snap/core18/5
loop6 squashf /snap/gnome-ca
loop7 squashf /snap/gnome-ca
loop8 squashf /snap/gimp/88
loop9 squashf /snap/gtk-comm
loop10 squashf /snap/gnome-ch
loop11 squashf /snap/gnome-3-
loop12 squashf /snap/gnome-3-
loop13 squashf /snap/skype/60
loop14 squashf /snap/skype/63
loop15 squashf /snap/squirrel
loop16 squashf /snap/gnome-3-
loop17 squashf /snap/canonica
loop18 squashf /snap/wine-pla
loop19 squashf /snap/skype/66
loop20 squashf /snap/wine-pla
loop21 squashf /snap/quadrapa
loop22 squashf /snap/gnome-sy
loop23 squashf /snap/gnome-sy
loop24 squashf /snap/gnome-ch
loop25 squashf /snap/ohmygira
loop26 squashf /snap/gnome-ca
loop27 squashf /snap/canonica
loop28 squashf /snap/teatime/
loop29 squashf /snap/gnome-ch
loop30 squashf /snap/gnome-lo
loop31 squashf /snap/gimp/83
loop32 squashf /snap/core/589
loop33 squashf /snap/marsshoo
loop34 squashf /snap/gtk-comm
loop35 squashf /snap/gimp/94
loop36 squashf /snap/teatime/
loop37 squashf /snap/core/613
loop38 squashf /snap/gnome-cl
loop39 squashf /snap/squirrel
loop40 squashf /snap/gtk-comm
loop41 squashf /snap/gnome-cl
mmcblk0

├─mmcblk0p1 vfat DB20-54E6 /boot/efi
├─mmcblk0p2 ext4 79300f87-0c38-49bb-8070-18460b8905a4 /boot
└─mmcblk0p3 crypto_ edf15eb1-9421-47de-8323-0a8c32b6cfb1

└─mmcblk0p3_crypt
LVM2_me w1g34A-NYp6-GtFo-b1Kb-zeJW-WowF-o04IsU
├─ubuntu--vg-root
│ ext4 b4075b43-cf2b-40c7-bb88-0d15293378b6 /
└─ubuntu--vg-swap_1
swap d0da0a8c-c645-4f46-9432-793c1a20799f [SWAP]
mmcblk0boot0

mmcblk0boot1










share|improve this question

























  • Did you change the swapfile's name? What does grep swap /etc/fstab show?

    – PerlDuck
    Dec 29 '18 at 15:30











  • Btw: It is perfectly OK and preferred to ask a new question here (and not as a comment to the other question) because it is … a new question. :-)

    – PerlDuck
    Dec 29 '18 at 15:31











  • Thanks, I took the line out about the new question! I followed the steps in the linked thread, so I should have replaced the swapfile, and I think its name is swapfile. The result of grep swap /etc/fstab is this: /dev/mapper/ubuntu--vg-swap_1 none swap sw 0 0. System Monitor shows me booting with 1 Gb of swap.

    – Justin Sharber
    Dec 29 '18 at 15:40













  • Maybe you don't enough space to increase the size!

    – George Udosen
    Dec 29 '18 at 15:44











  • @GeorgeUdosen - I have plenty of free space, using 70 out of 120 Gb on the HD. Also, I successfully increased the swap -- it just didn't stay increased on reboot.

    – Justin Sharber
    Dec 29 '18 at 15:55


















1















A previous thread explains how to resize the swap file in Ubuntu 18. I used it successfully. But on reboot, the swap file reverts to its previous size. Is there a straightforward way to make that change permanent?



lsblk -f



AME FSTYPE LABEL UUID MOUNTPOINT
loop0 squashf /snap/core/603
loop1 squashf /snap/gnome-lo
loop2 squashf /snap/core18/5
loop3 squashf /snap/hextris/
loop4 squashf /snap/core18/4
loop5 squashf /snap/core18/5
loop6 squashf /snap/gnome-ca
loop7 squashf /snap/gnome-ca
loop8 squashf /snap/gimp/88
loop9 squashf /snap/gtk-comm
loop10 squashf /snap/gnome-ch
loop11 squashf /snap/gnome-3-
loop12 squashf /snap/gnome-3-
loop13 squashf /snap/skype/60
loop14 squashf /snap/skype/63
loop15 squashf /snap/squirrel
loop16 squashf /snap/gnome-3-
loop17 squashf /snap/canonica
loop18 squashf /snap/wine-pla
loop19 squashf /snap/skype/66
loop20 squashf /snap/wine-pla
loop21 squashf /snap/quadrapa
loop22 squashf /snap/gnome-sy
loop23 squashf /snap/gnome-sy
loop24 squashf /snap/gnome-ch
loop25 squashf /snap/ohmygira
loop26 squashf /snap/gnome-ca
loop27 squashf /snap/canonica
loop28 squashf /snap/teatime/
loop29 squashf /snap/gnome-ch
loop30 squashf /snap/gnome-lo
loop31 squashf /snap/gimp/83
loop32 squashf /snap/core/589
loop33 squashf /snap/marsshoo
loop34 squashf /snap/gtk-comm
loop35 squashf /snap/gimp/94
loop36 squashf /snap/teatime/
loop37 squashf /snap/core/613
loop38 squashf /snap/gnome-cl
loop39 squashf /snap/squirrel
loop40 squashf /snap/gtk-comm
loop41 squashf /snap/gnome-cl
mmcblk0

├─mmcblk0p1 vfat DB20-54E6 /boot/efi
├─mmcblk0p2 ext4 79300f87-0c38-49bb-8070-18460b8905a4 /boot
└─mmcblk0p3 crypto_ edf15eb1-9421-47de-8323-0a8c32b6cfb1

└─mmcblk0p3_crypt
LVM2_me w1g34A-NYp6-GtFo-b1Kb-zeJW-WowF-o04IsU
├─ubuntu--vg-root
│ ext4 b4075b43-cf2b-40c7-bb88-0d15293378b6 /
└─ubuntu--vg-swap_1
swap d0da0a8c-c645-4f46-9432-793c1a20799f [SWAP]
mmcblk0boot0

mmcblk0boot1










share|improve this question

























  • Did you change the swapfile's name? What does grep swap /etc/fstab show?

    – PerlDuck
    Dec 29 '18 at 15:30











  • Btw: It is perfectly OK and preferred to ask a new question here (and not as a comment to the other question) because it is … a new question. :-)

    – PerlDuck
    Dec 29 '18 at 15:31











  • Thanks, I took the line out about the new question! I followed the steps in the linked thread, so I should have replaced the swapfile, and I think its name is swapfile. The result of grep swap /etc/fstab is this: /dev/mapper/ubuntu--vg-swap_1 none swap sw 0 0. System Monitor shows me booting with 1 Gb of swap.

    – Justin Sharber
    Dec 29 '18 at 15:40













  • Maybe you don't enough space to increase the size!

    – George Udosen
    Dec 29 '18 at 15:44











  • @GeorgeUdosen - I have plenty of free space, using 70 out of 120 Gb on the HD. Also, I successfully increased the swap -- it just didn't stay increased on reboot.

    – Justin Sharber
    Dec 29 '18 at 15:55
















1












1








1








A previous thread explains how to resize the swap file in Ubuntu 18. I used it successfully. But on reboot, the swap file reverts to its previous size. Is there a straightforward way to make that change permanent?



lsblk -f



AME FSTYPE LABEL UUID MOUNTPOINT
loop0 squashf /snap/core/603
loop1 squashf /snap/gnome-lo
loop2 squashf /snap/core18/5
loop3 squashf /snap/hextris/
loop4 squashf /snap/core18/4
loop5 squashf /snap/core18/5
loop6 squashf /snap/gnome-ca
loop7 squashf /snap/gnome-ca
loop8 squashf /snap/gimp/88
loop9 squashf /snap/gtk-comm
loop10 squashf /snap/gnome-ch
loop11 squashf /snap/gnome-3-
loop12 squashf /snap/gnome-3-
loop13 squashf /snap/skype/60
loop14 squashf /snap/skype/63
loop15 squashf /snap/squirrel
loop16 squashf /snap/gnome-3-
loop17 squashf /snap/canonica
loop18 squashf /snap/wine-pla
loop19 squashf /snap/skype/66
loop20 squashf /snap/wine-pla
loop21 squashf /snap/quadrapa
loop22 squashf /snap/gnome-sy
loop23 squashf /snap/gnome-sy
loop24 squashf /snap/gnome-ch
loop25 squashf /snap/ohmygira
loop26 squashf /snap/gnome-ca
loop27 squashf /snap/canonica
loop28 squashf /snap/teatime/
loop29 squashf /snap/gnome-ch
loop30 squashf /snap/gnome-lo
loop31 squashf /snap/gimp/83
loop32 squashf /snap/core/589
loop33 squashf /snap/marsshoo
loop34 squashf /snap/gtk-comm
loop35 squashf /snap/gimp/94
loop36 squashf /snap/teatime/
loop37 squashf /snap/core/613
loop38 squashf /snap/gnome-cl
loop39 squashf /snap/squirrel
loop40 squashf /snap/gtk-comm
loop41 squashf /snap/gnome-cl
mmcblk0

├─mmcblk0p1 vfat DB20-54E6 /boot/efi
├─mmcblk0p2 ext4 79300f87-0c38-49bb-8070-18460b8905a4 /boot
└─mmcblk0p3 crypto_ edf15eb1-9421-47de-8323-0a8c32b6cfb1

└─mmcblk0p3_crypt
LVM2_me w1g34A-NYp6-GtFo-b1Kb-zeJW-WowF-o04IsU
├─ubuntu--vg-root
│ ext4 b4075b43-cf2b-40c7-bb88-0d15293378b6 /
└─ubuntu--vg-swap_1
swap d0da0a8c-c645-4f46-9432-793c1a20799f [SWAP]
mmcblk0boot0

mmcblk0boot1










share|improve this question
















A previous thread explains how to resize the swap file in Ubuntu 18. I used it successfully. But on reboot, the swap file reverts to its previous size. Is there a straightforward way to make that change permanent?



lsblk -f



AME FSTYPE LABEL UUID MOUNTPOINT
loop0 squashf /snap/core/603
loop1 squashf /snap/gnome-lo
loop2 squashf /snap/core18/5
loop3 squashf /snap/hextris/
loop4 squashf /snap/core18/4
loop5 squashf /snap/core18/5
loop6 squashf /snap/gnome-ca
loop7 squashf /snap/gnome-ca
loop8 squashf /snap/gimp/88
loop9 squashf /snap/gtk-comm
loop10 squashf /snap/gnome-ch
loop11 squashf /snap/gnome-3-
loop12 squashf /snap/gnome-3-
loop13 squashf /snap/skype/60
loop14 squashf /snap/skype/63
loop15 squashf /snap/squirrel
loop16 squashf /snap/gnome-3-
loop17 squashf /snap/canonica
loop18 squashf /snap/wine-pla
loop19 squashf /snap/skype/66
loop20 squashf /snap/wine-pla
loop21 squashf /snap/quadrapa
loop22 squashf /snap/gnome-sy
loop23 squashf /snap/gnome-sy
loop24 squashf /snap/gnome-ch
loop25 squashf /snap/ohmygira
loop26 squashf /snap/gnome-ca
loop27 squashf /snap/canonica
loop28 squashf /snap/teatime/
loop29 squashf /snap/gnome-ch
loop30 squashf /snap/gnome-lo
loop31 squashf /snap/gimp/83
loop32 squashf /snap/core/589
loop33 squashf /snap/marsshoo
loop34 squashf /snap/gtk-comm
loop35 squashf /snap/gimp/94
loop36 squashf /snap/teatime/
loop37 squashf /snap/core/613
loop38 squashf /snap/gnome-cl
loop39 squashf /snap/squirrel
loop40 squashf /snap/gtk-comm
loop41 squashf /snap/gnome-cl
mmcblk0

├─mmcblk0p1 vfat DB20-54E6 /boot/efi
├─mmcblk0p2 ext4 79300f87-0c38-49bb-8070-18460b8905a4 /boot
└─mmcblk0p3 crypto_ edf15eb1-9421-47de-8323-0a8c32b6cfb1

└─mmcblk0p3_crypt
LVM2_me w1g34A-NYp6-GtFo-b1Kb-zeJW-WowF-o04IsU
├─ubuntu--vg-root
│ ext4 b4075b43-cf2b-40c7-bb88-0d15293378b6 /
└─ubuntu--vg-swap_1
swap d0da0a8c-c645-4f46-9432-793c1a20799f [SWAP]
mmcblk0boot0

mmcblk0boot1







18.04 swap






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Dec 29 '18 at 16:03







Justin Sharber

















asked Dec 29 '18 at 15:26









Justin SharberJustin Sharber

83




83













  • Did you change the swapfile's name? What does grep swap /etc/fstab show?

    – PerlDuck
    Dec 29 '18 at 15:30











  • Btw: It is perfectly OK and preferred to ask a new question here (and not as a comment to the other question) because it is … a new question. :-)

    – PerlDuck
    Dec 29 '18 at 15:31











  • Thanks, I took the line out about the new question! I followed the steps in the linked thread, so I should have replaced the swapfile, and I think its name is swapfile. The result of grep swap /etc/fstab is this: /dev/mapper/ubuntu--vg-swap_1 none swap sw 0 0. System Monitor shows me booting with 1 Gb of swap.

    – Justin Sharber
    Dec 29 '18 at 15:40













  • Maybe you don't enough space to increase the size!

    – George Udosen
    Dec 29 '18 at 15:44











  • @GeorgeUdosen - I have plenty of free space, using 70 out of 120 Gb on the HD. Also, I successfully increased the swap -- it just didn't stay increased on reboot.

    – Justin Sharber
    Dec 29 '18 at 15:55





















  • Did you change the swapfile's name? What does grep swap /etc/fstab show?

    – PerlDuck
    Dec 29 '18 at 15:30











  • Btw: It is perfectly OK and preferred to ask a new question here (and not as a comment to the other question) because it is … a new question. :-)

    – PerlDuck
    Dec 29 '18 at 15:31











  • Thanks, I took the line out about the new question! I followed the steps in the linked thread, so I should have replaced the swapfile, and I think its name is swapfile. The result of grep swap /etc/fstab is this: /dev/mapper/ubuntu--vg-swap_1 none swap sw 0 0. System Monitor shows me booting with 1 Gb of swap.

    – Justin Sharber
    Dec 29 '18 at 15:40













  • Maybe you don't enough space to increase the size!

    – George Udosen
    Dec 29 '18 at 15:44











  • @GeorgeUdosen - I have plenty of free space, using 70 out of 120 Gb on the HD. Also, I successfully increased the swap -- it just didn't stay increased on reboot.

    – Justin Sharber
    Dec 29 '18 at 15:55



















Did you change the swapfile's name? What does grep swap /etc/fstab show?

– PerlDuck
Dec 29 '18 at 15:30





Did you change the swapfile's name? What does grep swap /etc/fstab show?

– PerlDuck
Dec 29 '18 at 15:30













Btw: It is perfectly OK and preferred to ask a new question here (and not as a comment to the other question) because it is … a new question. :-)

– PerlDuck
Dec 29 '18 at 15:31





Btw: It is perfectly OK and preferred to ask a new question here (and not as a comment to the other question) because it is … a new question. :-)

– PerlDuck
Dec 29 '18 at 15:31













Thanks, I took the line out about the new question! I followed the steps in the linked thread, so I should have replaced the swapfile, and I think its name is swapfile. The result of grep swap /etc/fstab is this: /dev/mapper/ubuntu--vg-swap_1 none swap sw 0 0. System Monitor shows me booting with 1 Gb of swap.

– Justin Sharber
Dec 29 '18 at 15:40







Thanks, I took the line out about the new question! I followed the steps in the linked thread, so I should have replaced the swapfile, and I think its name is swapfile. The result of grep swap /etc/fstab is this: /dev/mapper/ubuntu--vg-swap_1 none swap sw 0 0. System Monitor shows me booting with 1 Gb of swap.

– Justin Sharber
Dec 29 '18 at 15:40















Maybe you don't enough space to increase the size!

– George Udosen
Dec 29 '18 at 15:44





Maybe you don't enough space to increase the size!

– George Udosen
Dec 29 '18 at 15:44













@GeorgeUdosen - I have plenty of free space, using 70 out of 120 Gb on the HD. Also, I successfully increased the swap -- it just didn't stay increased on reboot.

– Justin Sharber
Dec 29 '18 at 15:55







@GeorgeUdosen - I have plenty of free space, using 70 out of 120 Gb on the HD. Also, I successfully increased the swap -- it just didn't stay increased on reboot.

– Justin Sharber
Dec 29 '18 at 15:55












1 Answer
1






active

oldest

votes


















0














Your /etc/fstab contains the line



/dev/mapper/ubuntu--vg-swap_1 none swap sw 0 0


This means you have a swap partition on a logical volume group. With the command from that
other post you created a swap file. Increasing the size of a swap partition is more
complicated (and I don't have enough experience with LVGs to tell you exactly how that would be done).



With Ubunutu 17 (I guess) they switched from swap partitions to swapfiles which are
easier to handle. Both is still supported and valid, they just decided that on a freshly installed
system a swapfile instead of a partition is created.



You already created the swapfile, now you only need to add it to
the /etc/fstab. Open the file in an editor (sudo vim /etc/fstab) and add the
following line (assuming your swapfile is called /swapfile):



/swapfile none swap sw 0 0


Now run



sudo swapon -a


This will mount the swapfile in addition to the already mounted swap partition. That is:
you will now have both a swap partition and a swapfile. You can leave that as it is
(and have both) or remove the line referring to the partition
(/dev/mapper/ubuntu--vg-swap_1 …) and later remove that whole swap partition.



Whatever you do, the crucial point is to add the location of your swap space(s) to the
/etc/fstab so it gets mounted while booting.



I do not know whether it is a good idea to have two or more swap spaces (one partition and
one file) and whether there are drawbacks, but it is possible.






share|improve this answer


























  • Thank you, this was critically helpful. I decided to reinstall instead. The result was I didn't have the interfering swap partition. Then the swap file responded to the standard terminal commands and held the configuration on reboot. My system performance is good!

    – Justin Sharber
    Dec 31 '18 at 14:14











  • @JustinSharber You are welcome. Nice to hear I could help you.

    – PerlDuck
    Dec 31 '18 at 14:25











Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "89"
};
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: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
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%2faskubuntu.com%2fquestions%2f1105390%2fhow-to-change-the-swap-file-size-permanently%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














Your /etc/fstab contains the line



/dev/mapper/ubuntu--vg-swap_1 none swap sw 0 0


This means you have a swap partition on a logical volume group. With the command from that
other post you created a swap file. Increasing the size of a swap partition is more
complicated (and I don't have enough experience with LVGs to tell you exactly how that would be done).



With Ubunutu 17 (I guess) they switched from swap partitions to swapfiles which are
easier to handle. Both is still supported and valid, they just decided that on a freshly installed
system a swapfile instead of a partition is created.



You already created the swapfile, now you only need to add it to
the /etc/fstab. Open the file in an editor (sudo vim /etc/fstab) and add the
following line (assuming your swapfile is called /swapfile):



/swapfile none swap sw 0 0


Now run



sudo swapon -a


This will mount the swapfile in addition to the already mounted swap partition. That is:
you will now have both a swap partition and a swapfile. You can leave that as it is
(and have both) or remove the line referring to the partition
(/dev/mapper/ubuntu--vg-swap_1 …) and later remove that whole swap partition.



Whatever you do, the crucial point is to add the location of your swap space(s) to the
/etc/fstab so it gets mounted while booting.



I do not know whether it is a good idea to have two or more swap spaces (one partition and
one file) and whether there are drawbacks, but it is possible.






share|improve this answer


























  • Thank you, this was critically helpful. I decided to reinstall instead. The result was I didn't have the interfering swap partition. Then the swap file responded to the standard terminal commands and held the configuration on reboot. My system performance is good!

    – Justin Sharber
    Dec 31 '18 at 14:14











  • @JustinSharber You are welcome. Nice to hear I could help you.

    – PerlDuck
    Dec 31 '18 at 14:25
















0














Your /etc/fstab contains the line



/dev/mapper/ubuntu--vg-swap_1 none swap sw 0 0


This means you have a swap partition on a logical volume group. With the command from that
other post you created a swap file. Increasing the size of a swap partition is more
complicated (and I don't have enough experience with LVGs to tell you exactly how that would be done).



With Ubunutu 17 (I guess) they switched from swap partitions to swapfiles which are
easier to handle. Both is still supported and valid, they just decided that on a freshly installed
system a swapfile instead of a partition is created.



You already created the swapfile, now you only need to add it to
the /etc/fstab. Open the file in an editor (sudo vim /etc/fstab) and add the
following line (assuming your swapfile is called /swapfile):



/swapfile none swap sw 0 0


Now run



sudo swapon -a


This will mount the swapfile in addition to the already mounted swap partition. That is:
you will now have both a swap partition and a swapfile. You can leave that as it is
(and have both) or remove the line referring to the partition
(/dev/mapper/ubuntu--vg-swap_1 …) and later remove that whole swap partition.



Whatever you do, the crucial point is to add the location of your swap space(s) to the
/etc/fstab so it gets mounted while booting.



I do not know whether it is a good idea to have two or more swap spaces (one partition and
one file) and whether there are drawbacks, but it is possible.






share|improve this answer


























  • Thank you, this was critically helpful. I decided to reinstall instead. The result was I didn't have the interfering swap partition. Then the swap file responded to the standard terminal commands and held the configuration on reboot. My system performance is good!

    – Justin Sharber
    Dec 31 '18 at 14:14











  • @JustinSharber You are welcome. Nice to hear I could help you.

    – PerlDuck
    Dec 31 '18 at 14:25














0












0








0







Your /etc/fstab contains the line



/dev/mapper/ubuntu--vg-swap_1 none swap sw 0 0


This means you have a swap partition on a logical volume group. With the command from that
other post you created a swap file. Increasing the size of a swap partition is more
complicated (and I don't have enough experience with LVGs to tell you exactly how that would be done).



With Ubunutu 17 (I guess) they switched from swap partitions to swapfiles which are
easier to handle. Both is still supported and valid, they just decided that on a freshly installed
system a swapfile instead of a partition is created.



You already created the swapfile, now you only need to add it to
the /etc/fstab. Open the file in an editor (sudo vim /etc/fstab) and add the
following line (assuming your swapfile is called /swapfile):



/swapfile none swap sw 0 0


Now run



sudo swapon -a


This will mount the swapfile in addition to the already mounted swap partition. That is:
you will now have both a swap partition and a swapfile. You can leave that as it is
(and have both) or remove the line referring to the partition
(/dev/mapper/ubuntu--vg-swap_1 …) and later remove that whole swap partition.



Whatever you do, the crucial point is to add the location of your swap space(s) to the
/etc/fstab so it gets mounted while booting.



I do not know whether it is a good idea to have two or more swap spaces (one partition and
one file) and whether there are drawbacks, but it is possible.






share|improve this answer















Your /etc/fstab contains the line



/dev/mapper/ubuntu--vg-swap_1 none swap sw 0 0


This means you have a swap partition on a logical volume group. With the command from that
other post you created a swap file. Increasing the size of a swap partition is more
complicated (and I don't have enough experience with LVGs to tell you exactly how that would be done).



With Ubunutu 17 (I guess) they switched from swap partitions to swapfiles which are
easier to handle. Both is still supported and valid, they just decided that on a freshly installed
system a swapfile instead of a partition is created.



You already created the swapfile, now you only need to add it to
the /etc/fstab. Open the file in an editor (sudo vim /etc/fstab) and add the
following line (assuming your swapfile is called /swapfile):



/swapfile none swap sw 0 0


Now run



sudo swapon -a


This will mount the swapfile in addition to the already mounted swap partition. That is:
you will now have both a swap partition and a swapfile. You can leave that as it is
(and have both) or remove the line referring to the partition
(/dev/mapper/ubuntu--vg-swap_1 …) and later remove that whole swap partition.



Whatever you do, the crucial point is to add the location of your swap space(s) to the
/etc/fstab so it gets mounted while booting.



I do not know whether it is a good idea to have two or more swap spaces (one partition and
one file) and whether there are drawbacks, but it is possible.







share|improve this answer














share|improve this answer



share|improve this answer








edited Dec 29 '18 at 16:35

























answered Dec 29 '18 at 16:28









PerlDuckPerlDuck

5,90711333




5,90711333













  • Thank you, this was critically helpful. I decided to reinstall instead. The result was I didn't have the interfering swap partition. Then the swap file responded to the standard terminal commands and held the configuration on reboot. My system performance is good!

    – Justin Sharber
    Dec 31 '18 at 14:14











  • @JustinSharber You are welcome. Nice to hear I could help you.

    – PerlDuck
    Dec 31 '18 at 14:25



















  • Thank you, this was critically helpful. I decided to reinstall instead. The result was I didn't have the interfering swap partition. Then the swap file responded to the standard terminal commands and held the configuration on reboot. My system performance is good!

    – Justin Sharber
    Dec 31 '18 at 14:14











  • @JustinSharber You are welcome. Nice to hear I could help you.

    – PerlDuck
    Dec 31 '18 at 14:25

















Thank you, this was critically helpful. I decided to reinstall instead. The result was I didn't have the interfering swap partition. Then the swap file responded to the standard terminal commands and held the configuration on reboot. My system performance is good!

– Justin Sharber
Dec 31 '18 at 14:14





Thank you, this was critically helpful. I decided to reinstall instead. The result was I didn't have the interfering swap partition. Then the swap file responded to the standard terminal commands and held the configuration on reboot. My system performance is good!

– Justin Sharber
Dec 31 '18 at 14:14













@JustinSharber You are welcome. Nice to hear I could help you.

– PerlDuck
Dec 31 '18 at 14:25





@JustinSharber You are welcome. Nice to hear I could help you.

– PerlDuck
Dec 31 '18 at 14:25


















draft saved

draft discarded




















































Thanks for contributing an answer to Ask Ubuntu!


  • 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%2faskubuntu.com%2fquestions%2f1105390%2fhow-to-change-the-swap-file-size-permanently%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 change which sound is reproduced for terminal bell?

Can I use Tabulator js library in my java Spring + Thymeleaf project?

Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents