Merge pull request #737 from mwhudson/better-lvm-default

have the lv created by the guided lvm option take up 80% of the vg
This commit is contained in:
Michael Hudson-Doyle 2020-04-29 18:09:55 +12:00 committed by GitHub
commit 43081d0dd5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 8 deletions

View File

@ -750,14 +750,26 @@ class FilesystemController(SubiquityController):
spec = dict(name="ubuntu-vg", devices=set([part]))
if lvm_options and lvm_options['encrypt']:
spec['password'] = lvm_options['luks_options']['password']
# create volume group on partition
vg = self.create_volgroup(spec)
target_size = dehumanize_size("4G")
if target_size > vg.free_for_partitions:
target_size = int(vg.size*0.8)
# 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)
self.create_logical_volume(
vg=vg, spec=dict(
size=target_size,
size=lv_size,
name="ubuntu-lv",
fstype="ext4",
mount="/",

View File

@ -140,9 +140,10 @@ If the platform requires it, a bootloader partition is created on the disk.
If you choose to use LVM, two additional partitions are then created,
one for /boot and one covering the rest of the disk. An LVM volume
group is created containing the large partition. A 4 gigabyte logical
volume is created for the root filesystem. It can easily be enlarged
with standard LVM command line tools.
group is created containing the large partition. A logical volume is
created for the root filesystem, sized using some simple heuristic. It
can easily be enlarged with standard LVM command line tools (or on the
next screen).
You can also choose to encrypt LVM volume group. This will require
setting a password, that one will need to type on every boot before