-
Notifications
You must be signed in to change notification settings - Fork 158
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create a test to verify partition numbers and sizes. This is to ensure that the partition scheme is valid during the transition to using OSBuild in the FCOS pipeline.
- Loading branch information
1 parent
f4f8dc7
commit b9c706a
Showing
1 changed file
with
51 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/bin/bash | ||
## kola: | ||
## exclusive: false | ||
## description: Verify the partition scheme is correct. | ||
## | ||
|
||
set -xeuo pipefail | ||
|
||
# shellcheck disable=SC1091 | ||
. "$KOLA_EXT_DATA/commonlib.sh" | ||
|
||
# check for 4 partitions | ||
root_part=$(findmnt -n -o SOURCE /sysroot) | ||
disk_name=$(lsblk --json -o PKNAME --path "$root_part" | jq --raw-output '.blockdevices[].pkname') | ||
totalPartitions=$(sudo lsblk --json --bytes -o NAME,FSTYPE,START,SIZE,MOUNTPOINT,PARTLABEL,PARTTYPENAME "$disk_name" | jq '.blockdevices[].children | length') | ||
if [[ $totalPartitions -ne 4 ]]; then | ||
fatal "Expected 4 partitions, got $totalPartitions" | ||
fi | ||
|
||
# get partition sizes | ||
partitionData=$(sudo lsblk --json -ba -o NAME,FSTYPE,START,SIZE,MOUNTPOINT,PARTLABEL,PARTTYPENAME | jq .blockdevices[].children[] ) | ||
biosBootSize=$( echo "$partitionData" | jq 'select ( .partlabel == "BIOS-BOOT" or .parttypename == "BIOS boot") | .size ' ) | ||
efiSystemSize=$( echo "$partitionData" | jq 'select ( .partlabel == "EFI-SYSTEM" or .parttypename == "EFI System") | .size ' ) | ||
bootSize=$( echo "$partitionData" | jq 'select ( .partlabel == "boot" or .mountpoint == "/boot") | .size ' ) | ||
# get start size of root partition since the growfs service runs on first boot | ||
rootSize=$( echo "$partitionData" | jq 'select ( .partlabel == "root" or .mountpoint == "/sysroot") | .start ' ) | ||
|
||
# check sizes of each parition | ||
ONE_MiB=$(( 1024 * 1024 )) | ||
expectedBIOSBootSize=$((1 * $ONE_MiB)) | ||
expectedEFISystemSize=$((127 * $ONE_MiB)) | ||
expectedBootSize=$((384 * $ONE_MiB)) | ||
expectedRootSize=$(($ONE_MiB + 2048 )) | ||
|
||
if [[ $biosBootSize -ne $expectedBIOSBootSize ]]; then | ||
fatal "Expected BIOS-BOOT partition of size $expectedBIOSBootSize, got $biosBootSize" | ||
fi | ||
|
||
if [[ $efiSystemSize -ne $expectedEFISystemSize ]]; then | ||
fatal "Expected EFI-SYSTEM partition of size $expectedEFISystemSize, got $efiSystemSize" | ||
fi | ||
|
||
if [[ $bootSize -ne $expectedBootSize ]]; then | ||
fatal "Expected boot partition of size $expectedBootSize, got $bootSize" | ||
fi | ||
|
||
if [[ $rootSize -ne $expectedRootSize ]]; then | ||
fatal "Expected starting root partition of size $expectedRootSize, got $rootSize" | ||
fi | ||
|
||
ok partition scheme |