How can I write-protect (make read-only) a USB drive in OS X?
I have a USB drive with some archive data on it that I'd like to access from a Mac running Snow Leopard. However, I want to ensure that the data on the drive is preserved and no modifications are made to the drive. The drive is FAT32 formatted and does not have a write-protect switch on it. How can I make the drive read-only or otherwise write-protect it by the OS so that I can ensure nothing is modified on the drive?
Option 1: Mount drive read-only
You can mount the USB drive read-only by using Diskutil.
- First, insert/mount the drive once, run
diskutil list
from Terminal.app and take note of the device representing the drive (should be something like/dev/diskN
with N being any number). - Eject the disk by running
diskutil unmountDisk /dev/diskN
replacing N by the number noted in the first step - Mount the disk read-only by running
diskutil mountDisk readOnly /dev/diskN
This of course requires that you actively run these commands every time you want to use the archive stick. For an automated solution, have a look at MarcoPolo or write a launchd command (see e.g. here for inspiration).
Option 2: Use access control on the drive
Does the drive really need to be formatted in FAT32 or do you only access it from a Mac OSX system anyway? In the later case, you can save the drive content on another drive, reformat it as a Mac OSX drive, move/copy the content back and take away any write rights from anybody.
Seems like editing the fstab
file would be the best solution as you don't need to unmount/manually mount the volume each time. It sounds very low level solution, so not even the system/root/spotlight would modify the drive.
http://www.macissues.com/2014/09/02/how-to-make-secondary-boot-partitions-read-only-in-os-x/
Open Disk Utility in the Applications > Utilities folder, and then select the volume in the device list on the left-hand side of the window. Now press Command-i to get information on the volume. In the window that pops up, locate the “Universal Unique Identifier” (UUID) string, which is a series of letters and numbers separated by dashes. Select the entire UUID and press Command-c to copy it.
Open the Terminal utility
Run the following command:
sudo pico /etc/fstab
Add the following line to the fstab file, and change the UUID from all zeros as shown here, to the value of the copied UUID from Disk Utility:
UUID=00000000-0000-0000-0000-000000000000 none hfs ro
Press Control-o to write the file changes, and then Control-x to exit the editor.