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

  • Did you change the swapfile's name? What does grep swap /etc/fstab show?
    – PerlDuck
    Dec 29, 2018 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, 2018 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.
    – jshibby
    Dec 29, 2018 at 15:40
  • Maybe you don't enough space to increase the size! Dec 29, 2018 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.
    – jshibby
    Dec 29, 2018 at 15:55

1 Answer 1


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.

  • 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!
    – jshibby
    Dec 31, 2018 at 14:14
  • @JustinSharber You are welcome. Nice to hear I could help you.
    – PerlDuck
    Dec 31, 2018 at 14:25

You must log in to answer this question.

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