-
-
Save chris1111/30b9123a6d06864c0fe34666a107f72b to your computer and use it in GitHub Desktop.
#!/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 |
First of all, thank you for your script.
After run script, I found it has issue on sudo mount -uw /:
./trim_enable.sh
Password:
mount_apfs: volume could not be mounted: Operation not permitted
mount: / failed with 77
IMPORTANT NOTICE: This tool force-enables TRIM for all relevant attached
devices, even though such devices may not have been validated for data
integrity while using TRIM. Use of this tool to enable TRIM may result in
unintended data loss or data corruption. It should not be used in a commercial
operating environment or with important data. Before using this tool, you
should back up all of your data and regularly back up data while TRIM is
enabled. This tool is provided on an “as is” basis. APPLE MAKES NO WARRANTIES,
EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF
NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE,
REGARDING THIS TOOL OR ITS USE ALONE OR IN COMBINATION WITH YOUR DEVICES,
SYSTEMS, OR SERVICES. BY USING THIS TOOL TO ENABLE TRIM, YOU AGREE THAT, TO THE
EXTENT PERMITTED BY APPLICABLE LAW, USE OF THE TOOL IS AT YOUR SOLE RISK AND
THAT THE ENTIRE RISK AS TO SATISFACTORY QUALITY, PERFORMANCE, ACCURACY AND
EFFORT IS WITH YOU.
Are you sure you wish to proceed (y/N)?
Do you have a Core Storage Volume?
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).
I use and test / Built the script with SIP Disable
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
Worked for me on 10.15.2.
Worked for me on 10.15.2.
Great!
See Choice Enable