Skip to content

Instantly share code, notes, and snippets.

@jacobsalmela
Created June 1, 2014 16:05
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jacobsalmela/5876115cafff2dea8eb3 to your computer and use it in GitHub Desktop.
Save jacobsalmela/5876115cafff2dea8eb3 to your computer and use it in GitHub Desktop.
Partitions the disk for putting /Users on a separate partition
#!/bin/bash
#----------VARIABLES---------
echo "Checking hard disk ID..."
hardDiskID=$(diskutil list | awk '/GUID_partition_scheme/ {print $5}')
#----------------------------
#-----------SCRIPT-----------
#----------------------------
echo "Checking if Users partition exists..."
# List the disks available and grep for Users
diskutil list | grep "Users HD"
# If the last command exits with status 1 (failed--meaning no Users partition was found), then
if [ $? = 1 ];then
echo -e "Creating Users and Recovery partitions...\n"
# Partition the disk with three partitions using GPT
# The first should be JHFS+, named Macintosh HD, and use the first 30% of the disk
# The second should be the same as above, but use 68%
# The last partition should use the Remainder of the disk
diskutil partitionDisk $hardDiskID 3 GPT JHFS+ "Macintosh HD" 30% JHFS+ "Users HD" 68% JHFS+ "Recovery HD" R;
else
echo "Users partition already exists...no changes made."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment