0

I started with this in my kickstart file:

%pre

#***********************************************
#
# Get disk name to generate partition
#
#***********************************************
DIR="/sys/block"

# minimum size of hard drive needed specified in GIGABYTES
MINSIZE=50

ROOTDRIVE=""

# /sys/block/*/size is in 512 byte chunks

for DEV in xvda sda sdb sdc sdd; do
  if [ -d $DIR/$DEV ]; then
    REMOVABLE=`cat $DIR/$DEV/removable`
    if (( $REMOVABLE == 0 )); then
      echo $DEV
      SIZE=`cat $DIR/$DEV/size`
      GB=$(($SIZE/2**21))
      if [ $GB -gt $MINSIZE ]; then
        echo "$(($SIZE/2**21))"
        if [ -z $ROOTDRIVE ]; then
          ROOTDRIVE=$DEV
        fi
      fi
    fi
  fi
done

echo "ROOTDRIVE=$ROOTDRIVE"

cat > /tmp/ks-partition.txt <<EOF

# System bootloader configuration
bootloader --append=" crashkernel=auto" --location=mbr --boot-drive=$ROOTDRIVE

# Clear the Master Boot Record
zerombr

# Partition clearing information
clearpart --all

# Disk partitioning information
part /boot --fstype=ext4 --ondisk=$ROOTDRIVE --size=1000
part pv.00 --fstype="lvmpv" --ondisk=$ROOTDRIVE --size=1024 --grow
volgroup vg00 pv.00
logvol swap             --fstype="swap" --size=4096 --name=swap --vgname=vg00
logvol /var/log/audit   --fstype="ext4" --percent=10 --name=var_log_audit --vgname=vg00
logvol /var/log         --fstype="ext4" --percent=10 --name=var_log --vgname=vg00
logvol /var             --fstype="ext4" --percent=10 --name=var --vgname=vg00
logvol /opt             --fstype="ext4" --percent=30 --name=opt --vgname=vg00
logvol /                --fstype="ext4" --size=1000 --grow --name=root --vgname=vg00
EOF

%end

And wittled it all the way down to what you see below before it would work (many partial changes in between). Every time I kicked it I would see something like "is_valid_stage1_device: False" in the anaconda.log and it would ask me to manually configure partitioning to continue. Any ideas?

Using 7.2 and the thing i'm kickstarting is a VM. To be clear the below works like a champ but I need/want to automate like the above.

# System bootloader configuration
bootloader --append=" crashkernel=auto" --location=mbr --boot-drive=xvda

# Clear the Master Boot Record
zerombr

# Partition clearing information
clearpart --all

# Disk partitioning information
part /boot --fstype=ext4 --ondisk=xvda --size=1000
part pv.00 --fstype="lvmpv" --ondisk=xvda --size=1024 --grow
volgroup vg00 pv.00
logvol swap             --fstype="swap" --size=4096 --name=swap --
vgname=vg00
logvol /var/log/audit   --fstype="ext4" --percent=10 --name=var_log_audit --vgname=vg00
logvol /var/log         --fstype="ext4" --percent=10 --name=var_log --vgname=vg00
logvol /var             --fstype="ext4" --percent=10 --name=var --vgname=vg00
logvol /opt             --fstype="ext4" --percent=30 --name=opt --vgname=vg00
logvol /                --fstype="ext4" --size=1000 --grow --name=root --vgname=vg00
1

Got it! It wasn't the %pre config at all... I missed the %include for the partition file... dumb.

Here's the line I added (outside of the %pre - above it in my case.)

%include /tmp/ks-partition.txt

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.