Merge "Persistent backup partition"
This commit is contained in:
commit
fbb2ef2eed
@ -1,3 +1,13 @@
|
|||||||
|
%post --nochroot
|
||||||
|
|
||||||
|
# Change GUID of backup partition
|
||||||
|
change_guid=/tmp/backup-guid-change.sh
|
||||||
|
if [ -f "$change_guid" ]; then
|
||||||
|
sh $change_guid
|
||||||
|
fi
|
||||||
|
|
||||||
|
%end
|
||||||
|
|
||||||
%post --erroronfail
|
%post --erroronfail
|
||||||
|
|
||||||
# Source common functions
|
# Source common functions
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
##
|
##
|
||||||
## NOTE: Max default PV size must align with the default controllerfs sizes
|
## NOTE: Max default PV size must align with the default controllerfs sizes
|
||||||
##
|
##
|
||||||
## BACKUP_OVERHEAD = 20
|
## BACKUP_OVERHEAD = 10
|
||||||
##
|
##
|
||||||
## Physical install (for disks over 240GB)
|
## Physical install (for disks over 240GB)
|
||||||
## - DB size is doubled to allow for upgrades
|
## - DB size is doubled to allow for upgrades
|
||||||
@ -18,7 +18,7 @@
|
|||||||
## DEFAULT_DATABASE_STOR_SIZE = 20
|
## DEFAULT_DATABASE_STOR_SIZE = 20
|
||||||
## DEFAULT_IMG_CONVERSION_STOR_SIZE = 20
|
## DEFAULT_IMG_CONVERSION_STOR_SIZE = 20
|
||||||
## BACKUP = DEFAULT_DATABASE_STOR_SIZE + DEFAULT_IMAGE_STOR_SIZE
|
## BACKUP = DEFAULT_DATABASE_STOR_SIZE + DEFAULT_IMAGE_STOR_SIZE
|
||||||
## + BACKUP_OVERHEAD = 50
|
## + BACKUP_OVERHEAD = 40
|
||||||
## LOG_VOL_SIZE = 8192
|
## LOG_VOL_SIZE = 8192
|
||||||
## SCRATCH_VOL_SIZE = 8192
|
## SCRATCH_VOL_SIZE = 8192
|
||||||
## RABBIT = 2048
|
## RABBIT = 2048
|
||||||
@ -33,9 +33,9 @@
|
|||||||
## KUBELET_VOL_SIZE = 10240
|
## KUBELET_VOL_SIZE = 10240
|
||||||
## RESERVED_PE = 16 (based on pesize=32768)
|
## RESERVED_PE = 16 (based on pesize=32768)
|
||||||
##
|
##
|
||||||
## CGCS_PV_SIZE = 10240 + 2*20480 + 20480 + 51200 + 8196 + 8196 + 2048 +
|
## CGCS_PV_SIZE = 10240 + 2*20480 + 20480 + 40960 + 8196 + 8196 + 2048 +
|
||||||
## 2048 + 1024 + 1024 + 5120 + 30720 + 16384 + 5120 +
|
## 2048 + 1024 + 1024 + 5120 + 30720 + 16384 + 5120 +
|
||||||
## 20480 + 10240 + 16 = 233496
|
## 20480 + 10240 + 16 = 223256
|
||||||
##
|
##
|
||||||
## small install - (for disks below 240GB)
|
## small install - (for disks below 240GB)
|
||||||
## - DB size is doubled to allow for upgrades
|
## - DB size is doubled to allow for upgrades
|
||||||
@ -43,7 +43,7 @@
|
|||||||
## DEFAULT_SMALL_IMAGE_STOR_SIZE = 10
|
## DEFAULT_SMALL_IMAGE_STOR_SIZE = 10
|
||||||
## DEFAULT_SMALL_DATABASE_STOR_SIZE = 10
|
## DEFAULT_SMALL_DATABASE_STOR_SIZE = 10
|
||||||
## DEFAULT_SMALL_IMG_CONVERSION_STOR_SIZE = 10
|
## DEFAULT_SMALL_IMG_CONVERSION_STOR_SIZE = 10
|
||||||
## DEFAULT_SMALL_BACKUP_STOR_SIZE = 40
|
## DEFAULT_SMALL_BACKUP_STOR_SIZE = 30
|
||||||
##
|
##
|
||||||
## LOG_VOL_SIZE = 8192
|
## LOG_VOL_SIZE = 8192
|
||||||
## SCRATCH_VOL_SIZE = 8192
|
## SCRATCH_VOL_SIZE = 8192
|
||||||
@ -60,9 +60,9 @@
|
|||||||
## RESERVED_PE = 16 (based on pesize=32768)
|
## RESERVED_PE = 16 (based on pesize=32768)
|
||||||
##
|
##
|
||||||
##
|
##
|
||||||
## CGCS_PV_SIZE = 10240 + 2*10240 + 10240 + 40960 + 8192 + 8192 + 2048 +
|
## CGCS_PV_SIZE = 10240 + 2*10240 + 10240 + 30720 + 8192 + 8192 + 2048 +
|
||||||
## 2048 + 1024 + 1024 + 5120 + 30720 + 16384 + 5120 +
|
## 2048 + 1024 + 1024 + 5120 + 30720 + 16384 + 5120 +
|
||||||
## 20480 + 10240 + 16 = 192528
|
## 20480 + 10240 + 16 = 182288
|
||||||
##
|
##
|
||||||
## NOTE: To maintain upgrade compatability within the volume group, keep the
|
## NOTE: To maintain upgrade compatability within the volume group, keep the
|
||||||
## undersized LOG_VOL_SIZE and SCRATCH_VOL_SIZE, but size the minimally size
|
## undersized LOG_VOL_SIZE and SCRATCH_VOL_SIZE, but size the minimally size
|
||||||
@ -85,21 +85,25 @@
|
|||||||
## cgts-vg PV (142G), cgts-vg PV (336G)
|
## cgts-vg PV (142G), cgts-vg PV (336G)
|
||||||
##
|
##
|
||||||
|
|
||||||
sz=$(blockdev --getsize64 $(get_disk $rootfs_device))
|
sz=$(blockdev --getsize64 $(get_disk $ROOTFS_DISK))
|
||||||
if [ $sz -le $((240*$gb)) ] ; then
|
if [ $sz -le $((240*$gb)) ] ; then
|
||||||
# Round CGCS_PV_SIZE to the closest upper value that can be divided by 1024.
|
# Round CGCS_PV_SIZE to the closest upper value that can be divided by 1024.
|
||||||
# 192528/1024=188.01. CGCS_PV_SIZE=189*1024=193536. Using a disk with a
|
# 182288/1024=178.01. CGCS_PV_SIZE=179*1024=183296. Using a disk with a
|
||||||
# size under 189GiB will fail.
|
# size under 179GiB will fail.
|
||||||
CGCS_PV_SIZE=193536
|
CGCS_PV_SIZE=183296
|
||||||
|
|
||||||
else
|
else
|
||||||
# Round CGCS_PV_SIZE to the closest upper value that can be divided by 1024.
|
# Round CGCS_PV_SIZE to the closest upper value that can be divided by 1024.
|
||||||
# 233496/1024=228.02. CGCS_PV_SIZE=229*1024=234496.
|
# 223256/1024=218.02. CGCS_PV_SIZE=219*1024=224256.
|
||||||
CGCS_PV_SIZE=234496
|
CGCS_PV_SIZE=224256
|
||||||
fi
|
fi
|
||||||
|
|
||||||
ROOTFS_SIZE=20000
|
ROOTFS_SIZE=20000
|
||||||
LOG_VOL_SIZE=8000
|
LOG_VOL_SIZE=8000
|
||||||
SCRATCH_VOL_SIZE=8000
|
SCRATCH_VOL_SIZE=8000
|
||||||
|
PLATFORM_BACKUP_SIZE=10000
|
||||||
|
BOOT_SIZE=500
|
||||||
|
EFI_SIZE=300
|
||||||
|
|
||||||
ROOTFS_OPTIONS="defaults"
|
ROOTFS_OPTIONS="defaults"
|
||||||
profile_mode=`cat /proc/cmdline |xargs -n1 echo |grep security_profile= | grep extended`
|
profile_mode=`cat /proc/cmdline |xargs -n1 echo |grep security_profile= | grep extended`
|
||||||
@ -108,13 +112,67 @@ if [ -n "$profile_mode" ]; then
|
|||||||
ROOTFS_OPTIONS="${ROOTFS_OPTIONS},iversion"
|
ROOTFS_OPTIONS="${ROOTFS_OPTIONS},iversion"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -d /sys/firmware/efi ] ; then
|
||||||
|
BACKUP_PART=${ROOTFS_PART_PREFIX}1
|
||||||
|
BACKUP_PART_NO=1
|
||||||
|
START_POINT=1
|
||||||
|
END_POINT=$(($START_POINT + $PLATFORM_BACKUP_SIZE))
|
||||||
|
parted -s $ROOTFS_DISK mkpart primary ext4 ${START_POINT}MiB ${END_POINT}MiB
|
||||||
|
|
||||||
|
START_POINT=$END_POINT
|
||||||
|
END_POINT=$(($START_POINT + $EFI_SIZE))
|
||||||
|
parted -s $ROOTFS_DISK mkpart primary fat32 ${START_POINT}MiB ${END_POINT}MiB
|
||||||
|
|
||||||
cat<<EOF>>/tmp/part-include
|
cat<<EOF>>/tmp/part-include
|
||||||
part /boot --fstype=ext4 --asprimary --size=500 --ondrive=$(get_disk $rootfs_device) --fsoptions="$ROOTFS_OPTIONS"
|
part /boot/efi --fstype=efi --onpart=${ROOTFS_PART_PREFIX}2
|
||||||
part pv.253004 --grow --size=500 --maxsize=$CGCS_PV_SIZE --ondrive=$(get_disk $rootfs_device)
|
EOF
|
||||||
|
else
|
||||||
|
BACKUP_PART=${ROOTFS_PART_PREFIX}2
|
||||||
|
BACKUP_PART_NO=2
|
||||||
|
parted -s $ROOTFS_DISK mkpart primary 1MiB 2MiB
|
||||||
|
|
||||||
|
START_POINT=2
|
||||||
|
END_POINT=$(($START_POINT + $PLATFORM_BACKUP_SIZE))
|
||||||
|
parted -s $ROOTFS_DISK mkpart primary ext4 ${START_POINT}MiB ${END_POINT}MiB
|
||||||
|
|
||||||
|
cat<<EOF>>/tmp/part-include
|
||||||
|
part biosboot --asprimary --fstype=biosboot --onpart=${ROOTFS_PART_PREFIX}1
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
|
||||||
|
START_POINT=$END_POINT
|
||||||
|
END_POINT=$(($START_POINT + $BOOT_SIZE))
|
||||||
|
parted -s $ROOTFS_DISK mkpart primary ext4 ${START_POINT}MiB ${END_POINT}MiB
|
||||||
|
|
||||||
|
START_POINT=$END_POINT
|
||||||
|
END_POINT=$(($START_POINT + $ROOTFS_SIZE))
|
||||||
|
parted -s $ROOTFS_DISK mkpart primary ext4 ${START_POINT}MiB ${END_POINT}MiB
|
||||||
|
|
||||||
|
START_POINT=$END_POINT
|
||||||
|
END_POINT=$(($START_POINT + $CGCS_PV_SIZE))
|
||||||
|
parted -s $ROOTFS_DISK mkpart extended ${START_POINT}MiB ${END_POINT}MiB
|
||||||
|
|
||||||
|
if [ $BACKUP_CREATED -ne 0 ] ; then
|
||||||
|
cat<<EOF>>/tmp/part-include
|
||||||
|
part /opt/platform-backup --fstype=ext4 --asprimary --noformat --onpart=$BACKUP_PART --fsoptions="$ROOTFS_OPTIONS"
|
||||||
|
EOF
|
||||||
|
else
|
||||||
|
cat<<EOF>/tmp/backup-guid-change.sh
|
||||||
|
flock $ROOTFS_DISK sgdisk --change-name=${BACKUP_PART_NO}:"${BACKUP_PART_LABEL}" --typecode=${BACKUP_PART_NO}:"${BACKUP_PART_GUID}" $ROOTFS_DISK
|
||||||
|
EOF
|
||||||
|
|
||||||
|
cat<<EOF>>/tmp/part-include
|
||||||
|
part /opt/platform-backup --fstype=ext4 --asprimary --onpart=$BACKUP_PART --fsoptions="$ROOTFS_OPTIONS"
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
|
||||||
|
cat<<EOF>>/tmp/part-include
|
||||||
|
part /boot --fstype=ext4 --asprimary --onpart=${ROOTFS_PART_PREFIX}3 --fsoptions="$ROOTFS_OPTIONS"
|
||||||
|
part pv.253004 --onpart=${ROOTFS_PART_PREFIX}5
|
||||||
volgroup cgts-vg --pesize=32768 pv.253004
|
volgroup cgts-vg --pesize=32768 pv.253004
|
||||||
logvol /var/log --fstype=ext4 --vgname=cgts-vg --size=$LOG_VOL_SIZE --name=log-lv
|
logvol /var/log --fstype=ext4 --vgname=cgts-vg --size=$LOG_VOL_SIZE --name=log-lv
|
||||||
logvol /scratch --fstype=ext4 --vgname=cgts-vg --size=$SCRATCH_VOL_SIZE --name=scratch-lv
|
logvol /scratch --fstype=ext4 --vgname=cgts-vg --size=$SCRATCH_VOL_SIZE --name=scratch-lv
|
||||||
part / --fstype=ext4 --asprimary --size=$ROOTFS_SIZE --ondrive=$(get_disk $rootfs_device) --fsoptions="$ROOTFS_OPTIONS"
|
part / --fstype=ext4 --asprimary --onpart=${ROOTFS_PART_PREFIX}4 --fsoptions="$ROOTFS_OPTIONS"
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
%end
|
%end
|
||||||
|
@ -5,6 +5,9 @@
|
|||||||
ROOTFS_SIZE=20000
|
ROOTFS_SIZE=20000
|
||||||
LOG_VOL_SIZE=8000
|
LOG_VOL_SIZE=8000
|
||||||
SCRATCH_VOL_SIZE=8000
|
SCRATCH_VOL_SIZE=8000
|
||||||
|
PLATFORM_BACKUP_SIZE=10000
|
||||||
|
BOOT_SIZE=500
|
||||||
|
EFI_SIZE=300
|
||||||
|
|
||||||
ROOTFS_OPTIONS="defaults"
|
ROOTFS_OPTIONS="defaults"
|
||||||
profile_mode=`cat /proc/cmdline |xargs -n1 echo |grep security_profile= | grep extended`
|
profile_mode=`cat /proc/cmdline |xargs -n1 echo |grep security_profile= | grep extended`
|
||||||
@ -13,14 +16,66 @@ if [ -n "$profile_mode" ]; then
|
|||||||
ROOTFS_OPTIONS="${ROOTFS_OPTIONS},iversion"
|
ROOTFS_OPTIONS="${ROOTFS_OPTIONS},iversion"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -d /sys/firmware/efi ] ; then
|
||||||
|
BACKUP_PART=${ROOTFS_PART_PREFIX}1
|
||||||
|
BACKUP_PART_NO=1
|
||||||
|
START_POINT=1
|
||||||
|
END_POINT=$(($START_POINT + $PLATFORM_BACKUP_SIZE))
|
||||||
|
parted -s $ROOTFS_DISK mkpart primary ext4 ${START_POINT}MiB ${END_POINT}MiB
|
||||||
|
|
||||||
|
START_POINT=$END_POINT
|
||||||
|
END_POINT=$(($START_POINT + $EFI_SIZE))
|
||||||
|
parted -s $ROOTFS_DISK mkpart primary fat32 ${START_POINT}MiB ${END_POINT}MiB
|
||||||
|
|
||||||
cat<<EOF>>/tmp/part-include
|
cat<<EOF>>/tmp/part-include
|
||||||
part /boot --fstype=ext4 --asprimary --size=500 --ondrive=$(get_disk $rootfs_device) --fsoptions="$ROOTFS_OPTIONS"
|
part /boot/efi --fstype=efi --onpart=${ROOTFS_PART_PREFIX}2
|
||||||
part pv.253004 --grow --asprimary --size=500 --ondrive=$(get_disk $rootfs_device)
|
EOF
|
||||||
|
else
|
||||||
|
BACKUP_PART=${ROOTFS_PART_PREFIX}2
|
||||||
|
BACKUP_PART_NO=2
|
||||||
|
parted -s $ROOTFS_DISK mkpart primary 1MiB 2MiB
|
||||||
|
|
||||||
|
START_POINT=2
|
||||||
|
END_POINT=$(($START_POINT + $PLATFORM_BACKUP_SIZE))
|
||||||
|
parted -s $ROOTFS_DISK mkpart primary ext4 ${START_POINT}MiB ${END_POINT}MiB
|
||||||
|
|
||||||
|
cat<<EOF>>/tmp/part-include
|
||||||
|
part biosboot --asprimary --fstype=biosboot --onpart=${ROOTFS_PART_PREFIX}1
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
|
||||||
|
START_POINT=$END_POINT
|
||||||
|
END_POINT=$(($START_POINT + $BOOT_SIZE))
|
||||||
|
parted -s $ROOTFS_DISK mkpart primary ext4 ${START_POINT}MiB ${END_POINT}MiB
|
||||||
|
|
||||||
|
START_POINT=$END_POINT
|
||||||
|
END_POINT=$(($START_POINT + $ROOTFS_SIZE))
|
||||||
|
parted -s $ROOTFS_DISK mkpart primary ext4 ${START_POINT}MiB ${END_POINT}MiB
|
||||||
|
|
||||||
|
START_POINT=$END_POINT
|
||||||
|
parted -s $ROOTFS_DISK mkpart extended ${START_POINT}MiB 100%
|
||||||
|
|
||||||
|
if [ $BACKUP_CREATED -ne 0 ] ; then
|
||||||
|
cat<<EOF>>/tmp/part-include
|
||||||
|
part /opt/platform-backup --fstype=ext4 --asprimary --noformat --onpart=$BACKUP_PART --fsoptions="$ROOTFS_OPTIONS"
|
||||||
|
EOF
|
||||||
|
else
|
||||||
|
cat<<EOF>/tmp/backup-guid-change.sh
|
||||||
|
flock $ROOTFS_DISK sgdisk --change-name=${BACKUP_PART_NO}:"${BACKUP_PART_LABEL}" --typecode=${BACKUP_PART_NO}:"${BACKUP_PART_GUID}" $ROOTFS_DISK
|
||||||
|
EOF
|
||||||
|
|
||||||
|
cat<<EOF>>/tmp/part-include
|
||||||
|
part /opt/platform-backup --fstype=ext4 --asprimary --onpart=$BACKUP_PART --fsoptions="$ROOTFS_OPTIONS"
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
|
||||||
|
cat<<EOF>>/tmp/part-include
|
||||||
|
part /boot --fstype=ext4 --asprimary --onpart=${ROOTFS_PART_PREFIX}3 --fsoptions="$ROOTFS_OPTIONS"
|
||||||
|
part pv.253004 --onpart=${ROOTFS_PART_PREFIX}5
|
||||||
volgroup cgts-vg --pesize=32768 pv.253004
|
volgroup cgts-vg --pesize=32768 pv.253004
|
||||||
logvol /var/log --fstype=ext4 --vgname=cgts-vg --size=$LOG_VOL_SIZE --name=log-lv
|
logvol /var/log --fstype=ext4 --vgname=cgts-vg --size=$LOG_VOL_SIZE --name=log-lv
|
||||||
logvol /scratch --fstype=ext4 --vgname=cgts-vg --size=$SCRATCH_VOL_SIZE --name=scratch-lv
|
logvol /scratch --fstype=ext4 --vgname=cgts-vg --size=$SCRATCH_VOL_SIZE --name=scratch-lv
|
||||||
part / --fstype=ext4 --asprimary --size=$ROOTFS_SIZE --ondrive=$(get_disk $rootfs_device) --fsoptions="$ROOTFS_OPTIONS"
|
part / --fstype=ext4 --asprimary --onpart=${ROOTFS_PART_PREFIX}4 --fsoptions="$ROOTFS_OPTIONS"
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
%end
|
%end
|
||||||
|
@ -50,6 +50,7 @@ pvs --select 'vg_name=cgts-vg' --noheadings -o pv_name | xargs --no-run-if-empty
|
|||||||
vgs --select 'vg_name=cgts-vg' --noheadings -o vg_name | xargs --no-run-if-empty vgremove --force
|
vgs --select 'vg_name=cgts-vg' --noheadings -o vg_name | xargs --no-run-if-empty vgremove --force
|
||||||
|
|
||||||
ONLYUSE_HDD=""
|
ONLYUSE_HDD=""
|
||||||
|
part_type_guid_str="Partition GUID code"
|
||||||
if [ "$(curl -sf http://pxecontroller:6385/v1/upgrade/$(hostname)/in_upgrade 2>/dev/null)" = "true" ]; then
|
if [ "$(curl -sf http://pxecontroller:6385/v1/upgrade/$(hostname)/in_upgrade 2>/dev/null)" = "true" ]; then
|
||||||
# In an upgrade, only wipe the disk with the rootfs and boot partition
|
# In an upgrade, only wipe the disk with the rootfs and boot partition
|
||||||
echo "In upgrade, wiping only $rootfs_device"
|
echo "In upgrade, wiping only $rootfs_device"
|
||||||
@ -63,7 +64,6 @@ else
|
|||||||
# Make a list of all the hard drives that are to be wiped
|
# Make a list of all the hard drives that are to be wiped
|
||||||
WIPE_HDD=""
|
WIPE_HDD=""
|
||||||
# Partition type OSD has a unique globally identifier
|
# Partition type OSD has a unique globally identifier
|
||||||
part_type_guid_str="Partition GUID code"
|
|
||||||
CEPH_OSD_GUID="4FBD7E29-9D25-41B8-AFD0-062C0CEFF05D"
|
CEPH_OSD_GUID="4FBD7E29-9D25-41B8-AFD0-062C0CEFF05D"
|
||||||
|
|
||||||
# Check if we wipe OSDs
|
# Check if we wipe OSDs
|
||||||
@ -120,19 +120,55 @@ else
|
|||||||
echo "Not in upgrade, wiping disks: $WIPE_HDD"
|
echo "Not in upgrade, wiping disks: $WIPE_HDD"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
ROOTFS_DISK=$(get_disk $rootfs_device)
|
||||||
|
ROOTFS_PART_PREFIX=$ROOTFS_DISK
|
||||||
|
#check if disk is nvme
|
||||||
|
case $ROOTFS_DISK in
|
||||||
|
*"nvme"*)
|
||||||
|
ROOTFS_PART_PREFIX=${ROOTFS_PART_PREFIX}p
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
BACKUP_CREATED=0
|
||||||
|
|
||||||
|
# Note that the BA5EBA11-0000-1111-2222- is the prefix used by STX and it's defined in sysinv constants.py.
|
||||||
|
# Since the 000000000001 suffix is used by custom stx LVM partitions,
|
||||||
|
# the next suffix is used for the persistent backup partition (000000000002)
|
||||||
|
BACKUP_PART_LABEL="Platform Backup"
|
||||||
|
BACKUP_PART_GUID="BA5EBA11-0000-1111-2222-000000000002"
|
||||||
|
|
||||||
for dev in ${WIPE_HDD//,/ }
|
for dev in ${WIPE_HDD//,/ }
|
||||||
do
|
do
|
||||||
# Clearing previous GPT tables or LVM data
|
# Clearing previous GPT tables or LVM data
|
||||||
# Delete the first few bytes at the start and end of the partition. This is required with
|
# Delete the first few bytes at the start and end of the partition. This is required with
|
||||||
# GPT partitions, they save partition info at the start and the end of the block.
|
# GPT partitions, they save partition info at the start and the end of the block.
|
||||||
# Do this for each partition on the disk, as well.
|
# Do this for each partition on the disk, as well.
|
||||||
partitions=$(lsblk -rip $dev -o TYPE,NAME |awk '$1 == "part" {print $2}')
|
part_numbers=( $(parted -s $dev print | awk '$1 == "Number" {i=1; next}; i {print $1}') )
|
||||||
for p in $partitions $dev
|
for part_number in "${part_numbers[@]}"; do
|
||||||
do
|
part=$dev$part_number
|
||||||
echo "Pre-wiping $p from kickstart"
|
case $part in
|
||||||
dd if=/dev/zero of=$p bs=512 count=34
|
*"nvme"*)
|
||||||
dd if=/dev/zero of=$p bs=512 count=34 seek=$((`blockdev --getsz $p` - 34))
|
part=${dev}p${part_number}
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
sgdisk_part_info=$(flock $dev sgdisk -i $part_number $dev)
|
||||||
|
part_type_guid=$(echo "$sgdisk_part_info" | grep "$part_type_guid_str" | awk '{print $4;}')
|
||||||
|
if [ "$part_type_guid" == $BACKUP_PART_GUID ]; then
|
||||||
|
echo "Skipping wipe backup partition $part"
|
||||||
|
BACKUP_CREATED=1
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
echo "Wiping partition $part"
|
||||||
|
dd if=/dev/zero of=$part bs=512 count=34
|
||||||
|
dd if=/dev/zero of=$part bs=512 count=34 seek=$((`blockdev --getsz $part` - 34))
|
||||||
|
parted -s $dev rm $p
|
||||||
done
|
done
|
||||||
|
if [ $BACKUP_CREATED -eq 0 ] ; then
|
||||||
|
echo "Creating disk label for $dev"
|
||||||
|
parted -s $dev mktable gpt
|
||||||
|
fi
|
||||||
|
|
||||||
done
|
done
|
||||||
|
|
||||||
# Check for remaining cgts-vg PVs, which could potentially happen
|
# Check for remaining cgts-vg PVs, which could potentially happen
|
||||||
@ -149,23 +185,8 @@ done
|
|||||||
|
|
||||||
let -i gb=1024*1024*1024
|
let -i gb=1024*1024*1024
|
||||||
|
|
||||||
cat<<EOF>/tmp/part-include
|
|
||||||
clearpart --all --drives=$WIPE_HDD --initlabel
|
|
||||||
EOF
|
|
||||||
|
|
||||||
if [ -n "$ONLYUSE_HDD" ]; then
|
if [ -n "$ONLYUSE_HDD" ]; then
|
||||||
cat<<EOF>>/tmp/part-include
|
cat<<EOF>>/tmp/part-include
|
||||||
ignoredisk --only-use=$ONLYUSE_HDD
|
ignoredisk --only-use=$ONLYUSE_HDD
|
||||||
EOF
|
EOF
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -d /sys/firmware/efi ] ; then
|
|
||||||
cat<<EOF>>/tmp/part-include
|
|
||||||
part /boot/efi --fstype=efi --size=300 --ondrive=$(get_disk $boot_device)
|
|
||||||
EOF
|
|
||||||
else
|
|
||||||
cat<<EOF>>/tmp/part-include
|
|
||||||
part biosboot --asprimary --fstype=biosboot --size=1 --ondrive=$(get_disk $boot_device)
|
|
||||||
EOF
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
@ -17,6 +17,20 @@ if [ -n "$profile_mode" ]; then
|
|||||||
ROOTFS_OPTIONS="${ROOTFS_OPTIONS},iversion"
|
ROOTFS_OPTIONS="${ROOTFS_OPTIONS},iversion"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
cat<<EOF>/tmp/part-include
|
||||||
|
clearpart --all --drives=$WIPE_HDD --initlabel
|
||||||
|
EOF
|
||||||
|
|
||||||
|
if [ -d /sys/firmware/efi ] ; then
|
||||||
|
cat<<EOF>>/tmp/part-include
|
||||||
|
part /boot/efi --fstype=efi --size=300 --ondrive=$(get_disk $boot_device)
|
||||||
|
EOF
|
||||||
|
else
|
||||||
|
cat<<EOF>>/tmp/part-include
|
||||||
|
part biosboot --asprimary --fstype=biosboot --size=1 --ondrive=$(get_disk $boot_device)
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
|
||||||
cat<<EOF>>/tmp/part-include
|
cat<<EOF>>/tmp/part-include
|
||||||
part /boot --fstype=ext4 --asprimary --size=500 --ondrive=$(get_disk $rootfs_device) --fsoptions="$ROOTFS_OPTIONS"
|
part /boot --fstype=ext4 --asprimary --size=500 --ondrive=$(get_disk $rootfs_device) --fsoptions="$ROOTFS_OPTIONS"
|
||||||
part pv.253004 --grow --asprimary --size=500 --ondrive=$(get_disk $rootfs_device)
|
part pv.253004 --grow --asprimary --size=500 --ondrive=$(get_disk $rootfs_device)
|
||||||
|
@ -31,6 +31,20 @@ if [ -n "$profile_mode" ]; then
|
|||||||
ROOTFS_OPTIONS="${ROOTFS_OPTIONS},iversion"
|
ROOTFS_OPTIONS="${ROOTFS_OPTIONS},iversion"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
cat<<EOF>/tmp/part-include
|
||||||
|
clearpart --all --drives=$WIPE_HDD --initlabel
|
||||||
|
EOF
|
||||||
|
|
||||||
|
if [ -d /sys/firmware/efi ] ; then
|
||||||
|
cat<<EOF>>/tmp/part-include
|
||||||
|
part /boot/efi --fstype=efi --size=300 --ondrive=$(get_disk $boot_device)
|
||||||
|
EOF
|
||||||
|
else
|
||||||
|
cat<<EOF>>/tmp/part-include
|
||||||
|
part biosboot --asprimary --fstype=biosboot --size=1 --ondrive=$(get_disk $boot_device)
|
||||||
|
EOF
|
||||||
|
fi
|
||||||
|
|
||||||
cat<<EOF>>/tmp/part-include
|
cat<<EOF>>/tmp/part-include
|
||||||
part /boot --fstype=ext4 --asprimary --size=$BOOT_VOL_SIZE --ondrive=$(get_disk $rootfs_device) --fsoptions="$ROOTFS_OPTIONS"
|
part /boot --fstype=ext4 --asprimary --size=$BOOT_VOL_SIZE --ondrive=$(get_disk $rootfs_device) --fsoptions="$ROOTFS_OPTIONS"
|
||||||
part pv.253004 --asprimary --size=$CGTS_PV_SIZE --ondrive=$(get_disk $rootfs_device)
|
part pv.253004 --asprimary --size=$CGTS_PV_SIZE --ondrive=$(get_disk $rootfs_device)
|
||||||
|
@ -94,10 +94,42 @@ then
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Note that the BA5EBA11-0000-1111-2222- is the prefix used by STX and it's defined in sysinv constants.py.
|
||||||
|
# Since the 000000000001 suffix is used by custom stx LVM partitions,
|
||||||
|
# the next suffix is used for the persistent backup partition (000000000002)
|
||||||
|
BACKUP_PART_GUID="BA5EBA11-0000-1111-2222-000000000002"
|
||||||
|
part_type_guid_str="Partition GUID code"
|
||||||
|
|
||||||
for dev in $WIPE_HDD
|
for dev in $WIPE_HDD
|
||||||
do
|
do
|
||||||
if [[ -e $dev ]]
|
if [[ -e $dev ]]
|
||||||
then
|
then
|
||||||
|
if [ "$dev" == "$rootfs" ]
|
||||||
|
then
|
||||||
|
part_numbers=( $(parted -s $dev print | awk '$1 == "Number" {i=1; next}; i {print $1}') )
|
||||||
|
for part_number in "${part_numbers[@]}"; do
|
||||||
|
part=$dev$part_number
|
||||||
|
case $part in
|
||||||
|
*"nvme"*)
|
||||||
|
part=${dev}p${part_number}
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
sgdisk_part_info=$(flock $dev sgdisk -i $part_number $dev)
|
||||||
|
part_type_guid=$(echo "$sgdisk_part_info" | grep "$part_type_guid_str" | awk '{print $4;}')
|
||||||
|
if [ "$part_type_guid" == $BACKUP_PART_GUID ]; then
|
||||||
|
echo "Skipping wipe backup partition $part..."
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
echo "Wiping partition $part..."
|
||||||
|
wipefs -f -a $part
|
||||||
|
|
||||||
|
# Clearing previous GPT tables or LVM data
|
||||||
|
# Delete the first few bytes at the start and end of the partition. This is required with
|
||||||
|
# GPT partitions, they save partition info at the start and the end of the block.
|
||||||
|
dd if=/dev/zero of=$part bs=512 count=34
|
||||||
|
dd if=/dev/zero of=$part bs=512 count=34 seek=$((`blockdev --getsz $part` - 34))
|
||||||
|
done
|
||||||
|
else
|
||||||
echo "Wiping $dev..."
|
echo "Wiping $dev..."
|
||||||
wipefs -f -a $dev
|
wipefs -f -a $dev
|
||||||
|
|
||||||
@ -107,6 +139,7 @@ do
|
|||||||
dd if=/dev/zero of=$dev bs=512 count=34
|
dd if=/dev/zero of=$dev bs=512 count=34
|
||||||
dd if=/dev/zero of=$dev bs=512 count=34 seek=$((`blockdev --getsz $dev` - 34))
|
dd if=/dev/zero of=$dev bs=512 count=34 seek=$((`blockdev --getsz $dev` - 34))
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
if [[ -z $WIPE_HDD ]]
|
if [[ -z $WIPE_HDD ]]
|
||||||
|
Loading…
Reference in New Issue
Block a user