How to write protect (read-only) a hard drive?

Discussion in 'OS X Mavericks (10.9)' started by macstatic, Jun 15, 2016.

  1. macstatic macrumors 6502a

    Joined:
    Oct 21, 2005
    #1
    I can't believe I couldn't find anything useful on this when searching the web (everything seems to cover NTFS formatted drives that become read-only on a Mac), but I want to know how I can write-protect an external hard drive (SATA) connected (Firewire 800) to my Mac? It's MacOS Extended (journaled) formatted.

    I'd like to read from it, but it shouldn't be possible to overwrite files or mess it up in any way. The procedure shouldn't be permanent though, so is there a way to enable write-protection temporarily?
     
  2. CliftonHighgrov macrumors regular

    CliftonHighgrov

    Joined:
    Oct 1, 2014
    Location:
    United Kingdom
    #2
    You need to use the Terminal and edit the FSTAB file. This file is referred to whenever OS X attempts to mount a drive and modifies the mounting process accordingly. Using this you can assign a "ro" (read-only) switch to any volume of your choice. You can also disable binary execution on chosen volumes. It is a temporary change in so much as you can undo it any time you wish simply by prepending a "#" (pound) to its entry in FSTAB, and re-mounting the volume.

    Brief steps:

    NB: Make sure you are logged in as a user with SUDO rights, most likely an Admin. This walkthrough assumes your drive is formatted with the GUID partition scheme. Apologies in advance if you're already familiar with the CLI.

    1) Attach and mount drive
    2) Launch Disk Utility, select the volume in question in the sidebar, and Get Info.
    3) In the window that appears, look for the Universal Unique Identifier, composed of five clusters of hexadecimal digits separated by dashes, and copy it to the clipboard.
    4) Launch the Terminal, and execute the following command:
    sudo vifs
    You will be asked to authenticate with the current user's password. This text will not appear as you type. This opens FSTAB in VIM, a CLI-based text editor.
    5) Move the text entry cursor to an empty line and press the letter, "o" once. The text entry cursor will move down a line and the word, "INSERT" will appear at the foot of the window.
    6) Enter the following text, tabbing between each group:
    UUID=? none hfs ro
    Replace the "?" above by copy/pasting the UUID from the clipboard instead.
    7) Hit ESCAPE, then type a colon, ":" and then "x". Hit ENTER. You have now edited and saved changes to the FSTAB file.
    8) You should now be out of the text editor and back to the command-line. You can quit Terminal now, and test the result by unmounting and remounting the drive.

    That's it. Execute, "man fstab" in the Terminal for more info.
     

Share This Page