|
| 1 | +#!/bin/sh |
| 2 | + |
| 3 | +DISK="" |
| 4 | + |
| 5 | +for disk in \ |
| 6 | + /sys/block/sd[a-z] \ |
| 7 | + /sys/block/sd[a-z][a-z] \ |
| 8 | + /sys/block/cciss!c[0-9]d[0-9] \ |
| 9 | + /sys/block/cciss!c[0-9]d[0-9][0-9] \ |
| 10 | + /sys/block/cciss!c[0-9][0-9]d[0-9] \ |
| 11 | + /sys/block/cciss!c[0-9][0-9]d[0-9][0-9] \ |
| 12 | + /sys/block/xvd[a-z] \ |
| 13 | + /sys/block/xvd[a-z][a-z] \ |
| 14 | + /sys/block/vd[a-z] \ |
| 15 | + /sys/block/vd[a-z][a-z] \ |
| 16 | + /sys/block/hd[a-z] \ |
| 17 | + /sys/block/nvme[0-9]n[0-9] \ |
| 18 | + ; |
| 19 | +do |
| 20 | + [ -d "$disk" ] || continue |
| 21 | + |
| 22 | + # Ignore removable and virtual devices. |
| 23 | + |
| 24 | + if [ -f "$disk"/removable ]; then |
| 25 | + if read removable junk < "$disk"/removable; then |
| 26 | + [ "$removable" != "0" ] && continue |
| 27 | + fi |
| 28 | + fi |
| 29 | + |
| 30 | + if [ -f "$disk"/device/vendor -a -f "$disk"/device/model ]; then |
| 31 | + if read vendor junk < "$disk"/device/vendor && \ |
| 32 | + read model junk < "$disk"/device/model; then |
| 33 | + [ "$vendor" != "VMware" -a "$model" = "Virtual" ] && continue |
| 34 | + fi |
| 35 | + fi |
| 36 | + |
| 37 | + # Found the first disk. |
| 38 | + |
| 39 | + # Convert cciss!c0d0 to cciss/c0d0 |
| 40 | + DISK="`basename $disk | sed 's@!@/@g'`" |
| 41 | + break |
| 42 | +done |
| 43 | + |
| 44 | +touch /tmp/part-include |
| 45 | + |
| 46 | +# To automatically decrypt your system, the cryptfile needs to be located in an |
| 47 | +# unencrypted portion of the system. This is *not* secure but does allow users |
| 48 | +# to go in later and change the password without needing to reformat their |
| 49 | +# systems. |
| 50 | + |
| 51 | +# For EL6 |
| 52 | +if [ ! -d /boot ]; then |
| 53 | + mkdir /boot |
| 54 | +fi |
| 55 | + |
| 56 | +grep -q simp_disk_crypt /proc/cmdline || grep -q simp_crypt_disk /proc/cmdline |
| 57 | +encrypt=$? |
| 58 | + |
| 59 | +if [ $encrypt -eq 0 ]; then |
| 60 | + cat /dev/random | LC_CTYPE=C tr -dc "[:alnum:]" | head -c 256 > /boot/disk_creds |
| 61 | + passphrase=`cat /boot/disk_creds` |
| 62 | + |
| 63 | + echo $DISK > /boot/crypt_disk |
| 64 | +fi |
| 65 | + |
| 66 | +# This parses out some command line options generally only used by the |
| 67 | +# DVD, but available to PXE clients as well. |
| 68 | + |
| 69 | +simp_opt=`awk -F "simp_opt=" '{print $2}' /proc/cmdline | cut -f1 -d' '` |
| 70 | + |
| 71 | +if [ "$simp_opt" == "prompt" ]; then |
| 72 | + # This is the recommended workaround for a RedHat bug (BZ#1954408) where |
| 73 | + # the installation program attempts to perform automatic partitioning, even |
| 74 | + # when you do not specify any partitioning commands in the kickstart file. |
| 75 | + # https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/8/html/8.4_release_notes/known-issues#known-issue_installer-and-image-creation |
| 76 | + # This will cause the "Installation Destination" icon to show an "Kickstart |
| 77 | + # insufficient" error, which, in turn, will force the user to partition the |
| 78 | + # disks manually. |
| 79 | + echo "reqpart" > /tmp/part-include |
| 80 | +else |
| 81 | + cat << EOF > /tmp/part-include |
| 82 | +clearpart --all --initlabel --drives=${DISK} |
| 83 | +part /boot --fstype=ext4 --size=1024 --ondisk ${DISK} --asprimary --fsoptions=nosuid,nodev |
| 84 | +part /boot/efi --fstype=efi --size=400 --ondisk ${DISK} --asprimary |
| 85 | +EOF |
| 86 | + |
| 87 | +# In EL8 (8.2) the partitioning fails if --encrypted is used and the size=1. |
| 88 | +# The size was set to equal the sum of all the logical partitions (20G) to prevent this. |
| 89 | +# You can probably use a smaller size but we have not, at this time, determined how |
| 90 | +# small the initial size of the partion can to be to prevent the error. |
| 91 | + |
| 92 | + if [ $encrypt -eq 0 ]; then |
| 93 | + echo "part pv.01 --size=20480 --grow --ondisk ${DISK} --encrypted --passphrase=${passphrase}" >> /tmp/part-include |
| 94 | + else |
| 95 | + echo "part pv.01 --size=1 --grow --ondisk ${DISK}" >> /tmp/part-include |
| 96 | + fi |
| 97 | +fi |
| 98 | + |
| 99 | +if [ "$simp_opt" != "prompt" ]; then |
| 100 | + cat << EOF >> /tmp/part-include |
| 101 | +volgroup VolGroup00 pv.01 |
| 102 | +logvol swap --fstype=swap --name=SwapVol --vgname=VolGroup00 --size=1024 |
| 103 | +logvol / --fstype=ext4 --name=RootVol --vgname=VolGroup00 --size=10240 --fsoptions=iversion |
| 104 | +logvol /tmp --fstype=ext4 --name=TmpVol --vgname=VolGroup00 --size=2048 --fsoptions=nosuid,noexec,nodev |
| 105 | +logvol /home --fstype=ext4 --name=HomeVol --vgname=VolGroup00 --size=1024 --fsoptions=nosuid,noexec,nodev,iversion |
| 106 | +logvol /var --fstype=ext4 --name=VarVol --vgname=VolGroup00 --size=1024 --grow |
| 107 | +logvol /var/log --fstype=ext4 --name=VarLogVol --vgname=VolGroup00 --size=4096 --fsoptions=nosuid,noexec,nodev |
| 108 | +logvol /var/log/audit --fstype=ext4 --name=VarLogAuditVol --vgname=VolGroup00 --size=1024 --fsoptions=nosuid,noexec,nodev |
| 109 | +EOF |
| 110 | +fi |
0 commit comments