Skip to content

Instantly share code, notes, and snippets.

@chris1111
Created July 20, 2019 01:53
Show Gist options
  • Save chris1111/30b9123a6d06864c0fe34666a107f72b to your computer and use it in GitHub Desktop.
Save chris1111/30b9123a6d06864c0fe34666a107f72b to your computer and use it in GitHub Desktop.
Enable or Disable the Trim in macOS Catalina 10.15
#!/bin/bash
# Simple script by chris1111
# Vars
apptitle="Trim Enabler Catalina"
version="1.0"
# Set Icon directory and file
iconfile="/System/Library/CoreServices/Expansion Slot Utility.app/Contents/Resources/AppIcon.icns"
# Select Trim Choice
response=$(osascript -e 'tell app "System Events" to display dialog "Enable or Disable the Trim in macOS Catalina\n\nCancel for Exit" buttons {"Enable","Disable","Cancel"} default button 1 with title "'"$apptitle"' '"$version"'" with icon POSIX file "'"$iconfile"'" ')
action=$(echo $response | cut -d ':' -f2)
# Action is user select Disable
if [ "$action" == "Disable" ] ; then
response=$(osascript -e 'tell app "System Events" to display dialog "Your Choice is Disable Trim Enabler Catalina\n\n" buttons {"Cancel","OK"} default button 2 with title "'"$apptitle"' '"$version"'" with icon POSIX file "'"$iconfile"'" ')
answer=$(echo $response | grep "OK")
# Cancel if unable
if [ ! "$answer" ] ; then
echo "Program closing User cancelled
Exit"
exit 012345
fi
sudo mount -uw /
killall Finder
sudo trimforce disable
exit 0
fi
# Action is user select Enable
if [ "$action" == "Enable" ] ; then
response=$(osascript -e 'tell app "System Events" to display dialog "Your Choice is Enable Trim Enabler Catalina\n\n" buttons {"Cancel","OK"} default button 2 with title "'"$apptitle"' '"$version"'" with icon POSIX file "'"$iconfile"'" ')
answer=$(echo $response | grep "OK")
# Cancel if unable
if [ ! "$answer" ] ; then
echo "Program closing User cancelled
Exit"
exit 012345
fi
sudo mount -uw /
killall Finder
sudo trimforce enable
exit 0
fi
# Cancel is user selects Cancel
if [ ! "$imagepath" ] ; then
echo "Program closing User cancelled
Exit"
exit 012345
fi
@driscollxy
Copy link

Do you have a Core Storage Volume?

No, I have no CoreStorage.
I list using diskutil cs list shows 2 external disks (no Macintosh HD in the list).

@chris1111
Copy link
Author

I use and test / Built the script with SIP Disable

@driscollxy
Copy link

I use and test / Built the script with SIP Disable

Oh, I got it. Thank you for your answer about SID Disable. This case I'm ok to ignore mount: / failed with 77 for MacOS is SIP Enable.

BR,
Jeans

@kimsyversen
Copy link

Worked for me on 10.15.2.

@chris1111
Copy link
Author

Worked for me on 10.15.2.

Great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment