Go Back   The macosxhints Forums > OS X Help Requests > AppleScript



Reply
 
Thread Tools Rate Thread Display Modes
Old 11-20-2012, 10:27 AM   #1
Tessoer
Prospect
 
Join Date: Nov 2012
Posts: 3
Help automate Disk Utility tasks.

Hi there,

I need help automating a task that is seemingly simple, but needs to be done over and over to different drives (as required by my job), and it's the following:

I need to do a full secure format/erase on select drives.
So what I need the automator/script to do is:

(Run)
- Choose drive
- Choose a full secure erase, or "empty space" erase
- Confirmation message.
- Start the full erase.
- Notify when done.

That's it.

I need this for two reasons.
One of which being the redundant task of needing to securely erase drives we have at work, or empty space of drives that need the data kept.
I also have others who need the same program, but aren't computer savvy.
So this would make life easier for both of us.

Thanks ahead of time.

Best Regards.
Tessoer is offline   Reply With Quote
Old 11-21-2012, 06:12 AM   #2
cpragman
All Star
 
Join Date: Jan 2004
Location: Limerick, PA
Posts: 687
Disk utility is ultimately a command line executable. Use a shell script in terminal.

Man diskutil for info
cpragman is offline   Reply With Quote
Old 11-21-2012, 06:57 AM   #3
Tessoer
Prospect
 
Join Date: Nov 2012
Posts: 3
So if I find a Shell Script that can give those same commands to the Terminal, it'd work without using an Automator or Disk Utilities?
Thanks nice to know

What about that last line you said, I don't know what you mean.
"Man diskutil for info"?

Thanks.
Tessoer is offline   Reply With Quote
Old 11-21-2012, 07:14 AM   #4
acme.mail.order
League Commissioner
 
Join Date: Sep 2003
Location: Tokyo
Posts: 6,045
Quote:
Originally Posted by Tessoer
- Choose drive
- Choose a full secure erase, or "empty space" erase
- Confirmation message.
- Start the full erase.
- Notify when done.

These are all tasks that Disk Utility already does, and does quite well. Wrapping it in another utility seems excessively complex.

Quote:
Originally Posted by Tessoer
I also have others who need the same program, but aren't computer savvy.

A good reason for the above, but if this data is important enough to require secure erase, then I would never consider delegating it to anyone who can't identify SATA and PATA from across the room. The probability of a major foul-up is ... large?

Are these full size spinning drives, or USB storage? If you are simply decommissioning old drives then a power nailer is much more efficient than secure erase (large-calibre handguns are a lot more fun, but the power nailer doesn't need permits).
acme.mail.order is offline   Reply With Quote
Old 11-21-2012, 06:36 PM   #5
Tessoer
Prospect
 
Join Date: Nov 2012
Posts: 3
I found a few commands I could type in Terminal to get some things done that I wanted.
Things like typing this in the command line:

diskutil info /dev/disk0s1 <-- depends on the disk you want to get info on.
- This line just shows some info on the drive.

Then I found things like:
diskutil reformat <-- I don't know how to use that one.
It keeps asking for the format, and I have no idea what formats are available or how to choose them. I tried writing FAT and NTFS, but nothing worked.

Basically, could someone help me with writing a sample per code of the following:

- How to fully format a drive
I think it starts like this:

diskutil eraseVolume

- How to erase the free space of an external drive.
diskutil secureErase freespace 0 /dev/disk0s1 <--- i'm not sure if that's the right way to select a drive. (Writing a number after "freespace" shows how many levels of format you want done.

- How to do a secure format of an external drive.
diskutil secureErase <--- that's all I know, I don't know how to select the format/level/drive/name...

Basically, could someone just "fill in the blanks" for me, or show me examples?
Thanks.
Tessoer is offline   Reply With Quote
Old 11-21-2012, 06:48 PM   #6
acme.mail.order
League Commissioner
 
Join Date: Sep 2003
Location: Tokyo
Posts: 6,045
diskutil comes with a very good man page, did you check there?

And before we go any further, you are aware that the device identifier is subject to change, and that using the wrong one will be very bad for your local storage?


There's a simple shortcut to "erase free space" that runs faster:

cat /dev/random > /Volumes/DiskName/bigfile; rm /Volumes/DiskName/bigfile
acme.mail.order is offline   Reply With Quote
Old 11-21-2012, 07:59 PM   #7
hayne
Site Admin
 
Join Date: Jan 2002
Location: Montreal
Posts: 31,938
Quote:
Originally Posted by Tessoer
What about that last line you said, I don't know what you mean.
"Man diskutil for info"?

You probably would benefit from reading this Unix FAQ
(The 'man' command is mentioned in the "commonly used commands" section)
__________________
hayne.net/macosx.html
hayne is offline   Reply With Quote
Old 11-21-2012, 08:04 PM   #8
acme.mail.order
League Commissioner
 
Join Date: Sep 2003
Location: Tokyo
Posts: 6,045
man ( ual for the program named ) diskutil

It's the instructions. If you want to use unix programs, you need to Read The Fine Manual that came with it. Skimming the manual, and copy/pasting commands from websites, are really good ways to destroy your system, as a recent user here found out - something copied from Apple's website of all places erased his main drive, his external drives, AND his backups. And it didn't say "are you sure?"
acme.mail.order is offline   Reply With Quote
Old 12-01-2012, 04:20 PM   #9
sojourner
Major Leaguer
 
Join Date: Apr 2010
Posts: 324
Reading your question, I was curious about the answer and found some information online:

Programatically Secure Erasing Free Space
Deleting and merging a partition with diskutil from the command line OSX
Securely erase free space from Terminal

If you don't find a shell script, you can have Automator run a shell script and type in the command you want.
__________________
see a problem; solve a problem.

Last edited by sojourner; 12-01-2012 at 04:23 PM.
sojourner is offline   Reply With Quote
Reply

Tags
automator, disk utility, full erase, secure erase

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT -5. The time now is 08:19 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, vBulletin Solutions, Inc.
Site design © IDG Consumer & SMB; individuals retain copyright of their postings
but consent to the possible use of their material in other areas of IDG Consumer & SMB.