Merge "Refactor kickstarts to integrate multipath support"
This commit is contained in:
commit
17c2912bd6
@ -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
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
#
|
#
|
||||||
############################################################################
|
############################################################################
|
||||||
@ -144,8 +144,14 @@ function report_failure_with_msg()
|
|||||||
|
|
||||||
########################################################################
|
########################################################################
|
||||||
# Name : get_disk
|
# Name : get_disk
|
||||||
# Parameters: \$1 - ??????
|
# Parameters: \$1 - any disk path
|
||||||
# Returns : No return but common disk name is echo's to stdio
|
# 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()
|
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
|
# Parameters: \$1 - device name i.e. /dev/sda
|
||||||
# Returns : echo of device name by-path
|
# 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
|
# 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>.
|
# 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.
|
# 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.
|
# After reboot only the longer 'ata-1.0' exists.
|
||||||
# Reverse the parsing so we return the longer path.
|
# Reverse the parsing so we return the longer path.
|
||||||
#########################################################################
|
#########################################################################
|
||||||
function get_by_path()
|
function get_persistent_disk()
|
||||||
{
|
{
|
||||||
# log "Function: get_by_path '\${1}'"
|
local dev=\$(cd /dev ; readlink -f \$1)
|
||||||
local disk=\$(cd /dev ; readlink -f \$1)
|
case \$dev in
|
||||||
reverse_list=""
|
*"dm-"*)
|
||||||
for p in /dev/disk/by-path/*; do
|
for p in /dev/disk/by-id/wwn-*; do
|
||||||
reverse_list="\${p} \${reverse_list}"
|
if [ "\$(basename \$dev)" = "\$(basename \$(readlink -f \$p))" ]; then
|
||||||
done
|
echo "\$p"
|
||||||
for p in \${reverse_list}; do
|
return
|
||||||
if [ "\$disk" = "\$(readlink -f \$p)" ]; then
|
fi
|
||||||
echo "\$p"
|
done
|
||||||
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
|
# Name : get_part_prefix
|
||||||
# Purpose : get the disk name
|
# Parameters: \$1 - device name i.e. /dev/sda, /dev/nvme0n1, /dev/dm-0
|
||||||
# Returns : echo of the first disk name found ; base on coded priority
|
# 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
|
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
|
for blk_dev in vda vdb sda sdb dda ddb hda hdb; do
|
||||||
if [ -d /sys/block/\$blk_dev ]; then
|
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/');
|
disk=\$(ls -l /sys/block/\$blk_dev | grep -v usb | head -n1 | sed 's/^.*\([vsdh]d[a-z]\+\).*\$/\1/');
|
||||||
if [ -n "\$disk" ]; then
|
if [ -n "\$disk" ]; then
|
||||||
|
# Skip if this device is part of a multipath device
|
||||||
|
multipath -c /dev/\$disk > /dev/null && continue
|
||||||
echo "\$disk"
|
echo "\$disk"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# An acceptable HDD/SSD has not been found, look for an NVMe disk
|
||||||
for blk_dev in nvme0n1 nvme1n1; do
|
for blk_dev in nvme0n1 nvme1n1; do
|
||||||
if [ -d /sys/block/\$blk_dev ]; then
|
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/');
|
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
|
||||||
fi
|
fi
|
||||||
done
|
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
|
else
|
||||||
BACKUP_PART_NO=\${BACKUP_PART_UEFI}
|
BACKUP_PART_NO=\${BACKUP_PART_UEFI}
|
||||||
fi
|
fi
|
||||||
case \${INSTDEV} in
|
|
||||||
*"nvme"*)
|
|
||||||
BACKUP_PART=\${INSTDEV}p\${BACKUP_PART_NO}
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
BACKUP_PART=\${INSTDEV}\${BACKUP_PART_NO}
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
BACKUP_PART_LABEL="platform_backup"
|
BACKUP_PART_LABEL="platform_backup"
|
||||||
|
|
||||||
# Note that the BA5EBA11-0000-1111-2222- is the prefix used by STX and it's
|
# 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
|
for value in "$@"; do case "$value" in force_install) force_install=${value};; esac; done
|
||||||
if [ -z "${force_install}" ]; then
|
if [ -z "${force_install}" ]; then
|
||||||
if [ -z "${rootfs_device}" ]; then
|
if [ -z "${rootfs_device}" ]; then
|
||||||
rootfs_device=$(get_disk_dev)
|
rootfs_device=$(get_default_install_disk)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
orig_rootfs_device=$rootfs_device
|
desired_rootfs_device=$rootfs_device
|
||||||
by_path_rootfs_device=$(get_by_path ${rootfs_device})
|
persistent_rootfs_device=$(get_persistent_disk ${desired_rootfs_device})
|
||||||
if [ -z "${by_path_rootfs_device}" ]; then
|
if [ -z "${persistent_rootfs_device}" ]; then
|
||||||
report_failure_with_msg "Device not found: ${orig_rootfs_device}"
|
report_failure_with_msg "Device not found: ${desired_rootfs_device}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
rootfs_device=$(get_disk ${by_path_rootfs_device})
|
rootfs_device=$(get_disk ${persistent_rootfs_device})
|
||||||
ilog "Found rootfs $orig_rootfs_device on: $by_path_rootfs_device->$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}') )
|
part_numbers=( $(parted -s ${rootfs_device} print | awk '$1 == "Number" {i=1; next}; i {print $1}') )
|
||||||
|
|
||||||
# Get the correct rootfs prefix
|
# Get the correct rootfs prefix
|
||||||
ROOTFS_PART_PREFIX=${rootfs_device}
|
rootfs_part_prefix=$(get_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
|
|
||||||
# temporary mount directory
|
# temporary mount directory
|
||||||
temp_mount=/mnt/temp_mount
|
temp_mount=/mnt/temp_mount
|
||||||
mkdir -p ${temp_mount}
|
mkdir -p ${temp_mount}
|
||||||
@ -1056,7 +1105,7 @@ if check_prestage -eq 0 ; then
|
|||||||
|
|
||||||
device_list=()
|
device_list=()
|
||||||
for part in "${part_numbers[@]}"; do
|
for part in "${part_numbers[@]}"; do
|
||||||
device=${ROOTFS_PART_PREFIX}${part}
|
device=${rootfs_part_prefix}${part}
|
||||||
device_list+=(${device})
|
device_list+=(${device})
|
||||||
ilog "Adding ${device}"
|
ilog "Adding ${device}"
|
||||||
done
|
done
|
||||||
@ -1161,12 +1210,12 @@ fi
|
|||||||
# From pre_disk_setup_common.cfg
|
# From pre_disk_setup_common.cfg
|
||||||
#####################################################
|
#####################################################
|
||||||
|
|
||||||
if [ -n "$INSTDEV" ] ; then
|
if [ -n "${INSTDEV}" ] ; then
|
||||||
instdev_by_path=$(get_by_path $INSTDEV)
|
persistent_instdev=$(get_persistent_disk "${INSTDEV}")
|
||||||
if [ -z ${instdev_by_path} ] ; then
|
if [ -z ${persistent_instdev} ] ; then
|
||||||
report_failure_with_msg "invalid install device ${INSTDEV}"
|
report_failure_with_msg "invalid install device ${INSTDEV}"
|
||||||
else
|
else
|
||||||
ilog "Install device: ${INSTDEV} : ${instdev_by_path}"
|
ilog "Install device: ${INSTDEV} : ${persistent_instdev}"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -1177,11 +1226,20 @@ fi
|
|||||||
# asynchronously so avoid using them while performing partition
|
# asynchronously so avoid using them while performing partition
|
||||||
# operations.
|
# operations.
|
||||||
ilog "Detected storage devices:"
|
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=""
|
STOR_DEVS=""
|
||||||
for f in /dev/disk/by-path/* ; do
|
for f in ${disk_regex} ; do
|
||||||
dev=$(readlink -f $f)
|
dev=$(readlink -f $f)
|
||||||
# dlog "found device ${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
|
if [ $? -eq 0 ] ; then
|
||||||
# Filter out ISO disk from storage devices
|
# Filter out ISO disk from storage devices
|
||||||
check_valid_dev $dev || continue
|
check_valid_dev $dev || continue
|
||||||
@ -1224,9 +1282,9 @@ display_mount_info
|
|||||||
|
|
||||||
# Consider removing since LAT already handles this failure mode
|
# Consider removing since LAT already handles this failure mode
|
||||||
# Ensure specified device is not a USB drive
|
# 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
|
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
|
fi
|
||||||
|
|
||||||
# Log the disk setup
|
# Log the disk setup
|
||||||
@ -1300,7 +1358,9 @@ else
|
|||||||
|
|
||||||
# Partition type OSD has a unique globally identifier
|
# Partition type OSD has a unique globally identifier
|
||||||
CEPH_OSD_GUID="4FBD7E29-9D25-41B8-AFD0-062C0CEFF05D"
|
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_GUID="45B0969E-9B03-4F30-B4C6-B4B80CEFF106"
|
||||||
|
CEPH_JOURNAL_MPATH_GUID="45B0969E-8AE0-4982-BF9D-5A8D867AF560"
|
||||||
|
|
||||||
# Check if we wipe OSDs
|
# Check if we wipe OSDs
|
||||||
if [ "$(curl -sf http://pxecontroller:6385/v1/ihosts/wipe_osds 2>/dev/null)" = "true" ] ; then
|
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
|
for part_number in "${part_numbers[@]}" ; do
|
||||||
sgdisk_part_info=$(sgdisk -i $part_number $dev)
|
sgdisk_part_info=$(sgdisk -i $part_number $dev)
|
||||||
part_type_guid=$(echo "$sgdisk_part_info" | grep "$part_type_guid_str" | awk '{print $4;}')
|
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"
|
wlog "OSD found on $dev, skipping wipe"
|
||||||
wipe_dev="false"
|
wipe_dev="false"
|
||||||
break
|
break
|
||||||
fi
|
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}")
|
||||||
if [ $? -eq 0 ] ; then
|
exec_no_fds "$STOR_DEV_FDS" "pvs" | grep -q -e "${dev_part_prefix}${part_number} *ceph" -e "${dev_part_prefix}p${part_number} *ceph"
|
||||||
wlog "Rook OSD found on $dev$part_number, skip wipe"
|
if [ $? -eq 0 ]; then
|
||||||
|
wlog "Rook OSD found on $dev_part_prefix$part_number, skip wipe"
|
||||||
wipe_dev="false"
|
wipe_dev="false"
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
@ -1389,14 +1450,7 @@ fi
|
|||||||
ilog "==========="
|
ilog "==========="
|
||||||
ilog "WIPE DISKs: ${WIPE_HDD}"
|
ilog "WIPE DISKs: ${WIPE_HDD}"
|
||||||
ilog "==========="
|
ilog "==========="
|
||||||
by_dev=${INSTDEV}
|
inst_dev=$(get_disk "${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
|
|
||||||
for dev in ${WIPE_HDD//,/ } ; do
|
for dev in ${WIPE_HDD//,/ } ; do
|
||||||
ilog "Wiping $dev"
|
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.
|
# Note: Delete the first few bytes at the start and end of the partition.
|
||||||
# This is required with GPT partitions because they save partition
|
# This is required with GPT partitions because they save partition
|
||||||
# info at both the start and the end of the block.
|
# info at both the start and the end of the block.
|
||||||
|
|
||||||
# Get a list of partitions for this disk
|
# Get a list of partitions for this disk
|
||||||
part_numbers=( $(parted -s $dev print | awk '$1 == "Number" {i=1; next}; i {print $1}') )
|
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
|
for part_number in "${part_numbers[@]}"; do
|
||||||
sgdisk_part_info=$(sgdisk -i $part_number $dev)
|
sgdisk_part_info=$(sgdisk -i $part_number $dev)
|
||||||
part_name=$(echo "$sgdisk_part_info" | grep "$part_type_name_str" | awk '{print $3;}')
|
part_name=$(echo "$sgdisk_part_info" | grep "$part_type_name_str" | awk '{print $3;}')
|
||||||
|
|
||||||
# special handling for the install device '${INSTDEV}'
|
# special handling for the install device
|
||||||
if [ "${dev}" == "${by_dev}" ] ; then
|
if [ "${dev}" == "${inst_dev}" ] ; then
|
||||||
|
|
||||||
# Skip over the bios, efi and boot partitions that got us here.
|
# Skip over the bios, efi and boot partitions that got us here.
|
||||||
# LAT handles these partitions
|
# LAT handles these partitions
|
||||||
case ${part_name} in
|
case ${part_name} in
|
||||||
"'bios'")
|
"'bios'" | "'otaefi'" | "'otaboot'" | "'otaboot_b'")
|
||||||
ilog "skipping ${part_name} on ${dev}${part_number}"
|
ilog "skipping ${part_name} on partition ${part_number} of device ${dev}"
|
||||||
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}"
|
|
||||||
continue
|
continue
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
dlog "wipe candidate ${part_name} on ${dev}${part_number}"
|
dlog "wipe candidate ${part_name} on partition ${part_number} of device ${dev}"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Deal with ssd's which have different partition labelling convention
|
part=$(get_part_prefix "${dev}")$part_number
|
||||||
part=$dev$part_number
|
|
||||||
case $part in
|
|
||||||
*"nvme"*)
|
|
||||||
part=${dev}p${part_number}
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
if [ "${controller}" = true ] ; then
|
if [ "${controller}" = true ] ; then
|
||||||
# Skip if we already found a valid partition, look otherwise
|
# Skip if we already found a valid partition, look otherwise
|
||||||
[ ${BACKUP_PART_FOUND} -eq 1 ] && continue
|
[ ${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)
|
sgdisk_part_info=$(sgdisk -i $part_number $dev)
|
||||||
part_type_guid=$(echo "$sgdisk_part_info" | grep "$part_type_guid_str" | awk '{print $4;}')
|
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;}')
|
part_type_name=$(echo "$sgdisk_part_info" | grep "$part_type_name_str" | awk '{print $3,$4;}')
|
||||||
BACKUP_PART_NAME=${part_type_name:1:-1}
|
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
|
# 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
|
# known to be invalid. Detect a potential switch in BIOS vs. UEFI and
|
||||||
# exit with an appropriate message.
|
# 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
|
if [ "$USE_UEFI_PARTITIONS" = 0 ] ; then
|
||||||
# BIOS boot...
|
# BIOS boot...
|
||||||
if [ "${part_number}" == "${BACKUP_PART_UEFI}" ] ; then
|
if [ "${part_number}" == "${BACKUP_PART_UEFI}" ] ; then
|
||||||
@ -1513,7 +1547,7 @@ for dev in ${WIPE_HDD//,/ } ; do
|
|||||||
fi
|
fi
|
||||||
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
|
# 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)
|
# 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
|
# 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
|
fi
|
||||||
done
|
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"
|
ilog "Creating disk label for $dev"
|
||||||
parted -s $dev mktable gpt
|
parted -s $dev mktable gpt
|
||||||
ilog "... done"
|
ilog "... done"
|
||||||
@ -1574,7 +1608,7 @@ ilog "*****************************************"
|
|||||||
ilog "*** Partition - Partition Disks ***"
|
ilog "*** Partition - Partition Disks ***"
|
||||||
ilog "*****************************************"
|
ilog "*****************************************"
|
||||||
|
|
||||||
dev=$(get_disk "${INSTDEV}")
|
inst_dev=$(get_disk "${INSTDEV}")
|
||||||
|
|
||||||
###########################################################
|
###########################################################
|
||||||
# From pre_disk_controller.cfg
|
# From pre_disk_controller.cfg
|
||||||
@ -1601,18 +1635,18 @@ MIB_BYTES=$((1024*1024))
|
|||||||
sgdisk_parts=""
|
sgdisk_parts=""
|
||||||
|
|
||||||
# Get the logical sector size used for determining partition boundaries
|
# 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
|
# Zap the GPT/MBR information
|
||||||
sgdisk -Z ${dev}
|
sgdisk -Z ${inst_dev}
|
||||||
|
|
||||||
# Get the first aligned sector
|
# 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
|
# 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
|
# Maintain BIOS partition mappings from previous releases
|
||||||
start_sec=$first
|
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."
|
[ -z "$STOR_DEVS" ] && report_failure_with_msg "No storage devices available."
|
||||||
ilog "STOR_DEV_FDS Updated ; $STOR_DEV_FDS"
|
ilog "STOR_DEV_FDS Updated ; $STOR_DEV_FDS"
|
||||||
|
|
||||||
dlog "Requesting ${dev} Partition Table: ${a}"
|
dlog "Requesting ${inst_dev} Partition Table: ${a}"
|
||||||
sgdisk $sgdisk_parts -p ${dev}
|
sgdisk $sgdisk_parts -p ${inst_dev}
|
||||||
[ $? -ne 0 ] && report_failure_with_msg "sgdisk failed to create partitions: ${a}"
|
[ $? -ne 0 ] && report_failure_with_msg "sgdisk failed to create partitions: ${a}"
|
||||||
|
|
||||||
true
|
true
|
||||||
@ -1742,6 +1776,7 @@ ilog "***************************************************"
|
|||||||
vg="volume group"
|
vg="volume group"
|
||||||
lv="logical volume"
|
lv="logical volume"
|
||||||
dev=$(get_disk "${INSTDEV}")
|
dev=$(get_disk "${INSTDEV}")
|
||||||
|
dev_part_prefix=$(get_part_prefix "${dev}")
|
||||||
|
|
||||||
if [ "${controller}" = true ] ; then
|
if [ "${controller}" = true ] ; then
|
||||||
if [ "${aio}" = true ] ; then
|
if [ "${aio}" = true ] ; then
|
||||||
@ -1755,13 +1790,6 @@ elif [ "${storage}" = true ] ; then
|
|||||||
get_storage_provisioning_sizes
|
get_storage_provisioning_sizes
|
||||||
fi
|
fi
|
||||||
|
|
||||||
fs_dev=$dev
|
|
||||||
case ${fs_dev} in
|
|
||||||
*"nvme"*)
|
|
||||||
fs_dev=${fs_dev}p
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
# Maintain BIOS partition mappings from previous releases
|
# Maintain BIOS partition mappings from previous releases
|
||||||
part_no=1
|
part_no=1
|
||||||
if [ "$USE_UEFI_PARTITIONS" = 0 -o "${controller}" = false ] ; then
|
if [ "$USE_UEFI_PARTITIONS" = 0 -o "${controller}" = false ] ; then
|
||||||
@ -1771,48 +1799,45 @@ fi
|
|||||||
|
|
||||||
if [ "${controller}" = true ] ; then
|
if [ "${controller}" = true ] ; then
|
||||||
ilog "BACKUP_SIZE : ${BACKUP_SIZE}"
|
ilog "BACKUP_SIZE : ${BACKUP_SIZE}"
|
||||||
ilog "BACKUP_PART : ${BACKUP_PART}"
|
|
||||||
ilog "BACKUP_PART_NO : ${BACKUP_PART_NO}"
|
ilog "BACKUP_PART_NO : ${BACKUP_PART_NO}"
|
||||||
ilog "BACKUP_PART_LABEL : ${BACKUP_PART_LABEL}"
|
ilog "BACKUP_PART_LABEL : ${BACKUP_PART_LABEL}"
|
||||||
ilog "BACKUP_PART_GUID : ${BACKUP_PART_GUID}"
|
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
|
# Only init Platform Backup partition filesystem if the partition was just created
|
||||||
if [ ${BACKUP_PART_FOUND} -eq 0 ] ; then
|
if [ ${BACKUP_PART_FOUND} -eq 0 ] ; then
|
||||||
# Sanity check
|
ilog "Platform Backup Partition was CREATED. Initialize filesystem on ${dev_part_prefix}${BACKUP_PART_NO}"
|
||||||
[ "${fs_dev}${part_no}" != "${BACKUP_PART}" ] && report_failure_with_msg "Abort creating platform backup filesystem, unexpected location: ${fs_dev}${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}"
|
||||||
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}"
|
|
||||||
else
|
else
|
||||||
# Preserving the contents of the backup partition, but make sure it's labeled correctly
|
# 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
|
fi
|
||||||
part_no=$((part_no+1))
|
part_no=$((part_no+1))
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Maintain UEFI partition mappings from previous releases
|
# Maintain UEFI partition mappings from previous releases
|
||||||
mkfs.vfat -n otaefi ${fs_dev}${part_no}
|
mkfs.vfat -n otaefi ${dev_part_prefix}${part_no}
|
||||||
[ ${?} -ne 0 ] && report_failure_with_msg "Failed UEFI filesystem init: ${fs_dev}${part_no}, rc=${?}"
|
[ ${?} -ne 0 ] && report_failure_with_msg "Failed UEFI filesystem init: ${dev_part_prefix}${part_no}, rc=${?}"
|
||||||
part_no=$((part_no+1))
|
part_no=$((part_no+1))
|
||||||
|
|
||||||
# Boot/Root OSTree Partition A (Note: OSTree Partition B not used)
|
# Boot/Root OSTree Partition A (Note: OSTree Partition B not used)
|
||||||
if [ "${PART_SZ_BOOT}" != 0 ] ; then
|
if [ "${PART_SZ_BOOT}" != 0 ] ; then
|
||||||
mkfs.ext4 -F -L otaboot ${fs_dev}${part_no}
|
mkfs.ext4 -F -L otaboot ${dev_part_prefix}${part_no}
|
||||||
[ ${?} -ne 0 ] && report_failure_with_msg "Failed Boot filesystem init: ${fs_dev}${part_no}, rc=${?}"
|
[ ${?} -ne 0 ] && report_failure_with_msg "Failed Boot filesystem init: ${dev_part_prefix}${part_no}, rc=${?}"
|
||||||
part_no=$((part_no+1))
|
part_no=$((part_no+1))
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "${PART_SZ_ROOT}" != 0 ] ; then
|
if [ "${PART_SZ_ROOT}" != 0 ] ; then
|
||||||
mkfs.ext4 -F -L otaroot ${fs_dev}${part_no}
|
mkfs.ext4 -F -L otaroot ${dev_part_prefix}${part_no}
|
||||||
[ ${?} -ne 0 ] && report_failure_with_msg "Failed Root filesystem init: ${fs_dev}${part_no}, rc=${?}"
|
[ ${?} -ne 0 ] && report_failure_with_msg "Failed Root filesystem init: ${dev_part_prefix}${part_no}, rc=${?}"
|
||||||
part_no=$((part_no+1))
|
part_no=$((part_no+1))
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Flux Partition
|
# Flux Partition
|
||||||
if [ "${LV_SZ_VAR}" = 0 -a "${INSTFLUX}" = 1 ] ; then
|
if [ "${LV_SZ_VAR}" = 0 -a "${INSTFLUX}" = 1 ] ; then
|
||||||
mkfs.ext4 -F -L fluxdata ${fs_dev}${part_no}
|
mkfs.ext4 -F -L fluxdata ${dev_part_prefix}${part_no}
|
||||||
[ ${?} -ne 0 ] && report_failure_with_msg "Failed Fluxdata (/var) filesystem init: ${fs_dev}${part_no}, rc=${?}"
|
[ ${?} -ne 0 ] && report_failure_with_msg "Failed Fluxdata (/var) filesystem init: ${dev_part_prefix}${part_no}, rc=${?}"
|
||||||
part_no=$((part_no+1))
|
part_no=$((part_no+1))
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -1820,10 +1845,10 @@ fi
|
|||||||
log_lvm_conf "Installer Initial" /etc/lvm/lvm.conf
|
log_lvm_conf "Installer Initial" /etc/lvm/lvm.conf
|
||||||
|
|
||||||
# Create Volume Group
|
# Create Volume Group
|
||||||
pv_part=${fs_dev}${part_no}
|
pv_part=${dev_part_prefix}${part_no}
|
||||||
|
|
||||||
ilog "Install disk: ${INSTDEV}"
|
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_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_ROOT (cgts--vg-root--lv) : ${LV_SZ_ROOT} MB"
|
||||||
ilog "LV_SZ_SCRATCH (cgts--vg-scratch--lv) : ${LV_SZ_SCRATCH} 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
|
p1=2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Important: Set fs_dev needed by the installer for mounting/updating the efi
|
||||||
|
# partition
|
||||||
|
fs_dev=${dev_part_prefix}
|
||||||
|
|
||||||
true
|
true
|
||||||
%end
|
%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
|
# Report and update the lvm config for the sysroot. Remove preceeding tab and
|
||||||
# convert to spaces to align with puppet expectations
|
# 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
|
log_lvm_conf "SysRoot Initial" ${IMAGE_ROOTFS}/etc/lvm/lvm.conf
|
||||||
ilog ""
|
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 ""
|
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
|
log_lvm_conf "SysRoot Updated" ${IMAGE_ROOTFS}/etc/lvm/lvm.conf
|
||||||
|
|
||||||
# Create first_boot flag
|
# 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
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
#
|
#
|
||||||
############################################################################
|
############################################################################
|
||||||
@ -149,8 +149,14 @@ function report_failure_with_msg()
|
|||||||
|
|
||||||
########################################################################
|
########################################################################
|
||||||
# Name : get_disk
|
# Name : get_disk
|
||||||
# Parameters: \$1 - ??????
|
# Parameters: \$1 - any disk path
|
||||||
# Returns : No return but common disk name is echo's to stdio
|
# 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()
|
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
|
# Parameters: \$1 - device name i.e. /dev/sda
|
||||||
# Returns : echo of device name by-path
|
# 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
|
# 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>.
|
# 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.
|
# 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.
|
# After reboot only the longer 'ata-1.0' exists.
|
||||||
# Reverse the parsing so we return the longer path.
|
# Reverse the parsing so we return the longer path.
|
||||||
#########################################################################
|
#########################################################################
|
||||||
function get_by_path()
|
function get_persistent_disk()
|
||||||
{
|
{
|
||||||
# log "Function: get_by_path '\${1}'"
|
local dev=\$(cd /dev ; readlink -f \$1)
|
||||||
local disk=\$(cd /dev ; readlink -f \$1)
|
case \$dev in
|
||||||
reverse_list=""
|
*"dm-"*)
|
||||||
for p in /dev/disk/by-path/*; do
|
for p in /dev/disk/by-id/wwn-*; do
|
||||||
reverse_list="\${p} \${reverse_list}"
|
if [ "\$(basename \$dev)" = "\$(basename \$(readlink -f \$p))" ]; then
|
||||||
done
|
echo "\$p"
|
||||||
for p in \${reverse_list}; do
|
return
|
||||||
if [ "\$disk" = "\$(readlink -f \$p)" ]; then
|
fi
|
||||||
echo "\$p"
|
done
|
||||||
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
|
# Name : get_part_prefix
|
||||||
# Purpose : get the disk name
|
# Parameters: \$1 - device name i.e. /dev/sda, /dev/nvme0n1, /dev/dm-0
|
||||||
# Returns : echo of the first disk name found ; base on coded priority
|
# 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
|
# ensure that we have a canonicalized device
|
||||||
# Detect HDD
|
local dev=\$(cd /dev ; readlink -f \$1)
|
||||||
for blk_dev in vda vdb sda sdb dda ddb hda hdb; do
|
case \$dev in
|
||||||
if [ -d /sys/block/\$blk_dev ]; then
|
*"nvme"*)
|
||||||
disk=\$(ls -l /sys/block/\$blk_dev | grep -v usb | head -n1 | sed 's/^.*\([vsdh]d[a-z]\+\).*\$/\1/');
|
echo "\${dev}p"
|
||||||
if [ -n "\$disk" ]; then
|
;;
|
||||||
echo "\$disk"
|
*"dm-"*)
|
||||||
return
|
for p in /dev/disk/by-id/wwn-*; do
|
||||||
fi
|
if [ "\$dev" = "\$(readlink -f \$p)" ]; then
|
||||||
fi
|
echo "\${p}-part"
|
||||||
done
|
return
|
||||||
for blk_dev in nvme0n1 nvme1n1; do
|
fi
|
||||||
if [ -d /sys/block/\$blk_dev ]; then
|
done
|
||||||
disk=\$(ls -l /sys/block/\$blk_dev | grep -v usb | head -n1 | sed 's/^.*\(nvme[01]n1\).*\$/\1/');
|
;;
|
||||||
if [ -n "\$disk" ]; then
|
*)
|
||||||
echo "\$disk"
|
echo "\${dev}"
|
||||||
return
|
;;
|
||||||
fi
|
esac
|
||||||
fi
|
|
||||||
done
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#########################################################################
|
#########################################################################
|
||||||
@ -810,14 +829,6 @@ if [ "\${controller}" = true ] ; then
|
|||||||
else
|
else
|
||||||
BACKUP_PART_NO=\${BACKUP_PART_UEFI}
|
BACKUP_PART_NO=\${BACKUP_PART_UEFI}
|
||||||
fi
|
fi
|
||||||
case \${INSTDEV} in
|
|
||||||
*"nvme"*)
|
|
||||||
BACKUP_PART=\${INSTDEV}p\${BACKUP_PART_NO}
|
|
||||||
;;
|
|
||||||
*)
|
|
||||||
BACKUP_PART=\${INSTDEV}\${BACKUP_PART_NO}
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
BACKUP_PART_LABEL="platform_backup"
|
BACKUP_PART_LABEL="platform_backup"
|
||||||
|
|
||||||
# Note that the BA5EBA11-0000-1111-2222- is the prefix used by STX and it's
|
# 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
|
# From pre_disk_setup_common.cfg
|
||||||
#####################################################
|
#####################################################
|
||||||
|
|
||||||
if [ -n "$INSTDEV" ] ; then
|
if [ -n "${INSTDEV}" ] ; then
|
||||||
instdev_by_path=$(get_by_path $INSTDEV)
|
persistent_instdev=$(get_persistent_disk "${INSTDEV}")
|
||||||
if [ -z ${instdev_by_path} ] ; then
|
if [ -z ${persistent_instdev} ] ; then
|
||||||
report_failure_with_msg "invalid install device ${INSTDEV}"
|
report_failure_with_msg "invalid install device ${INSTDEV}"
|
||||||
else
|
else
|
||||||
ilog "Install device: ${INSTDEV} : ${instdev_by_path}"
|
ilog "Install device: ${INSTDEV} : ${persistent_instdev}"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -1151,12 +1162,21 @@ fi
|
|||||||
# asynchronously so avoid using them while performing partition
|
# asynchronously so avoid using them while performing partition
|
||||||
# operations.
|
# operations.
|
||||||
ilog "Detected storage devices:"
|
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=""
|
STOR_DEVS=""
|
||||||
for f in /dev/disk/by-path/*; do
|
for f in ${disk_regex} ; do
|
||||||
dev=$(readlink -f $f)
|
dev=$(readlink -f $f)
|
||||||
# dlog "found device ${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
|
if [ $? -eq 0 ]; then
|
||||||
# Filter out ISO disk from storage devices
|
# Filter out ISO disk from storage devices
|
||||||
check_valid_dev $dev || continue
|
check_valid_dev $dev || continue
|
||||||
STOR_DEVS="$STOR_DEVS $dev"
|
STOR_DEVS="$STOR_DEVS $dev"
|
||||||
@ -1198,9 +1218,9 @@ display_mount_info
|
|||||||
|
|
||||||
# Consider removing since LAT already handles this failure mode
|
# Consider removing since LAT already handles this failure mode
|
||||||
# Ensure specified device is not a USB drive
|
# 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
|
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
|
fi
|
||||||
|
|
||||||
# Log the disk setup
|
# Log the disk setup
|
||||||
@ -1274,7 +1294,9 @@ else
|
|||||||
|
|
||||||
# Partition type OSD has a unique globally identifier
|
# Partition type OSD has a unique globally identifier
|
||||||
CEPH_OSD_GUID="4FBD7E29-9D25-41B8-AFD0-062C0CEFF05D"
|
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_GUID="45B0969E-9B03-4F30-B4C6-B4B80CEFF106"
|
||||||
|
CEPH_JOURNAL_MPATH_GUID="45B0969E-8AE0-4982-BF9D-5A8D867AF560"
|
||||||
|
|
||||||
# Check if we wipe OSDs
|
# Check if we wipe OSDs
|
||||||
if [ "$(curl -sf http://pxecontroller:6385/v1/ihosts/wipe_osds 2>/dev/null)" = "true" ]; then
|
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
|
for part_number in "${part_numbers[@]}"; do
|
||||||
sgdisk_part_info=$(sgdisk -i $part_number $dev)
|
sgdisk_part_info=$(sgdisk -i $part_number $dev)
|
||||||
part_type_guid=$(echo "$sgdisk_part_info" | grep "$part_type_guid_str" | awk '{print $4;}')
|
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"
|
wlog "OSD found on $dev, skipping wipe"
|
||||||
wipe_dev="false"
|
wipe_dev="false"
|
||||||
break
|
break
|
||||||
fi
|
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
|
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"
|
wipe_dev="false"
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
@ -1363,14 +1386,7 @@ fi
|
|||||||
ilog "==========="
|
ilog "==========="
|
||||||
ilog "WIPE DISKs: ${WIPE_HDD}"
|
ilog "WIPE DISKs: ${WIPE_HDD}"
|
||||||
ilog "==========="
|
ilog "==========="
|
||||||
by_dev=${INSTDEV}
|
inst_dev=$(get_disk "${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
|
|
||||||
for dev in ${WIPE_HDD//,/ } ; do
|
for dev in ${WIPE_HDD//,/ } ; do
|
||||||
ilog "Wiping $dev"
|
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.
|
# Note: Delete the first few bytes at the start and end of the partition.
|
||||||
# This is required with GPT partitions because they save partition
|
# This is required with GPT partitions because they save partition
|
||||||
# info at both the start and the end of the block.
|
# info at both the start and the end of the block.
|
||||||
|
|
||||||
# Get a list of partitions for this disk
|
# Get a list of partitions for this disk
|
||||||
part_numbers=( $(parted -s $dev print | awk '$1 == "Number" {i=1; next}; i {print $1}') )
|
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
|
for part_number in "${part_numbers[@]}"; do
|
||||||
sgdisk_part_info=$(sgdisk -i $part_number $dev)
|
sgdisk_part_info=$(sgdisk -i $part_number $dev)
|
||||||
part_name=$(echo "$sgdisk_part_info" | grep "$part_type_name_str" | awk '{print $3;}')
|
part_name=$(echo "$sgdisk_part_info" | grep "$part_type_name_str" | awk '{print $3;}')
|
||||||
|
|
||||||
# special handling for the install device '${INSTDEV}'
|
# special handling for the install device
|
||||||
if [ "${dev}" == "${by_dev}" ] ; then
|
if [ "${dev}" == "${inst_dev}" ] ; then
|
||||||
|
|
||||||
# Skip over the bios, efi and boot partitions that got us here.
|
# Skip over the bios, efi and boot partitions that got us here.
|
||||||
# LAT handles these partitions
|
# LAT handles these partitions
|
||||||
case ${part_name} in
|
case ${part_name} in
|
||||||
"'bios'")
|
"'bios'" | "'otaefi'" | "'otaboot'" | "'otaboot_b'")
|
||||||
ilog "skipping ${part_name} on ${dev}${part_number}"
|
ilog "skipping ${part_name} on partition ${part_number} of device ${dev}"
|
||||||
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}"
|
|
||||||
continue
|
continue
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
dlog "wipe candidate ${part_name} on ${dev}${part_number}"
|
dlog "wipe candidate ${part_name} on partition ${part_number} of device ${dev}"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Deal with ssd's which have different partition labelling convention
|
part=$(get_part_prefix "${dev}")$part_number
|
||||||
part=$dev$part_number
|
|
||||||
case $part in
|
|
||||||
*"nvme"*)
|
|
||||||
part=${dev}p${part_number}
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
if [ "${controller}" = true ] ; then
|
if [ "${controller}" = true ] ; then
|
||||||
# Skip if we already found a valid partition, look otherwise
|
# Skip if we already found a valid partition, look otherwise
|
||||||
[ ${BACKUP_PART_FOUND} -eq 1 ] && continue
|
[ ${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)
|
sgdisk_part_info=$(sgdisk -i $part_number $dev)
|
||||||
part_type_guid=$(echo "$sgdisk_part_info" | grep "$part_type_guid_str" | awk '{print $4;}')
|
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 "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 "sgdisk_part_info: ${sgdisk_part_info}"
|
||||||
dlog "BACKUP_PART_GUID: ${BACKUP_PART_GUID}"
|
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;}')
|
part_type_name=$(echo "$sgdisk_part_info" | grep "$part_type_name_str" | awk '{print $3,$4;}')
|
||||||
BACKUP_PART_NAME=${part_type_name:1:-1}
|
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
|
# 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
|
# known to be invalid. Detect a potential switch in BIOS vs. UEFI and
|
||||||
# exit with an appropriate message.
|
# 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
|
if [ "$USE_UEFI_PARTITIONS" = 0 ] ; then
|
||||||
# BIOS boot...
|
# BIOS boot...
|
||||||
if [ "${part_number}" == "${BACKUP_PART_UEFI}" ] ; then
|
if [ "${part_number}" == "${BACKUP_PART_UEFI}" ] ; then
|
||||||
@ -1491,7 +1487,7 @@ for dev in ${WIPE_HDD//,/ } ; do
|
|||||||
fi
|
fi
|
||||||
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
|
# 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)
|
# 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
|
# 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
|
fi
|
||||||
done
|
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"
|
ilog "Creating disk label for $dev"
|
||||||
parted -s $dev mktable gpt
|
parted -s $dev mktable gpt
|
||||||
ilog "... done"
|
ilog "... done"
|
||||||
@ -1615,7 +1611,7 @@ ilog "*****************************************"
|
|||||||
ilog "*** Partition - Partition Disks ***"
|
ilog "*** Partition - Partition Disks ***"
|
||||||
ilog "*****************************************"
|
ilog "*****************************************"
|
||||||
|
|
||||||
dev=$(get_disk "${INSTDEV}")
|
inst_dev=$(get_disk "${INSTDEV}")
|
||||||
|
|
||||||
###########################################################
|
###########################################################
|
||||||
# From pre_disk_controller.cfg
|
# From pre_disk_controller.cfg
|
||||||
@ -1642,18 +1638,18 @@ MIB_BYTES=$((1024*1024))
|
|||||||
sgdisk_parts=""
|
sgdisk_parts=""
|
||||||
|
|
||||||
# Get the logical sector size used for determining partition boundaries
|
# 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
|
# Zap the GPT/MBR information
|
||||||
sgdisk -Z ${dev}
|
sgdisk -Z ${inst_dev}
|
||||||
|
|
||||||
# Get the first aligned sector
|
# 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
|
# 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
|
# Maintain BIOS partition mappings from previous releases
|
||||||
start_sec=$first
|
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"
|
ilog "STOR_DEV_FDS Updated ; $STOR_DEV_FDS"
|
||||||
|
|
||||||
# CREATE PARTITIONS
|
# CREATE PARTITIONS
|
||||||
dlog "Requesting ${dev} Partition Table: ${a}"
|
dlog "Requesting ${inst_dev} Partition Table: ${a}"
|
||||||
dlog "Executing: sgdisk ${sgdisk_parts} -p ${dev}"
|
dlog "Executing: sgdisk ${sgdisk_parts} -p ${inst_dev}"
|
||||||
sgdisk $sgdisk_parts -p ${dev}
|
sgdisk $sgdisk_parts -p ${inst_dev}
|
||||||
rc=$?
|
rc=$?
|
||||||
[ ${rc} -ne 0 ] && report_failure_with_msg "sgdisk failed to create partitions: ${a} [rc=${rc}]"
|
[ ${rc} -ne 0 ] && report_failure_with_msg "sgdisk failed to create partitions: ${a} [rc=${rc}]"
|
||||||
|
|
||||||
if [ "${backup_part_extension_required}" -ne 0 ]; then
|
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.
|
# The backup partition has been increased via persistent_size.
|
||||||
# Extend the partition and resize the FS
|
# Extend the partition and resize the FS
|
||||||
wlog "Platform Backup partition: resizing ${BACKUP_PART} from ${BACKUP_PART_CURRENT_SIZE}MiB to ${BACKUP_SIZE}MiB"
|
wlog "Platform Backup partition: resizing ${instdev_part_prefix}${BACKUP_PART_NO} from ${BACKUP_PART_CURRENT_SIZE}MiB to ${BACKUP_SIZE}MiB"
|
||||||
e2fsck -p -f ${BACKUP_PART}
|
e2fsck -p -f ${instdev_part_prefix}${BACKUP_PART_NO}
|
||||||
rc=$?
|
rc=$?
|
||||||
# Handle e2fsck exit code, non-zero can still indicate success:
|
# Handle e2fsck exit code, non-zero can still indicate success:
|
||||||
# 0 - No errors
|
# 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
|
# 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).
|
# 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}]"
|
[ ${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=$?
|
||||||
[ ${rc} -ne 0 ] && report_failure_with_msg "Failed to resize ext4 fs of platform backup partition [rc=${rc}]"
|
[ ${rc} -ne 0 ] && report_failure_with_msg "Failed to resize ext4 fs of platform backup partition [rc=${rc}]"
|
||||||
fi
|
fi
|
||||||
@ -1821,6 +1818,7 @@ ilog "***************************************************"
|
|||||||
vg="volume group"
|
vg="volume group"
|
||||||
lv="logical volume"
|
lv="logical volume"
|
||||||
dev=$(get_disk "${INSTDEV}")
|
dev=$(get_disk "${INSTDEV}")
|
||||||
|
dev_part_prefix=$(get_part_prefix "${dev}")
|
||||||
|
|
||||||
if [ "${controller}" = true ] ; then
|
if [ "${controller}" = true ] ; then
|
||||||
if [ "${aio}" = 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"
|
report_failure_with_msg "Unsupported install type: only Standard or All-in-one is supported"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
fs_dev=$dev
|
|
||||||
case ${fs_dev} in
|
|
||||||
*"nvme"*)
|
|
||||||
fs_dev=${fs_dev}p
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
# Maintain BIOS partition mappings from previous releases
|
# Maintain BIOS partition mappings from previous releases
|
||||||
part_no=1
|
part_no=1
|
||||||
if [ "$USE_UEFI_PARTITIONS" = 0 -o "${controller}" = false ] ; then
|
if [ "$USE_UEFI_PARTITIONS" = 0 -o "${controller}" = false ] ; then
|
||||||
@ -1848,48 +1839,45 @@ fi
|
|||||||
|
|
||||||
if [ "${controller}" = true ] ; then
|
if [ "${controller}" = true ] ; then
|
||||||
ilog "BACKUP_SIZE : ${BACKUP_SIZE}"
|
ilog "BACKUP_SIZE : ${BACKUP_SIZE}"
|
||||||
ilog "BACKUP_PART : ${BACKUP_PART}"
|
|
||||||
ilog "BACKUP_PART_NO : ${BACKUP_PART_NO}"
|
ilog "BACKUP_PART_NO : ${BACKUP_PART_NO}"
|
||||||
ilog "BACKUP_PART_LABEL : ${BACKUP_PART_LABEL}"
|
ilog "BACKUP_PART_LABEL : ${BACKUP_PART_LABEL}"
|
||||||
ilog "BACKUP_PART_GUID : ${BACKUP_PART_GUID}"
|
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
|
# Only init Platform Backup partition filesystem if the partition was just created
|
||||||
if [ ${BACKUP_PART_FOUND} -eq 0 ] ; then
|
if [ ${BACKUP_PART_FOUND} -eq 0 ] ; then
|
||||||
# Sanity check
|
ilog "Platform Backup Partition was CREATED. Initialize filesystem on ${dev_part_prefix}${BACKUP_PART_NO}"
|
||||||
[ "${fs_dev}${part_no}" != "${BACKUP_PART}" ] && report_failure_with_msg "Abort creating platform backup filesystem, unexpected location: ${fs_dev}${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}"
|
||||||
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}"
|
|
||||||
else
|
else
|
||||||
# Preserving the contents of the backup partition, but make sure it's labeled correctly
|
# 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
|
fi
|
||||||
part_no=$((part_no+1))
|
part_no=$((part_no+1))
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Maintain UEFI partition mappings from previous releases
|
# Maintain UEFI partition mappings from previous releases
|
||||||
mkfs.vfat -n otaefi ${fs_dev}${part_no}
|
mkfs.vfat -n otaefi ${dev_part_prefix}${part_no}
|
||||||
[ ${?} -ne 0 ] && report_failure_with_msg "Failed UEFI filesystem init: ${fs_dev}${part_no}, rc=${?}"
|
[ ${?} -ne 0 ] && report_failure_with_msg "Failed UEFI filesystem init: ${dev_part_prefix}${part_no}, rc=${?}"
|
||||||
part_no=$((part_no+1))
|
part_no=$((part_no+1))
|
||||||
|
|
||||||
# Boot/Root OSTree Partition A (Note: OSTree Partition B not used)
|
# Boot/Root OSTree Partition A (Note: OSTree Partition B not used)
|
||||||
if [ "${PART_SZ_BOOT}" != 0 ] ; then
|
if [ "${PART_SZ_BOOT}" != 0 ] ; then
|
||||||
mkfs.ext4 -F -L otaboot ${fs_dev}${part_no}
|
mkfs.ext4 -F -L otaboot ${dev_part_prefix}${part_no}
|
||||||
[ ${?} -ne 0 ] && report_failure_with_msg "Failed Boot filesystem init: ${fs_dev}${part_no}, rc=${?}"
|
[ ${?} -ne 0 ] && report_failure_with_msg "Failed Boot filesystem init: ${dev_part_prefix}${part_no}, rc=${?}"
|
||||||
part_no=$((part_no+1))
|
part_no=$((part_no+1))
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "${PART_SZ_ROOT}" != 0 ] ; then
|
if [ "${PART_SZ_ROOT}" != 0 ] ; then
|
||||||
mkfs.ext4 -F -L otaroot ${fs_dev}${part_no}
|
mkfs.ext4 -F -L otaroot ${dev_part_prefix}${part_no}
|
||||||
[ ${?} -ne 0 ] && report_failure_with_msg "Failed Root filesystem init: ${fs_dev}${part_no}, rc=${?}"
|
[ ${?} -ne 0 ] && report_failure_with_msg "Failed Root filesystem init: ${dev_part_prefix}${part_no}, rc=${?}"
|
||||||
part_no=$((part_no+1))
|
part_no=$((part_no+1))
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Flux Partition
|
# Flux Partition
|
||||||
if [ "${LV_SZ_VAR}" = 0 -a "${INSTFLUX}" = 1 ] ; then
|
if [ "${LV_SZ_VAR}" = 0 -a "${INSTFLUX}" = 1 ] ; then
|
||||||
mkfs.ext4 -F -L fluxdata ${fs_dev}${part_no}
|
mkfs.ext4 -F -L fluxdata ${dev_part_prefix}${part_no}
|
||||||
[ ${?} -ne 0 ] && report_failure_with_msg "Failed Fluxdata (/var) filesystem init: ${fs_dev}${part_no}, rc=${?}"
|
[ ${?} -ne 0 ] && report_failure_with_msg "Failed Fluxdata (/var) filesystem init: ${dev_part_prefix}${part_no}, rc=${?}"
|
||||||
part_no=$((part_no+1))
|
part_no=$((part_no+1))
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -1897,10 +1885,10 @@ fi
|
|||||||
log_lvm_conf "Installer Initial" /etc/lvm/lvm.conf
|
log_lvm_conf "Installer Initial" /etc/lvm/lvm.conf
|
||||||
|
|
||||||
# Create Volume Group
|
# Create Volume Group
|
||||||
pv_part=${fs_dev}${part_no}
|
pv_part=${dev_part_prefix}${part_no}
|
||||||
|
|
||||||
ilog "Install disk: ${INSTDEV}"
|
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_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_ROOT (cgts--vg-root--lv) : ${LV_SZ_ROOT} MB"
|
||||||
ilog "LV_SZ_SCRATCH (cgts--vg-scratch--lv) : ${LV_SZ_SCRATCH} 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
|
p1=2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Important: Set fs_dev needed by the installer for mounting/updating the efi
|
||||||
|
# partition
|
||||||
|
fs_dev=${dev_part_prefix}
|
||||||
|
|
||||||
true
|
true
|
||||||
%end
|
%end
|
||||||
|
|
||||||
@ -2199,6 +2191,7 @@ HOOK_LABEL="post"
|
|||||||
ilog "*********************************************************"
|
ilog "*********************************************************"
|
||||||
ilog "**** Post - Add user/groups **"
|
ilog "**** Post - Add user/groups **"
|
||||||
ilog "*********************************************************"
|
ilog "*********************************************************"
|
||||||
|
|
||||||
# Set password for root to 'root'
|
# Set password for root to 'root'
|
||||||
usermod -p '$6$hEv/K.fPeg/$ezIWhJPrMG3WtdEwqQRdyBwdYmPZkqW2PONFAcDd6TqWliYc9dHAwW4MFTlLanVH3/clE0/34FheDMpbAqZVG.' 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
|
# Report and update the lvm config for the sysroot. Remove preceeding tab and
|
||||||
# convert to spaces to align with puppet expectations
|
# 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
|
log_lvm_conf "SysRoot Initial" ${IMAGE_ROOTFS}/etc/lvm/lvm.conf
|
||||||
ilog ""
|
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 ""
|
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
|
log_lvm_conf "SysRoot Updated" ${IMAGE_ROOTFS}/etc/lvm/lvm.conf
|
||||||
|
|
||||||
eject_device=$(eject -d | awk -F\` '{print $2}' | awk -F\' '{print $1}')
|
eject_device=$(eject -d | awk -F\` '{print $2}' | awk -F\' '{print $1}')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user