How to make hard drives read only?

All Gurus once were Newbies
Forum rules
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Please stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions prefer the other forums within the support section.
Before you post please read how to get help
Post Reply
hepme
Level 1
Level 1
Posts: 25
Joined: Wed Dec 25, 2019 2:54 pm

How to make hard drives read only?

Post by hepme »

I have a hard drive with movies on it and want to insure it is not messed-up inadvertently. Can I make it READ-ONLY?
thanks

User avatar
pebcak
Level 1
Level 1
Posts: 28
Joined: Mon Dec 16, 2019 4:59 am

Re: How to make hard drives read only?

Post by pebcak »

I am relatively new to Linux and very new to this forum but the following link is worth to read through:
https://www.addictivetips.com/ubuntu-li ... -on-linux/
See as well man mount and mount --help

grellyd
Level 1
Level 1
Posts: 6
Joined: Tue Dec 31, 2019 5:19 pm

Re: How to make hard drives read only?

Post by grellyd »

As pebcak mentioned, take a look at the `mount` command.

Assuming you are mounting the drive manually, you can do something like `mount -o ro /dev/sda1 /mnt/hd0`.

If you want it automatically mounted, you will have to edit your fstab file and add in an entry for the drive. There as well you can specify the read only option.

There is an interesting caution from mount's man page; you may still get journalling and other minor writes, but I suspect no change to your data.

From https://linux.die.net/man/8/mount:

Code: Select all

-r, --read-only
Mount the filesystem read-only. A synonym is -o ro.
Note that, depending on the filesystem type, state and kernel behavior, the system may still write to the device. 
For example, Ext3 or ext4 will replay its journal if the filesystem is dirty. 
To prevent this kind of write access, you may want to mount ext3 or ext4 filesystem with "ro,noload" mount options or set the block device to read-only mode, see command blockdev(8).

hepme
Level 1
Level 1
Posts: 25
Joined: Wed Dec 25, 2019 2:54 pm

Re: How to make hard drives read only?

Post by hepme »

I have lost videos before (W-7) and am wary of doing it again. The HDD is 2-3T and backing it up is illogical for me as I have nothing blank to dump it onto. As apparently changing it to semi-permanent read-only is an 'iffy' thing guess its better to just leave it alone and be careful.
Thanks


jglen490
Level 5
Level 5
Posts: 999
Joined: Sat Jul 15, 2017 9:57 pm

Re: How to make hard drives read only?

Post by jglen490 »

hepme wrote:
Wed Jan 01, 2020 2:33 pm
I have lost videos before (W-7) and am wary of doing it again. The HDD is 2-3T and backing it up is illogical for me as I have nothing blank to dump it onto. As apparently changing it to semi-permanent read-only is an 'iffy' thing guess its better to just leave it alone and be careful.
Thanks
You might look at trying to come up with a backup solution. With modern tools based on the rsync command, but with the convenience of GUI controls, you can backup once which might be an overnight thing the first time, and then backup only those files that have been added in subsequent backups.

I know what a hardware failure, as well as unintended "fat fingering", can do to irreplaceable personal data. Drives that can be temporarily mounted via USB, spinners as well as SSDs, are coming down in price and can be a great way to save your important files locally without keeping that backup drive permanently mounted.
I feel more like I do than I did when I got here.
Toshiba A135-S2386, Intel T2080, ATI Radeon® Xpress 200M Chipset, 2GB RAM, 500GB

cliffcoggin
Level 5
Level 5
Posts: 989
Joined: Sat Sep 17, 2016 6:40 pm
Location: England

Re: How to make hard drives read only?

Post by cliffcoggin »

If it is an external USB drive my simple solution is to stick tape over the plug. It requires a conscious effort to remove the tape to make it playable.
Cliff Coggin

squiggles3
Level 1
Level 1
Posts: 19
Joined: Wed Apr 10, 2019 12:40 am

Re: How to make hard drives read only?

Post by squiggles3 »

Why not use

Code: Select all

sudo chmod -R 444 [path to drive mount point]
This will set the drive and all files to read only for everyone. If you want to do something with the drive afterwards, you'll have to run chmod again and change the permissions. A process that doesn't really happen by accident.

hepme
Level 1
Level 1
Posts: 25
Joined: Wed Dec 25, 2019 2:54 pm

Re: How to make hard drives read only?

Post by hepme »

squiggles3 ; APOLOGIES for the long time lapse. Age effects concentration and I get sidelined with other priorities, sorry.

Wondering (how) I "run chmod again and change permissions"? Does running it again (same) just 'reset' HDDs to operate normally again or is there another sudo chmod to run in the process?

I like to check out the swamp before wading in you might say.. Alligators and snakes live there you know.
Thanks for the response

altair4
Level 20
Level 20
Posts: 10070
Joined: Tue Feb 03, 2009 10:27 am

Re: How to make hard drives read only?

Post by altair4 »

You don't want to do a chmod 444 anyway.

You won't be able to open up your directory to get to what is under it. Octal chmods on directories always have to be an odd number like 555. And you don't want to do it recursively or else you would make every file executable.

Since no one has asked this question yet I will. How is this partition formatted? ext4, ntfs, fat32....?
Please add a [SOLVED] at the end of your original subject header if your question has been answered and solved.

hepme
Level 1
Level 1
Posts: 25
Joined: Wed Dec 25, 2019 2:54 pm

Re: How to make hard drives read only?

Post by hepme »

3.0TB- NTFS

Post Reply

Return to “Newbie Questions”