I have noticed that when the Ubuntu Server installer ‘curtin’ creates an LVM container, it does not use all of the available drive space. It seems that, when the created partition is fairly small, it selects half for the LVM container, and when the partition is bigger, for example 1 TB, it selects a smaller fraction, in a reported case 200 GB, in other words approximately 20%.
Please explain why and how the size is decided like that.
# There's no point using LVM and unconditionally filling the
# VG with a single LV, but we should use more of a smaller
# disk to avoid the user running into out of space errors
# earlier than they probably expect to.
if vg.size < 10 * (2 << 30):
# Use all of a small (<10G) disk.
lv_size = vg.size
elif vg.size < 20 * (2 << 30):
# Use 10G of a smallish (<20G) disk.
lv_size = 10 * (2 << 30)
elif vg.size < 200 * (2 << 30):
# Use half of a larger (<200G) disk.
lv_size = vg.size // 2
else:
# Use at most 100G of a large disk.
lv_size = 100 * (2 << 30)
The rationale is that LVM is a volume management layer; there’s no point in using LVM if your intent is to only have a single filesystem that uses the whole partition. Furthermore, it is trivial for the user to expand a volume post-install, but very difficult to shrink a volume post-install if more space is needed.
The above logic maximizes the chances that LVM will be useful to the user, while also being mindful of disk space issues.
Given the size requirements of a default Ubuntu server install, I think 10GiB is a better minimum LV size instead of 20GiB, and it’s the code that should be fixed to match the comments.
@nio-wiklund - While a bug report would be fine, I don’t think we have to have one as I already have a PR open consistent with @vorlon’s recommendation.