0

I plan to use LVM instead of Extended MBR partition with its logical volumes. LVM is a somewhat new concept for me (in the sense that I have never before tried to use this option despite being aware of its existence) so I need some assistance.

The problem

I will have only one Volume Group placed on only one Physical Volume. I want that initial Extends of my Logical Volumes to be adjacent (volume initially contiguous). After creating all needed Logical Volumes there should be an empty space at the end of my PV for future usage (extending LV's as needed). So only the parts of LV's that later extend the initial size will be not adjacent to initial space of these LV's. Which option of lvcreate command, --alloc or --type, is intended for usage just described.

Possible solutions

The options:

--alloc contiguous|cling|cling_by_tags|normal|anywhere|inherit

--type linear|striped|snapshot|mirror|raid|thin|cache|thin-pool|cache-pool

Maybe there is an option to explicitly specify PE ranges as in pvmove command but while creating Logical Volume, not after creating it?

Something like:

pvmove /dev/sdb2:501-800   /dev/sdb2:1001-1300
pvmove /dev/sdb2:101-300   /dev/sdb2:1301-1500
pvmove /dev/sdb2:4001-5500 /dev/sdb2:1501-3000

... but with single lvcreate command instead of the above sequence which may take a long time unnecessarily:

lvcreate /dev/sdb2:1001-3000 -n home vg1

... and instead of below one that may (as I suppose) create scattered LV of the same size as above command line (if the above would have the correct syntax):

lvcreate -l 2000 -n home vg1

The cause

The reason is I don't want for my Logical Volumes (and therefore my big files on these volumes) to be too fragmented. The one option is to use really big Extends (64 MiB or 128 MiB) but I think there should be (and probably is) an option that additionally make my files less fragmented and scattered over my drive.

In short

  • What is the difference between --alloc and --type options?
  • Which one should I use and with what argument?
  • If none of these options can achieve what I want, then what I can do instead of creating scattered volume and then moving (by pvmove) each of its range so that the whole volume would be contiguous.
  • Can the initial range of PE's be specified at creation time?
0

If you are starting with a brand new PV, then when you create LVs, by default, it will allocate the PE's contiguously; because it can. You don't need to specify --alloc contiguous when creating the LVs.

When extending the LVs, as you stated, the PE's would no longer be contiguous. What this boils down to, is that the behaviour you're seeking is what LVM does by default.

However, you can make this behaviour more explicit by:

  1. Creating the LV's with --alloc contiguous
  2. Changing the LV's allocation policy back to normal with lvchange; You can do this at any time after creating the LV's.
  • Thank you very much! – MweeyLoo Oct 26 '19 at 17:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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