#!/bin/bash
# Determine disk device name
# Currently we can only support 1 disk.
# Disk with label 'config-2' or of type USB will
# be skipped.

MINSIZE=80000  # 80GB (1GB=1000MB)

# find any activation engine drive
AEDISK=$(blkid -L config-2)
while read -r dev sz; do
    if [ -d "/sys/class/block/$dev" ]; then
        removable=$(cat "/sys/class/block/$dev/removable")
        # Removable device such as dvd or usb will be filtered out
        # as well as a disk that contains the activation label
        # e.g. /dev/vda or /dev/vda1
        if [[ $removable -eq 0 && "$AEDISK" != "/dev/${dev}*" ]]; then
            # Check disk size
            sz=$((sz/1000/1000)) # convert to MB
            if [ "$sz" -gt "$MINSIZE" ]; then
               echo "$dev"
               exit 0
            fi
        fi
    fi
done < <(lsblk -r -n -d -b -o name,size)
exit 1
