[SystemsAdmin] Clearing disk partitions via CLI

  • List block devices of type disk
    lsblk -d -n -o kname, type| grep disk | awk '{print $1}'

  • remove block device MBR and GPT information
    `sgdisk -Z /dev/[DEVICE]

#!/usr/bin/env bash diskList=$(lsblk -d -n -o kname,type | grep disk | awk '{print $1}') for disk in $diskList do cmd="sgdisk -Z /dev/$disk" echo $cmd done