Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I am setting up a machine to run a number of virtual machines. I am using a single HDD with a boot partition and an LVM partition. I read on the Arch wiki that logcial volumes which will be used for swap should be setup with -C y

To create a contiguous partition, which means that your swap space does not get partitioned over one or more disks nor over non-contiguous physical extents.

How important is this? If i have a dozen VMs each with a contiguous logical volume for swap and a non-contiguous logical volume for /, how will having so many contiguous logical volumes affect my ability to resize logical volumes (either contiguous or non-contiguous)?

share|improve this question
add comment

2 Answers

up vote 2 down vote accepted

I am not aware of any requirement that swap space be contiguous on disk under Linux, with LVM or otherwise. I have never arranged for my swap LVs to be contiguous and have never run into any problem (it's possible that all my swap LVs just happened to be contiguous, I've never looked).

Linux supports non-contiguous swap files, it would be odd to have such a restriction on LVM volumes. I can't find any reference to this in any official documentation or anyone explaning why swap LVs should be contiguous. This has all the hallmarks of an urban legend.

The origin may lie in HP-UX, which Linux's LVM is partly inspired from, and which did (does?) require swap space to be contiguous. I don't know that this has ever been the case on Linux.

There may be a perceived performance benefit, but with 4MB extents, I very much doubt there is any performance benefit, and I can't find any benchmark.

If you have volume groups that span over multiple disks, you may want to constrain what PV the swap LV is on. But I wouldn't require a contiguous volume.

share|improve this answer
add comment

If these volumes are to be exposed to the VM's as their own devices, then they won't be able to tell the difference. Unless your PE size is really small, it shouldn't matter if the extents are contiguous or not.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.