Skip to content

Commit

Permalink
Change to use sfdisk
Browse files Browse the repository at this point in the history
Use sfdisk instead of lsblk to get the partition table. This requires
some changes in how the size of partitions are checked since sfdisk
records disk size in sectors, not MiB.
  • Loading branch information
lukewarmtemp committed Nov 28, 2023
1 parent 13a364c commit c90c387
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions tests/kola/disks/partition-scheme
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ set -xeuo pipefail

root_part=$(findmnt -n -o SOURCE /sysroot)
disk_name=$(lsblk --json -o PKNAME --path "$root_part" | jq --raw-output '.blockdevices[].pkname')
diskData=$(lsblk --json --bytes -o NAME,FSTYPE,START,SIZE,MOUNTPOINT,PARTLABEL,PARTTYPENAME,LOG-SEC "$disk_name" | jq '.blockdevices[]' )
partitionData=$(echo $diskData | jq '.children[]')
totalPartitions=$(echo $diskData | jq '.children | length')
sector_size=$(echo $diskData | jq '.["log-sec"]')
diskData=$(sfdisk --json "$disk_name" | jq '.partitiontable' )
partitionData=$(echo $diskData | jq '.partitions[]')
totalPartitions=$(echo $diskData | jq '.partitions | length')
sector_size=$(echo $diskData | jq .sectorsize)

if [[ $totalPartitions -ne 4 ]]; then
fatal "Expected 4 partitions, got $totalPartitions"
Expand All @@ -39,10 +39,10 @@ expected_start=$(( 1 * $ONE_MiB / $sector_size ))

# Iterate over the partitions and check their
for key in ${!expected[@]}; do
echo "${key}, ${expected[${key}]}"
size_MiB="${expected[${key}]}"
start=$(echo "$partitionData" | jq "select ( .partlabel == \"$key\") | .start")
size=$(echo "$partitionData" | jq "select ( .partlabel == \"$key\") | .size")
start=$(echo "$partitionData" | jq "select ( .name == \"$key\") | .start")
sectors=$(echo "$partitionData" | jq "select ( .name == \"$key\") | .size")
size=$(( $sectors * $sector_size ))
if [[ "$start" -ne "$expected_start" ]]; then
fatal "Expected $key partition start sector of $expected_start, got $start"
fi
Expand All @@ -58,4 +58,4 @@ for key in ${!expected[@]}; do
done

ok partition scheme
exit 0
exit 0

0 comments on commit c90c387

Please sign in to comment.