Skip to content

Instantly share code, notes, and snippets.

@jacobsalmela
Created February 26, 2015 20:03
Show Gist options
  • Save jacobsalmela/65aa7a7102a29b82daba to your computer and use it in GitHub Desktop.
Save jacobsalmela/65aa7a7102a29b82daba to your computer and use it in GitHub Desktop.
Reset the volume name to "Macintosh HD" if it is different.
#!/bin/bash
volumeName=$(diskutil info / | awk '/Volume Name/ {print substr ($0, index ($0,$3))}')
echo "Current volume name: $volumeName"
# If the volume is not named Macintosh HD
if [ "$volumeName" != "Macintosh HD" ];then
# Rename it
diskutil renameVolume "$volumeName" "Macintosh HD"
volumeName=$(diskutil info / | awk '/Volume Name/ {print substr ($0, index ($0,$3))}')
echo "Root volume is now named: $volumeName"
exit 0
else
# Exit 1 because something went wrong
echo "Something went wrong."
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment