Linux – Use a dynamic value in a kickstart file

centoskickstartlinuxredhat

I have a kickstart file I would like to reuse for machines of varying disk size. Can I statically set my volume sizes but then have it allocation the rest of the space to a single volume?

For example here is the disk part of my anaconda config:

# Disk partitioning information
part /boot --fstype="xfs" --ondisk=sda --size=1024
part pv.195 --fstype="lvmpv" --ondisk=sda --size=60214
part /boot/efi --fstype="efi" --ondisk=sda --size=200 --fsoptions="umask=0077,shortname=winnt"
volgroup cl --pesize=4096 pv.195
logvol swap  --fstype="swap" --size=2048 --name=swap --vgname=cl
logvol /  --fstype="xfs" --size=58160 --name=root --vgname=cl

Id like to be able to do this for the root volume:

# Disk partitioning information
    part /boot --fstype="xfs" --ondisk=sda --size=1024
    part pv.195 --fstype="lvmpv" --ondisk=sda --size=60214
    part /boot/efi --fstype="efi" --ondisk=sda --size=200 --fsoptions="umask=0077,shortname=winnt"
    volgroup cl --pesize=4096 pv.195
    logvol swap  --fstype="swap" --size=2048 --name=swap --vgname=cl
    logvol /  --fstype="xfs" --size=<****WHATEVER SPACE IS LEFT****> --name=root --vgname=cl

So this way no matter what the disk size of the VM Im running this kickstart config for the root volume will fit what space I have.

Best Answer

You would simply need to add the --grow option to your logvol line.

From the RHEL 7 documentation:

--grow - Tells the logical volume to grow to fill available space (if any), or up to the maximum size setting, if one is specified. A minimum size must be given, using either the --percent= option or the --size= option.

Source: RHEL 7: 24.3.2 - Kickstart Commands and Options

Related Topic