Refactor kickstarts to integrate multipath support
Refactor kickstart.cfg and miniboot.cfg device management to support to support multipath disks. This includes: - Improving function names for clarity - Improving function docs (params, returns, examples) - Add get_part_prefix() to provide a common function used to dynamically build the partition device names - Add discovery of multipath disks as an install media option if no instdev is provided. - Add support for by-id/wwn-* multipath persistent device names. This is in addition to by-path/* HDD/SSD/NVMe persistent device names which enables consistent disk usage, across reboots, irrespective of kernel device node enumeration inconsistencies. Test Plan: PASS - AIO-SX: HPE multipath install/bootstrap/unlock PASS - AIO-SX: Qemu virtual multipath install/bootstrap/unlock PASS - AIO-DX: Qemu virtual multipath install/bootstrap/unlock PASS - AIO-DX+: Qemu virtual multipath install/bootstrap/unlock PASS - 2+2 (controller storage): Qemu virtual multipath install/ bootstrap/unlock PASS - 2+2+2 (dedicated storage): Qemu virtual multipath install/ bootstrap/unlock PASS - Add OSD ceph storage configuration (AIO-SX) PASS - Expand cgts volume group using extra disk (Partition) (AIO-SX) PASS - Expand cgts volume group using extra disk (disk) (AIO-SX) PASS - Add nova local volume group using extra disk (AIO-SX) PASS - App pod that allocates and writes into a PVC (AIO-SX) PASS - Local disk commands (Disk API) - AIO-SX/DX - host-disk-list - host-disk-show - host-disk-partition-list - host-disk-partition-show - host-pv-list - host-pv-show - host-stor-list - host-stor-show - host-lvg-list - host-lvg-show - host-pv-add PASS - Create nova-local volume group PASS - Local disk commands on AIO-DX after swact Regression: PASS - AIO-SX: Non-multipath install/bootstrap/unlock (NVME) PASS - AIO-DX: Non-multipath install/bootstrap/unlock (SSD) PASS - 2+2: Non-multipath install/bootstrap/unlock (SSD) PASS - 2+2+2 : Non-multipath install/bootstrap/unlock (SSD and HD) PASS - Distributed cloud: Non-multipath install/bootstrap/unlock Change-Id: I8b7ab349d9991810d4faad9c3f7e3be625d6ed5c Depends-On: https://review.opendev.org/c/starlingx/tools/+/860590 Story: 2010046 Task: 46567 Co-Authored-By: Matheus Guilhermino <matheus.machadoguilhermino@windriver.com> Co-Authored-By: Robert Church <robert.church@windriver.com> Signed-off-by: Adriano Oliveira <adriano.oliveira@windriver.com> Signed-off-by: Robert Church <robert.church@windriver.com>
This commit is contained in:
parent
acbd301a1c
commit
a446585145
kickstart/files
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2022 Wind River Systems, Inc.
|
||||
# Copyright (c) 2022-2023 Wind River Systems, Inc.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
############################################################################
|
||||
@ -144,8 +144,14 @@ function report_failure_with_msg()
|
||||
|
||||
########################################################################
|
||||
# Name : get_disk
|
||||
# Parameters: \$1 - ??????
|
||||
# Returns : No return but common disk name is echo's to stdio
|
||||
# Parameters: \$1 - any disk path
|
||||
# Returns : echo of the canonicalized version of the disk path
|
||||
#
|
||||
# Example : /dev/sda -> /dev/sda
|
||||
# : /dev/nvme1n1 -> /dev/nvme1n1
|
||||
# : /dev/disk/by-path/pci-0000:02:00.0-scsi-0:1:0:0 -> /dev/sda
|
||||
# : /dev/disk/by-id/wwn-0x50014ee6ae58b07f -> /dev/sdc
|
||||
# : /dev/disk/by-id/wwn-0x600508b1001c2a30 -> /dev/dm-0
|
||||
#########################################################################
|
||||
function get_disk()
|
||||
{
|
||||
@ -153,50 +159,101 @@ function get_disk()
|
||||
}
|
||||
|
||||
#########################################################################
|
||||
# Name : get_by_path
|
||||
# Name : get_persistent_disk
|
||||
# Parameters: \$1 - device name i.e. /dev/sda
|
||||
# Returns : echo of device name by-path
|
||||
# example: /dev/disk/by-path/pci-0000:03:00.0-scsi-0:2:0:0
|
||||
# Returns : echo of device name by-path or by-id
|
||||
# example: /dev/disk/by-path/pci-0000:03:00.0-scsi-0:2:0:0 or
|
||||
# /dev/disk/by-id/wwn-0x50014ee6ae58b07f
|
||||
#
|
||||
# Notes: During kickstarts there are 2 links to a generic /dev/sd<X>.
|
||||
# Example: pci-0000:00:1f.2-ata-1 and pci-0000:00:1f.2-ata-1.0.
|
||||
# After reboot only the longer 'ata-1.0' exists.
|
||||
# Reverse the parsing so we return the longer path.
|
||||
#########################################################################
|
||||
function get_by_path()
|
||||
function get_persistent_disk()
|
||||
{
|
||||
# log "Function: get_by_path '\${1}'"
|
||||
local disk=\$(cd /dev ; readlink -f \$1)
|
||||
reverse_list=""
|
||||
for p in /dev/disk/by-path/*; do
|
||||
reverse_list="\${p} \${reverse_list}"
|
||||
done
|
||||
for p in \${reverse_list}; do
|
||||
if [ "\$disk" = "\$(readlink -f \$p)" ]; then
|
||||
echo "\$p"
|
||||
return
|
||||
fi
|
||||
done
|
||||
local dev=\$(cd /dev ; readlink -f \$1)
|
||||
case \$dev in
|
||||
*"dm-"*)
|
||||
for p in /dev/disk/by-id/wwn-*; do
|
||||
if [ "\$(basename \$dev)" = "\$(basename \$(readlink -f \$p))" ]; then
|
||||
echo "\$p"
|
||||
return
|
||||
fi
|
||||
done
|
||||
;;
|
||||
*)
|
||||
reverse_list=""
|
||||
for p in /dev/disk/by-path/*; do
|
||||
reverse_list="\${p} \${reverse_list}"
|
||||
done
|
||||
for p in \${reverse_list}; do
|
||||
if [ "\$(basename \$dev)" = "\$(basename \$(readlink -f \$p))" ]; then
|
||||
echo "\$p"
|
||||
return
|
||||
fi
|
||||
done
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
#########################################################################
|
||||
# Name : get_disk_dev
|
||||
# Purpose : get the disk name
|
||||
# Returns : echo of the first disk name found ; base on coded priority
|
||||
# Name : get_part_prefix
|
||||
# Parameters: \$1 - device name i.e. /dev/sda, /dev/nvme0n1, /dev/dm-0
|
||||
# Returns : echo of acceptable partition prefix
|
||||
# example: /dev/sda
|
||||
# /dev/nvme0n1p
|
||||
# /dev/disk/by-id/wwn-0x50014ee6ae58b07f-part
|
||||
#########################################################################
|
||||
function get_disk_dev()
|
||||
function get_part_prefix()
|
||||
{
|
||||
# ensure that we have a canonicalized device
|
||||
local dev=\$(cd /dev ; readlink -f \$1)
|
||||
case \$dev in
|
||||
*"nvme"*)
|
||||
echo "\${dev}p"
|
||||
;;
|
||||
*"dm-"*)
|
||||
for p in /dev/disk/by-id/wwn-*; do
|
||||
if [ "\$dev" = "\$(readlink -f \${p})" ]; then
|
||||
echo "\${p}-part"
|
||||
return
|
||||
fi
|
||||
done
|
||||
;;
|
||||
*)
|
||||
echo "\${dev}"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
#########################################################################
|
||||
# Name : get_default_install_disk
|
||||
# Purpose : Called when no install disk is provided. Will "discover" an
|
||||
# install disk. Limited to "a" and "b" devices so that if the
|
||||
# "a" device is a USB device it can be skipped.
|
||||
# Returns : echo of the first disk name found ; base on coded priority
|
||||
#
|
||||
# Rules : Look for a HDD/SSD device, an NVMe device, and finally a
|
||||
# multipath device
|
||||
#########################################################################
|
||||
function get_default_install_disk()
|
||||
{
|
||||
local disk
|
||||
# Detect HDD
|
||||
# Detect a HDD first and make sure it is not part of a mulitpath device
|
||||
for blk_dev in vda vdb sda sdb dda ddb hda hdb; do
|
||||
if [ -d /sys/block/\$blk_dev ]; then
|
||||
disk=\$(ls -l /sys/block/\$blk_dev | grep -v usb | head -n1 | sed 's/^.*\([vsdh]d[a-z]\+\).*\$/\1/');
|
||||
if [ -n "\$disk" ]; then
|
||||
# Skip if this device is part of a multipath device
|
||||
multipath -c /dev/\$disk > /dev/null && continue
|
||||
echo "\$disk"
|
||||
return
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
# An acceptable HDD/SSD has not been found, look for an NVMe disk
|
||||
for blk_dev in nvme0n1 nvme1n1; do
|
||||
if [ -d /sys/block/\$blk_dev ]; then
|
||||
disk=\$(ls -l /sys/block/\$blk_dev | grep -v usb | head -n1 | sed 's/^.*\(nvme[01]n1\).*\$/\1/');
|
||||
@ -206,6 +263,14 @@ function get_disk_dev()
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
# An acceptable NVMe disk has not been found, look for a multipath disk
|
||||
for mpath_dev in mpatha mpathb; do
|
||||
if [ -e /dev/mapper/\$mpath_dev ]; then
|
||||
echo "/dev/mapper/\$mpath_dev"
|
||||
return
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
#########################################################################
|
||||
@ -735,14 +800,6 @@ if [ "\${controller}" = true ] ; then
|
||||
else
|
||||
BACKUP_PART_NO=\${BACKUP_PART_UEFI}
|
||||
fi
|
||||
case \${INSTDEV} in
|
||||
*"nvme"*)
|
||||
BACKUP_PART=\${INSTDEV}p\${BACKUP_PART_NO}
|
||||
;;
|
||||
*)
|
||||
BACKUP_PART=\${INSTDEV}\${BACKUP_PART_NO}
|
||||
;;
|
||||
esac
|
||||
BACKUP_PART_LABEL="platform_backup"
|
||||
|
||||
# Note that the BA5EBA11-0000-1111-2222- is the prefix used by STX and it's
|
||||
@ -1023,31 +1080,23 @@ if check_prestage -eq 0 ; then
|
||||
for value in "$@"; do case "$value" in force_install) force_install=${value};; esac; done
|
||||
if [ -z "${force_install}" ]; then
|
||||
if [ -z "${rootfs_device}" ]; then
|
||||
rootfs_device=$(get_disk_dev)
|
||||
rootfs_device=$(get_default_install_disk)
|
||||
fi
|
||||
|
||||
orig_rootfs_device=$rootfs_device
|
||||
by_path_rootfs_device=$(get_by_path ${rootfs_device})
|
||||
if [ -z "${by_path_rootfs_device}" ]; then
|
||||
report_failure_with_msg "Device not found: ${orig_rootfs_device}"
|
||||
desired_rootfs_device=$rootfs_device
|
||||
persistent_rootfs_device=$(get_persistent_disk ${desired_rootfs_device})
|
||||
if [ -z "${persistent_rootfs_device}" ]; then
|
||||
report_failure_with_msg "Device not found: ${desired_rootfs_device}"
|
||||
fi
|
||||
|
||||
rootfs_device=$(get_disk ${by_path_rootfs_device})
|
||||
ilog "Found rootfs $orig_rootfs_device on: $by_path_rootfs_device->$rootfs_device."
|
||||
rootfs_device=$(get_disk ${persistent_rootfs_device})
|
||||
ilog "Desired root disk $desired_rootfs_device evaluates to: $persistent_rootfs_device->$rootfs_device."
|
||||
|
||||
part_numbers=( $(parted -s ${rootfs_device} print | awk '$1 == "Number" {i=1; next}; i {print $1}') )
|
||||
|
||||
# Get the correct rootfs prefix
|
||||
ROOTFS_PART_PREFIX=${rootfs_device}
|
||||
# Check if rootfs part is nvme (eg. /dev/nvme0n1). The partitions have a "p" in the part prefix.
|
||||
# For example, /dev/nvme0n1p1
|
||||
# So we need to add the letter "p" to get the prefix.
|
||||
# The part numbers will be used later in the code.
|
||||
case ${rootfs_device} in
|
||||
*"nvme"*)
|
||||
ROOTFS_PART_PREFIX=${ROOTFS_PART_PREFIX}p
|
||||
;;
|
||||
esac
|
||||
rootfs_part_prefix=$(get_part_prefix ${rootfs_device})
|
||||
|
||||
# temporary mount directory
|
||||
temp_mount=/mnt/temp_mount
|
||||
mkdir -p ${temp_mount}
|
||||
@ -1056,7 +1105,7 @@ if check_prestage -eq 0 ; then
|
||||
|
||||
device_list=()
|
||||
for part in "${part_numbers[@]}"; do
|
||||
device=${ROOTFS_PART_PREFIX}${part}
|
||||
device=${rootfs_part_prefix}${part}
|
||||
device_list+=(${device})
|
||||
ilog "Adding ${device}"
|
||||
done
|
||||
@ -1161,12 +1210,12 @@ fi
|
||||
# From pre_disk_setup_common.cfg
|
||||
#####################################################
|
||||
|
||||
if [ -n "$INSTDEV" ] ; then
|
||||
instdev_by_path=$(get_by_path $INSTDEV)
|
||||
if [ -z ${instdev_by_path} ] ; then
|
||||
if [ -n "${INSTDEV}" ] ; then
|
||||
persistent_instdev=$(get_persistent_disk "${INSTDEV}")
|
||||
if [ -z ${persistent_instdev} ] ; then
|
||||
report_failure_with_msg "invalid install device ${INSTDEV}"
|
||||
else
|
||||
ilog "Install device: ${INSTDEV} : ${instdev_by_path}"
|
||||
ilog "Install device: ${INSTDEV} : ${persistent_instdev}"
|
||||
fi
|
||||
fi
|
||||
|
||||
@ -1177,11 +1226,20 @@ fi
|
||||
# asynchronously so avoid using them while performing partition
|
||||
# operations.
|
||||
ilog "Detected storage devices:"
|
||||
case ${persistent_instdev} in
|
||||
*"by-id"*)
|
||||
disk_regex='/dev/disk/by-id/wwn-*'
|
||||
;;
|
||||
*)
|
||||
disk_regex='/dev/disk/by-path/*'
|
||||
;;
|
||||
esac
|
||||
|
||||
STOR_DEVS=""
|
||||
for f in /dev/disk/by-path/* ; do
|
||||
for f in ${disk_regex} ; do
|
||||
dev=$(readlink -f $f)
|
||||
# dlog "found device ${f}"
|
||||
exec_retry 2 0.5 "lsblk --nodeps --pairs $dev" | grep -q 'TYPE="disk"'
|
||||
exec_retry 2 0.5 "lsblk --nodeps --pairs $dev" | grep -q -e 'TYPE="disk"' -e 'TYPE="mpath"'
|
||||
if [ $? -eq 0 ] ; then
|
||||
# Filter out ISO disk from storage devices
|
||||
check_valid_dev $dev || continue
|
||||
@ -1224,9 +1282,9 @@ display_mount_info
|
||||
|
||||
# Consider removing since LAT already handles this failure mode
|
||||
# Ensure specified device is not a USB drive
|
||||
udevadm info --query=property --name=${INSTDEV} |grep -q '^ID_BUS=usb'
|
||||
udevadm info --query=property --name="${INSTDEV}" | grep -q '^ID_BUS=usb'
|
||||
if [ $? -eq 0 ] ; then
|
||||
report_failure_with_msg "Specified installation ($INSTDEV) device is a USB drive."
|
||||
report_failure_with_msg "Specified installation (${INSTDEV}) device is a USB drive."
|
||||
fi
|
||||
|
||||
# Log the disk setup
|
||||
@ -1300,7 +1358,9 @@ else
|
||||
|
||||
# Partition type OSD has a unique globally identifier
|
||||
CEPH_OSD_GUID="4FBD7E29-9D25-41B8-AFD0-062C0CEFF05D"
|
||||
CEPH_OSD_MPATH_GUID="4FBD7E29-8AE0-4982-BF9D-5A8D867AF560"
|
||||
CEPH_JOURNAL_GUID="45B0969E-9B03-4F30-B4C6-B4B80CEFF106"
|
||||
CEPH_JOURNAL_MPATH_GUID="45B0969E-8AE0-4982-BF9D-5A8D867AF560"
|
||||
|
||||
# Check if we wipe OSDs
|
||||
if [ "$(curl -sf http://pxecontroller:6385/v1/ihosts/wipe_osds 2>/dev/null)" = "true" ] ; then
|
||||
@ -1351,15 +1411,16 @@ else
|
||||
for part_number in "${part_numbers[@]}" ; do
|
||||
sgdisk_part_info=$(sgdisk -i $part_number $dev)
|
||||
part_type_guid=$(echo "$sgdisk_part_info" | grep "$part_type_guid_str" | awk '{print $4;}')
|
||||
if [ "$part_type_guid" == $CEPH_OSD_GUID ] ; then
|
||||
if [ "$part_type_guid" == $CEPH_OSD_GUID -o "$part_type_guid" == $CEPH_OSD_MPATH_GUID ]; then
|
||||
wlog "OSD found on $dev, skipping wipe"
|
||||
wipe_dev="false"
|
||||
break
|
||||
fi
|
||||
|
||||
exec_no_fds "$STOR_DEV_FDS" "pvs" | grep -q -e "${dev}${part_number} *ceph" -e "${dev}p${part_number} *ceph"
|
||||
if [ $? -eq 0 ] ; then
|
||||
wlog "Rook OSD found on $dev$part_number, skip wipe"
|
||||
dev_part_prefix=$(get_part_prefix "${dev}")
|
||||
exec_no_fds "$STOR_DEV_FDS" "pvs" | grep -q -e "${dev_part_prefix}${part_number} *ceph" -e "${dev_part_prefix}p${part_number} *ceph"
|
||||
if [ $? -eq 0 ]; then
|
||||
wlog "Rook OSD found on $dev_part_prefix$part_number, skip wipe"
|
||||
wipe_dev="false"
|
||||
break
|
||||
fi
|
||||
@ -1389,14 +1450,7 @@ fi
|
||||
ilog "==========="
|
||||
ilog "WIPE DISKs: ${WIPE_HDD}"
|
||||
ilog "==========="
|
||||
by_dev=${INSTDEV}
|
||||
# TODO: Avoid this loop if the INSTDEV does not have by-path in its name
|
||||
for f in /dev/disk/by-path/* ; do
|
||||
if [ "${f}" == "${INSTDEV}" ] ; then
|
||||
by_dev=$(get_disk "${INSTDEV}")
|
||||
break
|
||||
fi
|
||||
done
|
||||
inst_dev=$(get_disk "${INSTDEV}")
|
||||
for dev in ${WIPE_HDD//,/ } ; do
|
||||
ilog "Wiping $dev"
|
||||
|
||||
@ -1406,59 +1460,39 @@ for dev in ${WIPE_HDD//,/ } ; do
|
||||
# Note: Delete the first few bytes at the start and end of the partition.
|
||||
# This is required with GPT partitions because they save partition
|
||||
# info at both the start and the end of the block.
|
||||
|
||||
# Get a list of partitions for this disk
|
||||
part_numbers=( $(parted -s $dev print | awk '$1 == "Number" {i=1; next}; i {print $1}') )
|
||||
|
||||
# For each '/dev/${dev}${part_number} apply wipe rules
|
||||
for part_number in "${part_numbers[@]}" ; do
|
||||
# For each device partition apply wipe rules
|
||||
for part_number in "${part_numbers[@]}"; do
|
||||
sgdisk_part_info=$(sgdisk -i $part_number $dev)
|
||||
part_name=$(echo "$sgdisk_part_info" | grep "$part_type_name_str" | awk '{print $3;}')
|
||||
|
||||
# special handling for the install device '${INSTDEV}'
|
||||
if [ "${dev}" == "${by_dev}" ] ; then
|
||||
# special handling for the install device
|
||||
if [ "${dev}" == "${inst_dev}" ] ; then
|
||||
|
||||
# Skip over the bios, efi and boot partitions that got us here.
|
||||
# LAT handles these partitions
|
||||
case ${part_name} in
|
||||
"'bios'")
|
||||
ilog "skipping ${part_name} on ${dev}${part_number}"
|
||||
continue
|
||||
;;
|
||||
"'otaefi'")
|
||||
ilog "skipping ${part_name} on ${dev}${part_number}"
|
||||
continue
|
||||
;;
|
||||
"'otaboot'")
|
||||
ilog "skipping ${part_name} on ${dev}${part_number}"
|
||||
continue
|
||||
;;
|
||||
"'otaboot_b'")
|
||||
ilog "skipping ${part_name} on ${dev}${part_number}"
|
||||
"'bios'" | "'otaefi'" | "'otaboot'" | "'otaboot_b'")
|
||||
ilog "skipping ${part_name} on partition ${part_number} of device ${dev}"
|
||||
continue
|
||||
;;
|
||||
*)
|
||||
dlog "wipe candidate ${part_name} on ${dev}${part_number}"
|
||||
dlog "wipe candidate ${part_name} on partition ${part_number} of device ${dev}"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Deal with ssd's which have different partition labelling convention
|
||||
part=$dev$part_number
|
||||
case $part in
|
||||
*"nvme"*)
|
||||
part=${dev}p${part_number}
|
||||
;;
|
||||
esac
|
||||
|
||||
part=$(get_part_prefix "${dev}")$part_number
|
||||
if [ "${controller}" = true ] ; then
|
||||
# Skip if we already found a valid partition, look otherwise
|
||||
[ ${BACKUP_PART_FOUND} -eq 1 ] && continue
|
||||
|
||||
ilog "Looking for platform-backup partition on $part from ... instdev=${INSTDEV} device=${by_dev}"
|
||||
ilog "Looking for platform-backup partition on $part from ... instdev=${INSTDEV} device=${inst_dev} persistent_device=${persistent_instdev}"
|
||||
sgdisk_part_info=$(sgdisk -i $part_number $dev)
|
||||
part_type_guid=$(echo "$sgdisk_part_info" | grep "$part_type_guid_str" | awk '{print $4;}')
|
||||
if [ "$dev" == "${by_dev}" -a "$part_type_guid" == $BACKUP_PART_GUID ] ; then
|
||||
if [ "$dev" == "${inst_dev}" -a "$part_type_guid" == $BACKUP_PART_GUID ] ; then
|
||||
part_type_name=$(echo "$sgdisk_part_info" | grep "$part_type_name_str" | awk '{print $3,$4;}')
|
||||
BACKUP_PART_NAME=${part_type_name:1:-1}
|
||||
|
||||
@ -1491,7 +1525,7 @@ for dev in ${WIPE_HDD//,/ } ; do
|
||||
# Make sure we only recreate the backup partition on systems that are
|
||||
# known to be invalid. Detect a potential switch in BIOS vs. UEFI and
|
||||
# exit with an appropriate message.
|
||||
ilog "Discovered persistent backup partition, ${part}, is in an unexpected location. Expected: ${BACKUP_PART}."
|
||||
ilog "Discovered persistent backup partition, ${part}, is in an unexpected location. Expected on partition ${BACKUP_PART_NO}."
|
||||
if [ "$USE_UEFI_PARTITIONS" = 0 ] ; then
|
||||
# BIOS boot...
|
||||
if [ "${part_number}" == "${BACKUP_PART_UEFI}" ] ; then
|
||||
@ -1513,7 +1547,7 @@ for dev in ${WIPE_HDD//,/ } ; do
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ $WIPE_CEPH_OSDS == "true" -a "$part_type_guid" == $CEPH_JOURNAL_GUID ] ; then
|
||||
if [ "${WIPE_CEPH_OSDS}" = "true" ] && ([ "${part_type_guid}" = "${CEPH_JOURNAL_GUID}" ] || [ "${part_type_guid}" = "${CEPH_MPATH_JOURNAL_GUID}" ]); then
|
||||
# Journal partitions require additional wiping. Based on the ceph-manage-journal.py
|
||||
# script in the integ repo (at the ceph/ceph/files/ceph-manage-journal.py location)
|
||||
# wiping 100MB of data at the beginning of the partition should be enough. We also
|
||||
@ -1528,7 +1562,7 @@ for dev in ${WIPE_HDD//,/ } ; do
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ${BACKUP_PART_FOUND} -eq 0 -o "${dev}" != "${by_dev}" ] ; then
|
||||
if [ ${BACKUP_PART_FOUND} -eq 0 -o "${dev}" != "${inst_dev}" ] ; then
|
||||
ilog "Creating disk label for $dev"
|
||||
parted -s $dev mktable gpt
|
||||
ilog "... done"
|
||||
@ -1574,7 +1608,7 @@ ilog "*****************************************"
|
||||
ilog "*** Partition - Partition Disks ***"
|
||||
ilog "*****************************************"
|
||||
|
||||
dev=$(get_disk "${INSTDEV}")
|
||||
inst_dev=$(get_disk "${INSTDEV}")
|
||||
|
||||
###########################################################
|
||||
# From pre_disk_controller.cfg
|
||||
@ -1601,18 +1635,18 @@ MIB_BYTES=$((1024*1024))
|
||||
sgdisk_parts=""
|
||||
|
||||
# Get the logical sector size used for determining partition boundaries
|
||||
LOGICAL_SECTOR_SZ=`lsblk -n ${dev} -o LOG-SEC -d`
|
||||
LOGICAL_SECTOR_SZ=`lsblk -n ${inst_dev} -o LOG-SEC -d`
|
||||
|
||||
# Zap the GPT/MBR information
|
||||
sgdisk -Z ${dev}
|
||||
sgdisk -Z ${inst_dev}
|
||||
|
||||
# Get the first aligned sector
|
||||
first=`sgdisk -F ${dev} | grep -v Creating`
|
||||
first=`sgdisk -F ${inst_dev} | grep -v Creating`
|
||||
|
||||
# Get the last aligned sector
|
||||
export last=$(sgdisk -E ${dev} 2>/dev/null |grep -v Creating)
|
||||
export last=$(sgdisk -E ${inst_dev} 2>/dev/null |grep -v Creating)
|
||||
|
||||
ilog "Allocate host partitions on ${dev} with first sector: $first and last sector: $last"
|
||||
ilog "Allocate host partitions on ${inst_dev} with first sector: $first and last sector: $last"
|
||||
|
||||
# Maintain BIOS partition mappings from previous releases
|
||||
start_sec=$first
|
||||
@ -1719,8 +1753,8 @@ STOR_DEVS=$(echo "$STOR_DEVS" | xargs -n 1 | sort -u | xargs)
|
||||
[ -z "$STOR_DEVS" ] && report_failure_with_msg "No storage devices available."
|
||||
ilog "STOR_DEV_FDS Updated ; $STOR_DEV_FDS"
|
||||
|
||||
dlog "Requesting ${dev} Partition Table: ${a}"
|
||||
sgdisk $sgdisk_parts -p ${dev}
|
||||
dlog "Requesting ${inst_dev} Partition Table: ${a}"
|
||||
sgdisk $sgdisk_parts -p ${inst_dev}
|
||||
[ $? -ne 0 ] && report_failure_with_msg "sgdisk failed to create partitions: ${a}"
|
||||
|
||||
true
|
||||
@ -1742,6 +1776,7 @@ ilog "***************************************************"
|
||||
vg="volume group"
|
||||
lv="logical volume"
|
||||
dev=$(get_disk "${INSTDEV}")
|
||||
dev_part_prefix=$(get_part_prefix "${dev}")
|
||||
|
||||
if [ "${controller}" = true ] ; then
|
||||
if [ "${aio}" = true ] ; then
|
||||
@ -1755,13 +1790,6 @@ elif [ "${storage}" = true ] ; then
|
||||
get_storage_provisioning_sizes
|
||||
fi
|
||||
|
||||
fs_dev=$dev
|
||||
case ${fs_dev} in
|
||||
*"nvme"*)
|
||||
fs_dev=${fs_dev}p
|
||||
;;
|
||||
esac
|
||||
|
||||
# Maintain BIOS partition mappings from previous releases
|
||||
part_no=1
|
||||
if [ "$USE_UEFI_PARTITIONS" = 0 -o "${controller}" = false ] ; then
|
||||
@ -1771,48 +1799,45 @@ fi
|
||||
|
||||
if [ "${controller}" = true ] ; then
|
||||
ilog "BACKUP_SIZE : ${BACKUP_SIZE}"
|
||||
ilog "BACKUP_PART : ${BACKUP_PART}"
|
||||
ilog "BACKUP_PART_NO : ${BACKUP_PART_NO}"
|
||||
ilog "BACKUP_PART_LABEL : ${BACKUP_PART_LABEL}"
|
||||
ilog "BACKUP_PART_GUID : ${BACKUP_PART_GUID}"
|
||||
ilog "BACKUP_PART : ${dev_part_prefix}${BACKUP_PART_NO}"
|
||||
|
||||
# Only init Platform Backup partition filesystem if the partition was just created
|
||||
if [ ${BACKUP_PART_FOUND} -eq 0 ] ; then
|
||||
# Sanity check
|
||||
[ "${fs_dev}${part_no}" != "${BACKUP_PART}" ] && report_failure_with_msg "Abort creating platform backup filesystem, unexpected location: ${fs_dev}${part_no}"
|
||||
|
||||
ilog "Platform Backup Partition was CREATED. Initialize filesystem on ${BACKUP_PART}"
|
||||
mkfs.ext4 -F -L ${BACKUP_PART_LABEL} ${BACKUP_PART}
|
||||
[ ${?} -ne 0 ] && report_failure_with_msg "Failed Platform Backup partition filesystem init ${BACKUP_PART}"
|
||||
ilog "Platform Backup Partition was CREATED. Initialize filesystem on ${dev_part_prefix}${BACKUP_PART_NO}"
|
||||
mkfs.ext4 -F -L ${BACKUP_PART_LABEL} ${dev_part_prefix}${BACKUP_PART_NO}
|
||||
[ ${?} -ne 0 ] && report_failure_with_msg "Failed Platform Backup partition filesystem init ${dev_part_prefix}${BACKUP_PART_NO}"
|
||||
else
|
||||
# Preserving the contents of the backup partition, but make sure it's labeled correctly
|
||||
e2label ${BACKUP_PART} ${BACKUP_PART_LABEL}
|
||||
e2label ${dev_part_prefix}${BACKUP_PART_NO} ${BACKUP_PART_LABEL}
|
||||
fi
|
||||
part_no=$((part_no+1))
|
||||
fi
|
||||
|
||||
# Maintain UEFI partition mappings from previous releases
|
||||
mkfs.vfat -n otaefi ${fs_dev}${part_no}
|
||||
[ ${?} -ne 0 ] && report_failure_with_msg "Failed UEFI filesystem init: ${fs_dev}${part_no}, rc=${?}"
|
||||
mkfs.vfat -n otaefi ${dev_part_prefix}${part_no}
|
||||
[ ${?} -ne 0 ] && report_failure_with_msg "Failed UEFI filesystem init: ${dev_part_prefix}${part_no}, rc=${?}"
|
||||
part_no=$((part_no+1))
|
||||
|
||||
# Boot/Root OSTree Partition A (Note: OSTree Partition B not used)
|
||||
if [ "${PART_SZ_BOOT}" != 0 ] ; then
|
||||
mkfs.ext4 -F -L otaboot ${fs_dev}${part_no}
|
||||
[ ${?} -ne 0 ] && report_failure_with_msg "Failed Boot filesystem init: ${fs_dev}${part_no}, rc=${?}"
|
||||
mkfs.ext4 -F -L otaboot ${dev_part_prefix}${part_no}
|
||||
[ ${?} -ne 0 ] && report_failure_with_msg "Failed Boot filesystem init: ${dev_part_prefix}${part_no}, rc=${?}"
|
||||
part_no=$((part_no+1))
|
||||
fi
|
||||
|
||||
if [ "${PART_SZ_ROOT}" != 0 ] ; then
|
||||
mkfs.ext4 -F -L otaroot ${fs_dev}${part_no}
|
||||
[ ${?} -ne 0 ] && report_failure_with_msg "Failed Root filesystem init: ${fs_dev}${part_no}, rc=${?}"
|
||||
mkfs.ext4 -F -L otaroot ${dev_part_prefix}${part_no}
|
||||
[ ${?} -ne 0 ] && report_failure_with_msg "Failed Root filesystem init: ${dev_part_prefix}${part_no}, rc=${?}"
|
||||
part_no=$((part_no+1))
|
||||
fi
|
||||
|
||||
# Flux Partition
|
||||
if [ "${LV_SZ_VAR}" = 0 -a "${INSTFLUX}" = 1 ] ; then
|
||||
mkfs.ext4 -F -L fluxdata ${fs_dev}${part_no}
|
||||
[ ${?} -ne 0 ] && report_failure_with_msg "Failed Fluxdata (/var) filesystem init: ${fs_dev}${part_no}, rc=${?}"
|
||||
mkfs.ext4 -F -L fluxdata ${dev_part_prefix}${part_no}
|
||||
[ ${?} -ne 0 ] && report_failure_with_msg "Failed Fluxdata (/var) filesystem init: ${dev_part_prefix}${part_no}, rc=${?}"
|
||||
part_no=$((part_no+1))
|
||||
fi
|
||||
|
||||
@ -1820,10 +1845,10 @@ fi
|
||||
log_lvm_conf "Installer Initial" /etc/lvm/lvm.conf
|
||||
|
||||
# Create Volume Group
|
||||
pv_part=${fs_dev}${part_no}
|
||||
pv_part=${dev_part_prefix}${part_no}
|
||||
|
||||
ilog "Install disk: ${INSTDEV}"
|
||||
ilog "Current disk: ${dev} ; current partition index:$part_no"
|
||||
ilog "Current disk: ${dev} ; current partition index: $part_no"
|
||||
ilog "LV_SZ_LOG (cgts--vg-log--lv size): ${LV_SZ_LOG} MB"
|
||||
ilog "LV_SZ_ROOT (cgts--vg-root--lv) : ${LV_SZ_ROOT} MB"
|
||||
ilog "LV_SZ_SCRATCH (cgts--vg-scratch--lv) : ${LV_SZ_SCRATCH} MB"
|
||||
@ -2023,6 +2048,10 @@ elif [ "${worker}" = true -o "${storage}" = true ] ; then
|
||||
p1=2
|
||||
fi
|
||||
|
||||
# Important: Set fs_dev needed by the installer for mounting/updating the efi
|
||||
# partition
|
||||
fs_dev=${dev_part_prefix}
|
||||
|
||||
true
|
||||
%end
|
||||
|
||||
@ -3052,12 +3081,12 @@ echo -e "/dev/mapper/cgts--vg-log--lv\t/var/log\text4\tdefaults\t1 2" >> ${IMAGE
|
||||
|
||||
# Report and update the lvm config for the sysroot. Remove preceeding tab and
|
||||
# convert to spaces to align with puppet expectations
|
||||
LV_ROOTDISK_BY_PATH=$(get_by_path ${LV_ROOTDISK})
|
||||
LV_PERSISTENT_ROOTDISK=$(get_persistent_disk ${LV_ROOTDISK})
|
||||
log_lvm_conf "SysRoot Initial" ${IMAGE_ROOTFS}/etc/lvm/lvm.conf
|
||||
ilog ""
|
||||
ilog "Update the LVM global filter to enable the initial physical volume only: ${LV_ROOTDISK_BY_PATH}"
|
||||
ilog "Update the LVM global filter to enable the initial physical volume only: ${LV_PERSISTENT_ROOTDISK}"
|
||||
ilog ""
|
||||
sed -i "s@^\(\s*\)# global_filter = \[.*@ global_filter = [ \"a|${LV_ROOTDISK_BY_PATH}|\", \"r|.*|\" ]@" ${IMAGE_ROOTFS}/etc/lvm/lvm.conf
|
||||
sed -i "s@^\(\s*\)# global_filter = \[.*@ global_filter = [ \"a|${LV_PERSISTENT_ROOTDISK}|\", \"r|.*|\" ]@" ${IMAGE_ROOTFS}/etc/lvm/lvm.conf
|
||||
log_lvm_conf "SysRoot Updated" ${IMAGE_ROOTFS}/etc/lvm/lvm.conf
|
||||
|
||||
# Create first_boot flag
|
||||
|
@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (c) 2022 Wind River Systems, Inc.
|
||||
# Copyright (c) 2022-2023 Wind River Systems, Inc.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
############################################################################
|
||||
@ -149,8 +149,14 @@ function report_failure_with_msg()
|
||||
|
||||
########################################################################
|
||||
# Name : get_disk
|
||||
# Parameters: \$1 - ??????
|
||||
# Returns : No return but common disk name is echo's to stdio
|
||||
# Parameters: \$1 - any disk path
|
||||
# Returns : echo of the canonicalized version of the disk path
|
||||
#
|
||||
# Example : /dev/sda -> /dev/sda
|
||||
# : /dev/nvme1n1 -> /dev/nvme1n1
|
||||
# : /dev/disk/by-path/pci-0000:02:00.0-scsi-0:1:0:0 -> /dev/sda
|
||||
# : /dev/disk/by-id/wwn-0x50014ee6ae58b07f -> /dev/sdc
|
||||
# : /dev/disk/by-id/wwn-0x600508b1001c2a30 -> /dev/dm-0
|
||||
#########################################################################
|
||||
function get_disk()
|
||||
{
|
||||
@ -158,59 +164,72 @@ function get_disk()
|
||||
}
|
||||
|
||||
#########################################################################
|
||||
# Name : get_by_path
|
||||
# Name : get_persistent_disk
|
||||
# Parameters: \$1 - device name i.e. /dev/sda
|
||||
# Returns : echo of device name by-path
|
||||
# example: /dev/disk/by-path/pci-0000:03:00.0-scsi-0:2:0:0
|
||||
# Returns : echo of device name by-path or by-id
|
||||
# example: /dev/disk/by-path/pci-0000:03:00.0-scsi-0:2:0:0 or
|
||||
# /dev/disk/by-id/wwn-0x50014ee6ae58b07f
|
||||
#
|
||||
# Notes: During kickstarts there are 2 links to a generic /dev/sd<X>.
|
||||
# Example: pci-0000:00:1f.2-ata-1 and pci-0000:00:1f.2-ata-1.0.
|
||||
# After reboot only the longer 'ata-1.0' exists.
|
||||
# Reverse the parsing so we return the longer path.
|
||||
#########################################################################
|
||||
function get_by_path()
|
||||
function get_persistent_disk()
|
||||
{
|
||||
# log "Function: get_by_path '\${1}'"
|
||||
local disk=\$(cd /dev ; readlink -f \$1)
|
||||
reverse_list=""
|
||||
for p in /dev/disk/by-path/*; do
|
||||
reverse_list="\${p} \${reverse_list}"
|
||||
done
|
||||
for p in \${reverse_list}; do
|
||||
if [ "\$disk" = "\$(readlink -f \$p)" ]; then
|
||||
echo "\$p"
|
||||
return
|
||||
fi
|
||||
done
|
||||
local dev=\$(cd /dev ; readlink -f \$1)
|
||||
case \$dev in
|
||||
*"dm-"*)
|
||||
for p in /dev/disk/by-id/wwn-*; do
|
||||
if [ "\$(basename \$dev)" = "\$(basename \$(readlink -f \$p))" ]; then
|
||||
echo "\$p"
|
||||
return
|
||||
fi
|
||||
done
|
||||
;;
|
||||
*)
|
||||
reverse_list=""
|
||||
for p in /dev/disk/by-path/*; do
|
||||
reverse_list="\${p} \${reverse_list}"
|
||||
done
|
||||
for p in \${reverse_list}; do
|
||||
if [ "\$(basename \$dev)" = "\$(basename \$(readlink -f \$p))" ]; then
|
||||
echo "\$p"
|
||||
return
|
||||
fi
|
||||
done
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
#########################################################################
|
||||
# Name : get_disk_dev
|
||||
# Purpose : get the disk name
|
||||
# Returns : echo of the first disk name found ; base on coded priority
|
||||
# Name : get_part_prefix
|
||||
# Parameters: \$1 - device name i.e. /dev/sda, /dev/nvme0n1, /dev/dm-0
|
||||
# Returns : echo of acceptable partition prefix
|
||||
# example: /dev/sda
|
||||
# /dev/nvme0n1p
|
||||
# /dev/disk/by-id/wwn-0x50014ee6ae58b07f-part
|
||||
#########################################################################
|
||||
function get_disk_dev()
|
||||
function get_part_prefix()
|
||||
{
|
||||
local disk
|
||||
# Detect HDD
|
||||
for blk_dev in vda vdb sda sdb dda ddb hda hdb; do
|
||||
if [ -d /sys/block/\$blk_dev ]; then
|
||||
disk=\$(ls -l /sys/block/\$blk_dev | grep -v usb | head -n1 | sed 's/^.*\([vsdh]d[a-z]\+\).*\$/\1/');
|
||||
if [ -n "\$disk" ]; then
|
||||
echo "\$disk"
|
||||
return
|
||||
fi
|
||||
fi
|
||||
done
|
||||
for blk_dev in nvme0n1 nvme1n1; do
|
||||
if [ -d /sys/block/\$blk_dev ]; then
|
||||
disk=\$(ls -l /sys/block/\$blk_dev | grep -v usb | head -n1 | sed 's/^.*\(nvme[01]n1\).*\$/\1/');
|
||||
if [ -n "\$disk" ]; then
|
||||
echo "\$disk"
|
||||
return
|
||||
fi
|
||||
fi
|
||||
done
|
||||
# ensure that we have a canonicalized device
|
||||
local dev=\$(cd /dev ; readlink -f \$1)
|
||||
case \$dev in
|
||||
*"nvme"*)
|
||||
echo "\${dev}p"
|
||||
;;
|
||||
*"dm-"*)
|
||||
for p in /dev/disk/by-id/wwn-*; do
|
||||
if [ "\$dev" = "\$(readlink -f \$p)" ]; then
|
||||
echo "\${p}-part"
|
||||
return
|
||||
fi
|
||||
done
|
||||
;;
|
||||
*)
|
||||
echo "\${dev}"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
#########################################################################
|
||||
@ -810,14 +829,6 @@ if [ "\${controller}" = true ] ; then
|
||||
else
|
||||
BACKUP_PART_NO=\${BACKUP_PART_UEFI}
|
||||
fi
|
||||
case \${INSTDEV} in
|
||||
*"nvme"*)
|
||||
BACKUP_PART=\${INSTDEV}p\${BACKUP_PART_NO}
|
||||
;;
|
||||
*)
|
||||
BACKUP_PART=\${INSTDEV}\${BACKUP_PART_NO}
|
||||
;;
|
||||
esac
|
||||
BACKUP_PART_LABEL="platform_backup"
|
||||
|
||||
# Note that the BA5EBA11-0000-1111-2222- is the prefix used by STX and it's
|
||||
@ -1135,12 +1146,12 @@ fi
|
||||
# From pre_disk_setup_common.cfg
|
||||
#####################################################
|
||||
|
||||
if [ -n "$INSTDEV" ] ; then
|
||||
instdev_by_path=$(get_by_path $INSTDEV)
|
||||
if [ -z ${instdev_by_path} ] ; then
|
||||
if [ -n "${INSTDEV}" ] ; then
|
||||
persistent_instdev=$(get_persistent_disk "${INSTDEV}")
|
||||
if [ -z ${persistent_instdev} ] ; then
|
||||
report_failure_with_msg "invalid install device ${INSTDEV}"
|
||||
else
|
||||
ilog "Install device: ${INSTDEV} : ${instdev_by_path}"
|
||||
ilog "Install device: ${INSTDEV} : ${persistent_instdev}"
|
||||
fi
|
||||
fi
|
||||
|
||||
@ -1151,12 +1162,21 @@ fi
|
||||
# asynchronously so avoid using them while performing partition
|
||||
# operations.
|
||||
ilog "Detected storage devices:"
|
||||
case ${persistent_instdev} in
|
||||
*"by-id"*)
|
||||
disk_regex='/dev/disk/by-id/wwn-*'
|
||||
;;
|
||||
*)
|
||||
disk_regex='/dev/disk/by-path/*'
|
||||
;;
|
||||
esac
|
||||
|
||||
STOR_DEVS=""
|
||||
for f in /dev/disk/by-path/*; do
|
||||
for f in ${disk_regex} ; do
|
||||
dev=$(readlink -f $f)
|
||||
# dlog "found device ${f}"
|
||||
exec_retry 2 0.5 "lsblk --nodeps --pairs $dev" | grep -q 'TYPE="disk"'
|
||||
if [ $? -eq 0 ] ; then
|
||||
exec_retry 2 0.5 "lsblk --nodeps --pairs $dev" | grep -q -e 'TYPE="disk"' -e 'TYPE="mpath"'
|
||||
if [ $? -eq 0 ]; then
|
||||
# Filter out ISO disk from storage devices
|
||||
check_valid_dev $dev || continue
|
||||
STOR_DEVS="$STOR_DEVS $dev"
|
||||
@ -1198,9 +1218,9 @@ display_mount_info
|
||||
|
||||
# Consider removing since LAT already handles this failure mode
|
||||
# Ensure specified device is not a USB drive
|
||||
udevadm info --query=property --name=${INSTDEV} |grep -q '^ID_BUS=usb'
|
||||
udevadm info --query=property --name="${INSTDEV}" | grep -q '^ID_BUS=usb'
|
||||
if [ $? -eq 0 ]; then
|
||||
report_failure_with_msg "Specified installation ($INSTDEV) device is a USB drive."
|
||||
report_failure_with_msg "Specified installation (${INSTDEV}) device is a USB drive."
|
||||
fi
|
||||
|
||||
# Log the disk setup
|
||||
@ -1274,7 +1294,9 @@ else
|
||||
|
||||
# Partition type OSD has a unique globally identifier
|
||||
CEPH_OSD_GUID="4FBD7E29-9D25-41B8-AFD0-062C0CEFF05D"
|
||||
CEPH_OSD_MPATH_GUID="4FBD7E29-8AE0-4982-BF9D-5A8D867AF560"
|
||||
CEPH_JOURNAL_GUID="45B0969E-9B03-4F30-B4C6-B4B80CEFF106"
|
||||
CEPH_JOURNAL_MPATH_GUID="45B0969E-8AE0-4982-BF9D-5A8D867AF560"
|
||||
|
||||
# Check if we wipe OSDs
|
||||
if [ "$(curl -sf http://pxecontroller:6385/v1/ihosts/wipe_osds 2>/dev/null)" = "true" ]; then
|
||||
@ -1325,15 +1347,16 @@ else
|
||||
for part_number in "${part_numbers[@]}"; do
|
||||
sgdisk_part_info=$(sgdisk -i $part_number $dev)
|
||||
part_type_guid=$(echo "$sgdisk_part_info" | grep "$part_type_guid_str" | awk '{print $4;}')
|
||||
if [ "$part_type_guid" == $CEPH_OSD_GUID ]; then
|
||||
if [ "$part_type_guid" == $CEPH_OSD_GUID -o "$part_type_guid" == $CEPH_OSD_MPATH_GUID ]; then
|
||||
wlog "OSD found on $dev, skipping wipe"
|
||||
wipe_dev="false"
|
||||
break
|
||||
fi
|
||||
|
||||
exec_no_fds "$STOR_DEV_FDS" "pvs" | grep -q -e "${dev}${part_number} *ceph" -e "${dev}p${part_number} *ceph"
|
||||
dev_part_prefix=$(get_part_prefix "${dev}")
|
||||
exec_no_fds "$STOR_DEV_FDS" "pvs" | grep -q -e "${dev_part_prefix}${part_number} *ceph" -e "${dev_part_prefix}p${part_number} *ceph"
|
||||
if [ $? -eq 0 ]; then
|
||||
wlog "Rook OSD found on $dev$part_number, skip wipe"
|
||||
wlog "Rook OSD found on $dev_part_prefix$part_number, skip wipe"
|
||||
wipe_dev="false"
|
||||
break
|
||||
fi
|
||||
@ -1363,14 +1386,7 @@ fi
|
||||
ilog "==========="
|
||||
ilog "WIPE DISKs: ${WIPE_HDD}"
|
||||
ilog "==========="
|
||||
by_dev=${INSTDEV}
|
||||
# TODO: Avoid this loop if the INSTDEV does not have by-path in its name
|
||||
for f in /dev/disk/by-path/*; do
|
||||
if [ "${f}" == "${INSTDEV}" ] ; then
|
||||
by_dev=$(get_disk "${INSTDEV}")
|
||||
break
|
||||
fi
|
||||
done
|
||||
inst_dev=$(get_disk "${INSTDEV}")
|
||||
for dev in ${WIPE_HDD//,/ } ; do
|
||||
ilog "Wiping $dev"
|
||||
|
||||
@ -1380,62 +1396,42 @@ for dev in ${WIPE_HDD//,/ } ; do
|
||||
# Note: Delete the first few bytes at the start and end of the partition.
|
||||
# This is required with GPT partitions because they save partition
|
||||
# info at both the start and the end of the block.
|
||||
|
||||
# Get a list of partitions for this disk
|
||||
part_numbers=( $(parted -s $dev print | awk '$1 == "Number" {i=1; next}; i {print $1}') )
|
||||
|
||||
# For each '/dev/${dev}${part_number} apply wipe rules
|
||||
# For each device partition apply wipe rules
|
||||
for part_number in "${part_numbers[@]}"; do
|
||||
sgdisk_part_info=$(sgdisk -i $part_number $dev)
|
||||
part_name=$(echo "$sgdisk_part_info" | grep "$part_type_name_str" | awk '{print $3;}')
|
||||
|
||||
# special handling for the install device '${INSTDEV}'
|
||||
if [ "${dev}" == "${by_dev}" ] ; then
|
||||
# special handling for the install device
|
||||
if [ "${dev}" == "${inst_dev}" ] ; then
|
||||
|
||||
# Skip over the bios, efi and boot partitions that got us here.
|
||||
# LAT handles these partitions
|
||||
case ${part_name} in
|
||||
"'bios'")
|
||||
ilog "skipping ${part_name} on ${dev}${part_number}"
|
||||
continue
|
||||
;;
|
||||
"'otaefi'")
|
||||
ilog "skipping ${part_name} on ${dev}${part_number}"
|
||||
continue
|
||||
;;
|
||||
"'otaboot'")
|
||||
ilog "skipping ${part_name} on ${dev}${part_number}"
|
||||
continue
|
||||
;;
|
||||
"'otaboot_b'")
|
||||
ilog "skipping ${part_name} on ${dev}${part_number}"
|
||||
"'bios'" | "'otaefi'" | "'otaboot'" | "'otaboot_b'")
|
||||
ilog "skipping ${part_name} on partition ${part_number} of device ${dev}"
|
||||
continue
|
||||
;;
|
||||
*)
|
||||
dlog "wipe candidate ${part_name} on ${dev}${part_number}"
|
||||
dlog "wipe candidate ${part_name} on partition ${part_number} of device ${dev}"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
# Deal with ssd's which have different partition labelling convention
|
||||
part=$dev$part_number
|
||||
case $part in
|
||||
*"nvme"*)
|
||||
part=${dev}p${part_number}
|
||||
;;
|
||||
esac
|
||||
|
||||
part=$(get_part_prefix "${dev}")$part_number
|
||||
if [ "${controller}" = true ] ; then
|
||||
# Skip if we already found a valid partition, look otherwise
|
||||
[ ${BACKUP_PART_FOUND} -eq 1 ] && continue
|
||||
|
||||
ilog "Looking for platform-backup partition on $part from ... instdev=${INSTDEV} device=${by_dev}"
|
||||
ilog "Looking for platform-backup partition on $part from ... instdev=${INSTDEV} device=${inst_dev} persistent_device=${persistent_instdev}"
|
||||
sgdisk_part_info=$(sgdisk -i $part_number $dev)
|
||||
part_type_guid=$(echo "$sgdisk_part_info" | grep "$part_type_guid_str" | awk '{print $4;}')
|
||||
dlog "Examining part_number=${part_number}, by_dev=${by_dev}, dev=${dev}, part_type_guid: ${part_type_guid}"
|
||||
dlog "sgdisk_part_info: ${sgdisk_part_info}"
|
||||
dlog "BACKUP_PART_GUID: ${BACKUP_PART_GUID}"
|
||||
if [ "$dev" == "${by_dev}" -a "$part_type_guid" == $BACKUP_PART_GUID ] ; then
|
||||
if [ "$dev" == "${inst_dev}" -a "$part_type_guid" == $BACKUP_PART_GUID ] ; then
|
||||
part_type_name=$(echo "$sgdisk_part_info" | grep "$part_type_name_str" | awk '{print $3,$4;}')
|
||||
BACKUP_PART_NAME=${part_type_name:1:-1}
|
||||
|
||||
@ -1469,7 +1465,7 @@ for dev in ${WIPE_HDD//,/ } ; do
|
||||
# Make sure we only recreate the backup partition on systems that are
|
||||
# known to be invalid. Detect a potential switch in BIOS vs. UEFI and
|
||||
# exit with an appropriate message.
|
||||
ilog "Discovered persistent backup partition, ${part}, is in an unexpected location. Expected: ${BACKUP_PART}."
|
||||
ilog "Discovered persistent backup partition, ${part}, is in an unexpected location. Expected on partition ${BACKUP_PART_NO}."
|
||||
if [ "$USE_UEFI_PARTITIONS" = 0 ] ; then
|
||||
# BIOS boot...
|
||||
if [ "${part_number}" == "${BACKUP_PART_UEFI}" ] ; then
|
||||
@ -1491,7 +1487,7 @@ for dev in ${WIPE_HDD//,/ } ; do
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ $WIPE_CEPH_OSDS == "true" -a "$part_type_guid" == $CEPH_JOURNAL_GUID ]; then
|
||||
if [ "${WIPE_CEPH_OSDS}" = "true" ] && ([ "${part_type_guid}" = "${CEPH_JOURNAL_GUID}" ] || [ "${part_type_guid}" = "${CEPH_MPATH_JOURNAL_GUID}" ]); then
|
||||
# Journal partitions require additional wiping. Based on the ceph-manage-journal.py
|
||||
# script in the integ repo (at the ceph/ceph/files/ceph-manage-journal.py location)
|
||||
# wiping 100MB of data at the beginning of the partition should be enough. We also
|
||||
@ -1506,7 +1502,7 @@ for dev in ${WIPE_HDD//,/ } ; do
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ${BACKUP_PART_FOUND} -eq 0 -o "${dev}" != "${by_dev}" ]; then
|
||||
if [ ${BACKUP_PART_FOUND} -eq 0 -o "${dev}" != "${inst_dev}" ] ; then
|
||||
ilog "Creating disk label for $dev"
|
||||
parted -s $dev mktable gpt
|
||||
ilog "... done"
|
||||
@ -1615,7 +1611,7 @@ ilog "*****************************************"
|
||||
ilog "*** Partition - Partition Disks ***"
|
||||
ilog "*****************************************"
|
||||
|
||||
dev=$(get_disk "${INSTDEV}")
|
||||
inst_dev=$(get_disk "${INSTDEV}")
|
||||
|
||||
###########################################################
|
||||
# From pre_disk_controller.cfg
|
||||
@ -1642,18 +1638,18 @@ MIB_BYTES=$((1024*1024))
|
||||
sgdisk_parts=""
|
||||
|
||||
# Get the logical sector size used for determining partition boundaries
|
||||
LOGICAL_SECTOR_SZ=`lsblk -n ${dev} -o LOG-SEC -d`
|
||||
LOGICAL_SECTOR_SZ=`lsblk -n ${inst_dev} -o LOG-SEC -d`
|
||||
|
||||
# Zap the GPT/MBR information
|
||||
sgdisk -Z ${dev}
|
||||
sgdisk -Z ${inst_dev}
|
||||
|
||||
# Get the first aligned sector
|
||||
first=`sgdisk -F ${dev} | grep -v Creating`
|
||||
first=`sgdisk -F ${inst_dev} | grep -v Creating`
|
||||
|
||||
# Get the last aligned sector
|
||||
export last=$(sgdisk -E ${dev} 2>/dev/null |grep -v Creating)
|
||||
export last=$(sgdisk -E ${inst_dev} 2>/dev/null |grep -v Creating)
|
||||
|
||||
ilog "Allocate host partitions on ${dev} with first sector: $first and last sector: $last"
|
||||
ilog "Allocate host partitions on ${inst_dev} with first sector: $first and last sector: $last"
|
||||
|
||||
# Maintain BIOS partition mappings from previous releases
|
||||
start_sec=$first
|
||||
@ -1778,17 +1774,18 @@ STOR_DEVS=$(echo "$STOR_DEVS" | xargs -n 1 | sort -u | xargs)
|
||||
ilog "STOR_DEV_FDS Updated ; $STOR_DEV_FDS"
|
||||
|
||||
# CREATE PARTITIONS
|
||||
dlog "Requesting ${dev} Partition Table: ${a}"
|
||||
dlog "Executing: sgdisk ${sgdisk_parts} -p ${dev}"
|
||||
sgdisk $sgdisk_parts -p ${dev}
|
||||
dlog "Requesting ${inst_dev} Partition Table: ${a}"
|
||||
dlog "Executing: sgdisk ${sgdisk_parts} -p ${inst_dev}"
|
||||
sgdisk $sgdisk_parts -p ${inst_dev}
|
||||
rc=$?
|
||||
[ ${rc} -ne 0 ] && report_failure_with_msg "sgdisk failed to create partitions: ${a} [rc=${rc}]"
|
||||
|
||||
if [ "${backup_part_extension_required}" -ne 0 ]; then
|
||||
instdev_part_prefix=$(get_part_prefix "${inst_dev}")
|
||||
# The backup partition has been increased via persistent_size.
|
||||
# Extend the partition and resize the FS
|
||||
wlog "Platform Backup partition: resizing ${BACKUP_PART} from ${BACKUP_PART_CURRENT_SIZE}MiB to ${BACKUP_SIZE}MiB"
|
||||
e2fsck -p -f ${BACKUP_PART}
|
||||
wlog "Platform Backup partition: resizing ${instdev_part_prefix}${BACKUP_PART_NO} from ${BACKUP_PART_CURRENT_SIZE}MiB to ${BACKUP_SIZE}MiB"
|
||||
e2fsck -p -f ${instdev_part_prefix}${BACKUP_PART_NO}
|
||||
rc=$?
|
||||
# Handle e2fsck exit code, non-zero can still indicate success:
|
||||
# 0 - No errors
|
||||
@ -1798,7 +1795,7 @@ if [ "${backup_part_extension_required}" -ne 0 ]; then
|
||||
# Include 2 as a failure in our case, since it should only happen if the filesystem
|
||||
# is mounted while e2fsck is run (not a valid scenario here).
|
||||
[ ${rc} -gt 1 ] && report_failure_with_msg "e2fsck failed on platform backup partition [rc=${rc}]"
|
||||
resize2fs -f ${BACKUP_PART}
|
||||
resize2fs -f ${instdev_part_prefix}${BACKUP_PART_NO}
|
||||
rc=$?
|
||||
[ ${rc} -ne 0 ] && report_failure_with_msg "Failed to resize ext4 fs of platform backup partition [rc=${rc}]"
|
||||
fi
|
||||
@ -1821,6 +1818,7 @@ ilog "***************************************************"
|
||||
vg="volume group"
|
||||
lv="logical volume"
|
||||
dev=$(get_disk "${INSTDEV}")
|
||||
dev_part_prefix=$(get_part_prefix "${dev}")
|
||||
|
||||
if [ "${controller}" = true ] ; then
|
||||
if [ "${aio}" = true ] ; then
|
||||
@ -1832,13 +1830,6 @@ else
|
||||
report_failure_with_msg "Unsupported install type: only Standard or All-in-one is supported"
|
||||
fi
|
||||
|
||||
fs_dev=$dev
|
||||
case ${fs_dev} in
|
||||
*"nvme"*)
|
||||
fs_dev=${fs_dev}p
|
||||
;;
|
||||
esac
|
||||
|
||||
# Maintain BIOS partition mappings from previous releases
|
||||
part_no=1
|
||||
if [ "$USE_UEFI_PARTITIONS" = 0 -o "${controller}" = false ] ; then
|
||||
@ -1848,48 +1839,45 @@ fi
|
||||
|
||||
if [ "${controller}" = true ] ; then
|
||||
ilog "BACKUP_SIZE : ${BACKUP_SIZE}"
|
||||
ilog "BACKUP_PART : ${BACKUP_PART}"
|
||||
ilog "BACKUP_PART_NO : ${BACKUP_PART_NO}"
|
||||
ilog "BACKUP_PART_LABEL : ${BACKUP_PART_LABEL}"
|
||||
ilog "BACKUP_PART_GUID : ${BACKUP_PART_GUID}"
|
||||
ilog "BACKUP_PART : ${dev_part_prefix}${BACKUP_PART_NO}"
|
||||
|
||||
# Only init Platform Backup partition filesystem if the partition was just created
|
||||
if [ ${BACKUP_PART_FOUND} -eq 0 ] ; then
|
||||
# Sanity check
|
||||
[ "${fs_dev}${part_no}" != "${BACKUP_PART}" ] && report_failure_with_msg "Abort creating platform backup filesystem, unexpected location: ${fs_dev}${part_no}"
|
||||
|
||||
ilog "Platform Backup Partition was CREATED. Initialize filesystem on ${BACKUP_PART}"
|
||||
mkfs.ext4 -F -L ${BACKUP_PART_LABEL} ${BACKUP_PART}
|
||||
[ ${?} -ne 0 ] && report_failure_with_msg "Failed Platform Backup partition filesystem init ${BACKUP_PART}"
|
||||
ilog "Platform Backup Partition was CREATED. Initialize filesystem on ${dev_part_prefix}${BACKUP_PART_NO}"
|
||||
mkfs.ext4 -F -L ${BACKUP_PART_LABEL} ${dev_part_prefix}${BACKUP_PART_NO}
|
||||
[ ${?} -ne 0 ] && report_failure_with_msg "Failed Platform Backup partition filesystem init ${dev_part_prefix}${BACKUP_PART_NO}"
|
||||
else
|
||||
# Preserving the contents of the backup partition, but make sure it's labeled correctly
|
||||
e2label ${BACKUP_PART} ${BACKUP_PART_LABEL}
|
||||
e2label ${dev_part_prefix}${BACKUP_PART_NO} ${BACKUP_PART_LABEL}
|
||||
fi
|
||||
part_no=$((part_no+1))
|
||||
fi
|
||||
|
||||
# Maintain UEFI partition mappings from previous releases
|
||||
mkfs.vfat -n otaefi ${fs_dev}${part_no}
|
||||
[ ${?} -ne 0 ] && report_failure_with_msg "Failed UEFI filesystem init: ${fs_dev}${part_no}, rc=${?}"
|
||||
mkfs.vfat -n otaefi ${dev_part_prefix}${part_no}
|
||||
[ ${?} -ne 0 ] && report_failure_with_msg "Failed UEFI filesystem init: ${dev_part_prefix}${part_no}, rc=${?}"
|
||||
part_no=$((part_no+1))
|
||||
|
||||
# Boot/Root OSTree Partition A (Note: OSTree Partition B not used)
|
||||
if [ "${PART_SZ_BOOT}" != 0 ] ; then
|
||||
mkfs.ext4 -F -L otaboot ${fs_dev}${part_no}
|
||||
[ ${?} -ne 0 ] && report_failure_with_msg "Failed Boot filesystem init: ${fs_dev}${part_no}, rc=${?}"
|
||||
mkfs.ext4 -F -L otaboot ${dev_part_prefix}${part_no}
|
||||
[ ${?} -ne 0 ] && report_failure_with_msg "Failed Boot filesystem init: ${dev_part_prefix}${part_no}, rc=${?}"
|
||||
part_no=$((part_no+1))
|
||||
fi
|
||||
|
||||
if [ "${PART_SZ_ROOT}" != 0 ] ; then
|
||||
mkfs.ext4 -F -L otaroot ${fs_dev}${part_no}
|
||||
[ ${?} -ne 0 ] && report_failure_with_msg "Failed Root filesystem init: ${fs_dev}${part_no}, rc=${?}"
|
||||
mkfs.ext4 -F -L otaroot ${dev_part_prefix}${part_no}
|
||||
[ ${?} -ne 0 ] && report_failure_with_msg "Failed Root filesystem init: ${dev_part_prefix}${part_no}, rc=${?}"
|
||||
part_no=$((part_no+1))
|
||||
fi
|
||||
|
||||
# Flux Partition
|
||||
if [ "${LV_SZ_VAR}" = 0 -a "${INSTFLUX}" = 1 ] ; then
|
||||
mkfs.ext4 -F -L fluxdata ${fs_dev}${part_no}
|
||||
[ ${?} -ne 0 ] && report_failure_with_msg "Failed Fluxdata (/var) filesystem init: ${fs_dev}${part_no}, rc=${?}"
|
||||
mkfs.ext4 -F -L fluxdata ${dev_part_prefix}${part_no}
|
||||
[ ${?} -ne 0 ] && report_failure_with_msg "Failed Fluxdata (/var) filesystem init: ${dev_part_prefix}${part_no}, rc=${?}"
|
||||
part_no=$((part_no+1))
|
||||
fi
|
||||
|
||||
@ -1897,10 +1885,10 @@ fi
|
||||
log_lvm_conf "Installer Initial" /etc/lvm/lvm.conf
|
||||
|
||||
# Create Volume Group
|
||||
pv_part=${fs_dev}${part_no}
|
||||
pv_part=${dev_part_prefix}${part_no}
|
||||
|
||||
ilog "Install disk: ${INSTDEV}"
|
||||
ilog "Current disk: ${dev} ; current partition index:$part_no"
|
||||
ilog "Current disk: ${dev} ; current partition index: $part_no"
|
||||
ilog "LV_SZ_LOG (cgts--vg-log--lv size): ${LV_SZ_LOG} MB"
|
||||
ilog "LV_SZ_ROOT (cgts--vg-root--lv) : ${LV_SZ_ROOT} MB"
|
||||
ilog "LV_SZ_SCRATCH (cgts--vg-scratch--lv) : ${LV_SZ_SCRATCH} MB"
|
||||
@ -2188,6 +2176,10 @@ elif [ "${worker}" = true -o "${storage}" = true ] ; then
|
||||
p1=2
|
||||
fi
|
||||
|
||||
# Important: Set fs_dev needed by the installer for mounting/updating the efi
|
||||
# partition
|
||||
fs_dev=${dev_part_prefix}
|
||||
|
||||
true
|
||||
%end
|
||||
|
||||
@ -2199,6 +2191,7 @@ HOOK_LABEL="post"
|
||||
ilog "*********************************************************"
|
||||
ilog "**** Post - Add user/groups **"
|
||||
ilog "*********************************************************"
|
||||
|
||||
# Set password for root to 'root'
|
||||
usermod -p '$6$hEv/K.fPeg/$ezIWhJPrMG3WtdEwqQRdyBwdYmPZkqW2PONFAcDd6TqWliYc9dHAwW4MFTlLanVH3/clE0/34FheDMpbAqZVG.' root
|
||||
|
||||
@ -2938,12 +2931,12 @@ echo -e "/dev/mapper/cgts--vg-log--lv\t/var/log\text4\tdefaults\t1 2" >> ${IMAGE
|
||||
|
||||
# Report and update the lvm config for the sysroot. Remove preceeding tab and
|
||||
# convert to spaces to align with puppet expectations
|
||||
LV_ROOTDISK_BY_PATH=$(get_by_path ${LV_ROOTDISK})
|
||||
LV_PERSISTENT_ROOTDISK=$(get_persistent_disk ${LV_ROOTDISK})
|
||||
log_lvm_conf "SysRoot Initial" ${IMAGE_ROOTFS}/etc/lvm/lvm.conf
|
||||
ilog ""
|
||||
ilog "Update the LVM global filter to enable the initial physical volume only: ${LV_ROOTDISK_BY_PATH}"
|
||||
ilog "Update the LVM global filter to enable the initial physical volume only: ${LV_PERSISTENT_ROOTDISK}"
|
||||
ilog ""
|
||||
sed -i "s@^\(\s*\)# global_filter = \[.*@ global_filter = [ \"a|${LV_ROOTDISK_BY_PATH}|\", \"r|.*|\" ]@" ${IMAGE_ROOTFS}/etc/lvm/lvm.conf
|
||||
sed -i "s@^\(\s*\)# global_filter = \[.*@ global_filter = [ \"a|${LV_PERSISTENT_ROOTDISK}|\", \"r|.*|\" ]@" ${IMAGE_ROOTFS}/etc/lvm/lvm.conf
|
||||
log_lvm_conf "SysRoot Updated" ${IMAGE_ROOTFS}/etc/lvm/lvm.conf
|
||||
|
||||
eject_device=$(eject -d | awk -F\` '{print $2}' | awk -F\' '{print $1}')
|
||||
|
Loading…
x
Reference in New Issue
Block a user