How do I prevent a disk from mounting?
I own an Iomega Prestige. The disk series includes a Virtual CD partition that includes a file encryption utility that can only be used on a Windows machine. Every time I mount the external drive to my filesystem, the Virtual CD partition mounts right along with it.
I'd like to prevent the Virtual CD from mounting while allowing the rest of the disk to be mounted without trouble. So, the question is: How can I either remove the Virtual CD partition or how can I prevent it from mounting?
I have seen a couple of options but they won't work:
Iomega makes a utility to remove this for a Windows system; problem is I don't run Windows but rather I use OS X 10.7.
There is a hint on MacOSXHints, but it is out of date for Lion.
/etc/fstab
is deprecated in Lion anddiskutil
no longer provides the UUID of a disk (at least as hinted on the page).
By the way, one cannot simply format and repartition the disk. The Virtual CD won't be removed.
The encryption utility which can also remove/hide the virtual CD is available for OSX now.
Iomega Encryption Utility Version 3.0 for Mac OS : Read First
Keep the following program running at all times in the background, e.g. by auto starting using launchd
:
#include <CoreFoundation/CoreFoundation.h>
#include <DiskArbitration/DiskArbitration.h>
DADissenterRef BlockMount(DADiskRef disk, void *context)
{
DADissenterRef dissenter = DADissenterCreate(kCFAllocatorDefault, kDAReturnNotPermitted, CFSTR("forbidden!"));
CFDictionaryRef description = DADiskCopyDescription(disk);
// UUID of the disk you don't want to mount:
CFUUIDRef backupDisk = CFUUIDCreateFromString(NULL, CFStringCreateWithCString(NULL, "3B5315C1-96AE-3471-B43C-2C41CDB12A64", kCFStringEncodingUTF8));
if (CFDictionaryContainsKey(description, kDADiskDescriptionVolumeUUIDKey)) {
CFUUIDRef value = CFDictionaryGetValue(description, kDADiskDescriptionVolumeUUIDKey);
if (CFEqual(backupDisk, value)) {
return dissenter;
}
}
return NULL;
}
int main (int argc, const char * argv[])
{
DAApprovalSessionRef session = DAApprovalSessionCreate (kCFAllocatorDefault);
if (!session)
{
fprintf(stderr, "failed to create Disk Arbitration session");
}
else
{
DARegisterDiskMountApprovalCallback(session, NULL, BlockMount, NULL);
DAApprovalSessionScheduleWithRunLoop(session, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
while (true) {
CFRunLoopRunInMode(kCFRunLoopDefaultMode, 60 /* seconds */, false);
}
DAApprovalSessionUnscheduleFromRunLoop(session, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
DAUnregisterApprovalCallback(session, BlockMount, NULL);
CFRelease(session);
}
return 0;
}
Find out the UUID of the volume you don't want to mount using diskutil list
(to get the device name) and diskutil info
to read the UUID.
Save as main.c and compile using the following command (you need Developer Tools):
cc main.c -o mountstopd -framework Foundation -framework DiskArbitration
On Mac OS X 10.7.1, doing the following worked for me just now (pretty much identical to what's in the OS X Hint):
First, find out the device name of the volume you don't want to be mounted:
diskutil list
Partial output looks like this:
/dev/disk3
#: TYPE NAME SIZE IDENTIFIER
0: Apple_partition_scheme *2.2 TB disk3
1: Apple_partition_map 32.3 KB disk3s1
2: Apple_HFS DroboBackup 2.2 TB disk3s3
In this example, DroboBackup is the actual partition, so /dev/disk3s3
is the device we need next. Then find out its UUID:
diskutil info /dev/disk3s3
Look for Volume UUID
, e.g. 3B5315C1-96AE-3471-B43C-2C41CDB12A64
.
Then, enter the following:
sudo touch /etc/fstab
sudo sh -c 'echo "UUID=3B5315C1-96AE-3471-B43C-2C41CDB12A64 none hfs rw,noauto" >> /etc/fstab'
This will prevent the disk from mounting.
I don't have an Iomega Prestige to test with, but you might try Aaron Burghardt's Disk Arbitrator utility.
From the introduction in the README (emphasis mine):
Disk Arbitrator is Mac OS X forensic utility designed to help the user ensure correct forensic procedures are followed during imaging of a disk device.
Disk Arbitrator is essentially a user interface to the Disk Arbitration framework, which enables a program to participate in the management of block storage devices, including the automatic mounting of file systems. When enabled, Disk Arbitrator will block the mounting of file systems to avoid mounting as read-write and violating the integrity of the evidence.
It is important to note that Disk Arbitrator is not a software write blocker—it does not change the state of currently attached devices nor does it affect newly attached devices to force a device to be read-only. The user still must be careful to not accidentally write to a disk with a command such as
dd
. Owing to this fact, a hardware or software write-blocker may still be desirable for the most sound procedure. Disk Arbitrator compliments a write-blocker with additional useful features and eliminates the typical forensic recommendation to "disable disk arbitration."