Compare commits

...

3 Commits

Author SHA1 Message Date
345b29b84c Flip ID to end of detect string
This just seems to "flow" more for me.
2021-12-24 15:29:53 -05:00
e1fa427ddd Add delay during checkin script 2021-12-20 04:44:23 -05:00
87a0251fe0 Replace block zeroing with wipefs
This is very time consuming and intensive on the disks and really
doesn't do anything, so use wipefs.
2021-12-20 01:24:47 -05:00
2 changed files with 17 additions and 52 deletions

View File

@ -31,11 +31,6 @@ addpkglist="{{ addpkglist }}"
filesystem="{{ filesystem }}"
{% endif %}
{%- if skip_blockcheck is defined and skip_blockcheck %}
# Skip block zeroing; only recommended for testing, slow, low-endurance, or known-zeroed block devices.
skip_blockcheck="y"
{% endif %}
###
### Per-host definitions (required)
###

View File

@ -210,6 +210,7 @@ seed_config() {
host_macaddr=$( ip -br link show ${target_interface} | awk '{ print $3 }' )
host_ipaddr=$( ip -br address show ${target_interface} | awk '{ print $3 }' | awk -F '/' '{ print $1 }' )
o_target_disk="${target_disk}"
# Handle the target disk
case "${target_disk}" in
/dev/*)
@ -219,12 +220,12 @@ seed_config() {
detect:*)
# Read the detect string into separate variables
# A detect string is formated thusly:
# detect:<Controller-or-Model-Name>:<0-indexed-ID>:<Capacity-in-human-units>
# detect:<Controller-or-Model-Name>:<Capacity-in-human-units><0-indexed-ID>
# For example:
# detect:INTEL:1:800GB
# detect:DELLBOSS:0:240GB
# detect:PERC H330 Mini:0:200GB
IFS=: read detect b_name b_id b_size <<<"${target_disk}"
# detect:INTEL:800GB:1
# detect:DELLBOSS:240GB:0
# detect:PERC H330 Mini:200GB:0
IFS=: read detect b_name b_size b_id <<<"${target_disk}"
# Get the lsscsi output (exclude NVMe)
lsscsi_data_all="$( lsscsi -s -N )"
# Get the available sizes, and match to within +/- 2%
@ -272,7 +273,7 @@ EOF
esac
if [[ ! -b ${target_disk} ]]; then
echo "Invalid disk or disk not found!"
echo "Invalid disk or disk not found for '${o_target_disk}'!"
exit 1
fi
@ -376,15 +377,6 @@ interactive_config() {
fi
echo
done
echo "2c) Skip disk zeroing? Only recommended for slow, low-endurance, or known-"
echo -n "zeroed block devices. [y/N] "
read skip_blockcheck
if [[ ${skip_blockcheck} == 'y' || ${skip_blockcheck} == 'Y' ]]; then
skip_blockcheck="y"
else
skip_blockcheck=""
fi
echo
for interface in $( ip address | grep '^[0-9]' | grep 'eno\|enp\|ens\|wlp' | awk '{ print $2 }' | tr -d ':' ); do
ip link set ${interface} up
@ -690,47 +682,21 @@ for pv in $( pvscan | grep "${target_disk}" | awk '{ print $2 }' ); do
done
echo "done."
blockcheck() {
# Skip checking if the key is set
if [[ -n ${skip_blockcheck} ]]; then
return
fi
echo -n "Wiping partition signatures on '${target_disk}'... "
wipefs -a ${target_disk} >&2
echo "done."
# Determine optimal block size for zeroing
exponent=16
remainder=1
while [[ ${remainder} -gt 0 && ${exponent} -gt 0 ]]; do
exponent=$(( ${exponent} - 1 ))
size=$(( 2**9 * 2 ** ${exponent} ))
count=$(( ${blockdev_size_bytes} / ${size} ))
remainder=$(( ${blockdev_size_bytes} - ${count} * ${size} ))
done
if [[ ${remainder} -gt 0 ]]; then
echo "Failed to find a suitable block size for wiping... skipping."
return
fi
echo -n "Checking if block device '${target_disk}' is already wiped... "
if ! cmp --silent --bytes ${blockdev_size_bytes} /dev/zero ${target_disk}; then
echo "false."
echo "Wiping block device '${target_disk}' (${count} blocks of ${size} bytes)..."
dd if=/dev/zero of=${target_disk} bs=${size} count=${count} oflag=direct status=progress 2>&1
else
echo "done."
fi
}
blockcheck
echo -n "Preparing block device '${target_disk}'... "
echo -n "Preparing GPT partitions on '${target_disk}'... "
# New GPT, part 1 32MB BIOS boot, part 2 64MB ESP, part 3 928MB BOOT, part 4 inf LVM PV
echo -e "o\ny\nn\n1\n\n32M\nEF02\nn\n2\n\n64M\nEF00\nn\n3\n\n928M\n8300\nn\n4\n\n\n8E00\nw\ny\n" | gdisk ${target_disk} >&2
echo "done."
echo -n "Rescanning disks... "
partprobe >&2 || true
sleep 5
echo "done."
echo -n "Creating LVM PV... "
echo -n "Creating LVM PV on '${target_disk}4'... "
yes | pvcreate -ffy ${target_disk}4 >&2
echo "done."
@ -887,6 +853,7 @@ host_macaddr=\$( ip -br link show \${target_interface} | awk '{ print \$3 }' )
host_ipaddr=\$( ip -br address show \${target_interface} | awk '{ print \$3 }' | awk -F '/' '{ print \$1 }' )
bmc_macaddr=\$( ipmitool lan print | grep 'MAC Address ' | awk '{ print \$NF }' )
bmc_ipaddr=\$( ipmitool lan print | grep 'IP Address ' | awk '{ print \$NF }' )
if [[ -f /etc/pvc-install.hooks ]]; then
# The third boot, when all hooks have been completed
action="system-boot_completed"
@ -897,6 +864,9 @@ else
# The first boot, when Ansible has not been run yet
action="system-boot_initial"
fi
sleep 30
curl -X POST \
-H "Content-Type: application/json" \
-d "{\"action\":\"\${action}\",\"hostname\":\"\$( hostname -s )\",\"host_macaddr\":\"\${host_macaddr}\",\"host_ipaddr\":\"\${host_ipaddr}\",\"bmc_macaddr\":\"\${bmc_macaddr}\",\"bmc_ipaddr\":\"\${bmc_ipaddr}\"}" \