Skip to content

Instantly share code, notes, and snippets.

@amitzilblog
Last active April 5, 2017 21:38
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 amitzilblog/b17303b62d1dc09b9f8d6c571b291177 to your computer and use it in GitHub Desktop.
Save amitzilblog/b17303b62d1dc09b9f8d6c571b291177 to your computer and use it in GitHub Desktop.
#!/bin/bash
if [ $(whoami) != "root" ]; then
echo "Please run this script as root"
exit
fi
asm_disks=""
for asm_disk in $(oracleasm listdisks); do
asm_disks=$(echo -e "${asm_disks}\n${asm_disk} $(oracleasm querydisk -p ${asm_disk} | egrep '^/dev/' | cut -d ':' -f 1)")
done
disks=$(fdisk -l | egrep 'Disk /dev' | awk '{print $2}' | sed -e 's/://g')
for d in ${disks}; do
parts=$(fdisk -l ${d} | egrep '^/dev/' | cut -f 1 -d ' ')
if [ -z "${parts}" ]; then
# no partitions
fs=$(df -P | grep ${d} | awk '{print $6}')
if [ -n "${fs}" ]; then
# file system
echo "Device ${d} - filesystem: ${fs}"
else
# asm
asm=$(echo "${asm_disks}" | grep ${d} | awk '{print $1}')
if [ -n "${asm}" ]; then
echo "Device ${d} - ASM (${asm})"
else
echo "Device ${d} - unallocated"
fi
fi
else
echo "Device ${d}:"
for p in ${parts}; do
# check filesystem
fs=$(df -P | grep ${p} | awk '{print $6}')
if [ -n "${fs}" ]; then
# file system
echo " - Partition ${p} is filesystem: ${fs}"
else
# asm
asm=$(echo "${asm_disks}" | grep ${p} | awk '{print $1}')
if [ -n "${asm}" ]; then
echo " - Partition ${p} is ASM (${asm})"
else
echo " - Partition ${p} is unallocated"
fi
fi
done
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment