Skip to content

Instantly share code, notes, and snippets.

@jaysonsantos
Last active March 12, 2019 15:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jaysonsantos/e26a355e1fc3cae5f2788515b9efad3f to your computer and use it in GitHub Desktop.
Save jaysonsantos/e26a355e1fc3cae5f2788515b9efad3f to your computer and use it in GitHub Desktop.
find_kafka_device() {
for device in $(nvme list | grep ^/dev | awk '{print $1}')
do
local found_device="$(nvme id-ctrl -v $device | grep -Po '/dev/[a-z0-9]+' || true)"
if [[ -n "$found_device" ]]; then
echo "$device"
return 0
fi
done
return 1
}
main() {
kafka_device="$(find_kafka_device)"
already_formatted="$(blkid "$kafka_device" | grep kafka || true )"
if [[ -n "$already_formatted" ]]; then
echo "Kafka partition already created"
else
mkfs.ext4 -L kafka "$kafka_device"
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment