There are two reasons you would want to prevent Linux from writing anything to an external harddrive or USB drive when you plug it in:
- To recover accidentally deleted files from now "empty" part of the drives
- For digital forensics, you need to be certain nothing on the drive has changed when you make a clone of it
There are drive connectors and external enclosures just for this purpose, and have a switch or button on them which physically blocks any write commands from reaching the drive.
However, my USB-to-IDE connector doesn't have that luxury. I have heard this is possible to achieve by software instead (which would include having to disable Ubuntu's auto-mounting), but I'm not finding any instructions online on how to do this.
How do I prevent Ubuntu from writing anything to an external harddrive for the purposes of preserving all data on it?
In my particular case I will be using Ubuntu, however, I asked on Unix & Linux rather than AskUbuntu in the hope of finding an answer that would work across distributions, and not just in my particular case. Both types of answers are welcome.