A script to safely enable journaling on OS X client

Dec 10, '02 09:22:13AM

Contributed by: vonleigh

Here's an easy way to add journaling to your filesystems graphically. To set Journaling, all you do is run the script, put in your admin password and wait for Disk Utility to launch. In Disk Utility, select a Volume or Partition (not the actual Hard Drive) and you'll see that in the Info tab, at the bottom, is a button saying "Make Journaled". Click on it to enable or disable Journaling. After that, quit the Script and it will ask you for your admin password, it is important that you provide it again.

The script posted does the following: first it creates a file called ServerVersion.plist, when this file is present Disk Utility (and a few other apps) will 'think' that they are running on a Mac OS X Server machine instead of an Mac OS X Client and will allow you to enable journaling with one button.

When you quit the script, it will remove said file so Bad ThingsĀ® don't happen to your machine. Basically one thing that could happen if you leave that file there is that Software Update will think you are running Mac OS X Server and will send you the wrong update, potentially hosing your machine.

[Editor's note: There's a good discussion about journaling and the "OS X Server" related issues in this hint -- make sure you're comfortable with what you're doing before you proceed.]

The script will prompt you for your admin password twice, once to create the file, and once to delete it. I included some error checking in case something goes wrong. Here's the script:

try
with timeout of 600 seconds
do shell script ¬
"touch /System/Library/CoreServices/ServerVersion.plist" with administrator privileges
end timeout
on error
display dialog "You didn't provide your admin password,
script will now exit. No changes made."
return
end try

tell application "Disk Utility"
activate
end tell

on quit
try
do shell script ¬
"rm /System/Library/CoreServices/ServerVersion.plist" with administrator privileges
continue quit
on error
display dialog "Couldn't remove the file ServerVersion.plist
because you either did not provide an admin password
or other error. Please check the /System/Library/CoreServices
directory and remove this file if it exists. If you don't
evil things can happen to your machine"
end try
end quit
Note: It is important you compile the script as an Application, and that you set it to "stay open". A compiled script can be downloaded with this link.

The reason you need to compile it as an app is so the "on quit" statement gets called and it deletes the file properly; the reason you need to make it "stay open" is because if this option is not set, as soon as the script finishes, it'll try to delete the file. If you delete the file while Disk Utility is open, it'll take away the "Make Journaled" button immediately.

Comments (7)


Mac OS X Hints
http://hints.macworld.com/article.php?story=20021210062213717