1
  1. Why does the default installation make one choose either LVM or SWAP file (vs. partition)? See here.

  2. Further, is it possible to change either option later (post-installation), i.e., either switch to a SWAP file (dropping the SWAP partition), or switching to LVM with the SWAP file running?


Related:

Ravexina
  • 55,668
  • 25
  • 164
  • 183

1 Answers1

4

The answer to your first question is somehow opinion based.

The idea is that a swapfile is a better option because you can easily increase/decrease its size or even remove it and use the free space for other purposes without any further steps. I guess because of these advantages they decide to move toward swapfiles:

Today, carving a partition and reserving twice the RAM size for swap makes little sense. [...] Or if said [partition based] swap space is in use but is of inappropriate size, changing it in-place in retrospect is painful.

Why they didn't implement it for LVM? I think that's because LVM snapshots don't exclude the swapfile changes but having swap in a separate logical volume works around the issue:

On LVM based installations, swap logical volumes are used, since unfortunately LVM snapshots do not exclude swapfile changes.

(Quotes are from a 2016 blog post by Dimitri John Ledkov who was employed by Canonical at the time of the entries were written)

Second question: somehow yes, you can install your system using LVM, remove the swap logical volume, add its size to other volumes like root (or any other place you want) and then create a new swapfile. You can also do the reverse - remove the swapfile, decrease the size of the FS and volume it was in and add a new swap partition.

However converting the basic installation to LVM is not possible unless you do tricky stuff.

Anon
  • 312
Ravexina
  • 55,668
  • 25
  • 164
  • 183
  • Installing with LVM option resulted in me having a 17GB swap partition... somehow I got the impression a lean swap file would just make more sense? – nutty about natty Jul 03 '17 at 20:03
  • Yeah, however if you see my update... instead of removing the swap partition you can just decrease its size and add it to other partitions. – Ravexina Jul 03 '17 at 20:05
  • you mean: add the disk space *freed up by decreasing* the size of the original swap partition to other partition(s), right? – nutty about natty Jul 03 '17 at 20:20
  • 2
    You should read a little bit about how LVM works, you've got a volume group, you should use lvreduce to decease your swap partition's size. now the freed up space is available in your volume group and you can use lvextend to add it to other partitions, /, /home or whatever. – Ravexina Jul 03 '17 at 20:43