Visit Our UNIX and Linux User Community


Set readonly


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Set readonly
# 1  
Old 03-21-2012
Set readonly

I'm confused using hdparm -r1 /dev/sda9

although it shows readonly set to 1 (on) - I can touch a file and edit and save it.

why?
# 2  
Old 03-21-2012
What Operating System are you running when you type this command?
Not expecting "-r" to have another parameter.
# 3  
Old 03-21-2012
Quote:
Originally Posted by methyl
What Operating System are you running when you type this command?
Not expecting "-r" to have another parameter.
I'm still using Linux 2.6.32-33-server (Ubuntu 4.4.3) here.

I read the hdparm manual and found out to set parameter with this syntax ( -r1 ).

hdparm /dev/sda9 showed readonly set to 0.

after hdparm -r1 /dev/sda9 it showed readonly = 1 (on)

but still write operations allowed. also tried with another user than 'root'.
# 4  
Old 03-21-2012
Unless anybody here has any better suggestions, I'd take it up with the software authors.
Personally I'd use the read-only option to "mount".
# 5  
Old 03-21-2012
Setting read-only on a mounted disk tears the floor out from under the operating system, because you're telling the disk itself, not OS, to act in a read-only fashion. I suspect it would cause write-errors much later, not immediate 'permission denied'. Only when the OS tries to sync cache to disk would it realize it can't write.

That's if it realizes the write failed at all -- if it doesn't, very inexplicable behavior and crashes are probably in the near future when the contents on disk end up having less and less resemblance to what the kernel believes they should!

Not all disks support the read-only feature, as well.

Last edited by Corona688; 03-21-2012 at 02:22 PM..
# 6  
Old 03-22-2012
Quote:
Originally Posted by Corona688
Setting read-only on a mounted disk tears the floor out from under the operating system, because you're telling the disk itself, not OS, to act in a read-only fashion.
I don't understand.
If a program tries to write on a disk it doesn't call a system function to get if it is writeenabled? why it doesn't check for this disk setting too?

Quote:
I suspect it would cause write-errors much later, not immediate 'permission denied'. That's if it realizes the write failed at all -- if it doesn't, very inexplicable behavior and crashes are probably in the near future when the contents on disk end up having less and less resemblance to what the kernel believes they should
I tested the creation and editing of a file and OS told me the file is there and changed. After restart the file was still there.

I'll check mount to set readonly flag..
# 7  
Old 03-22-2012
Quote:
Originally Posted by daWonderer
I don't understand.
If a program tries to write on a disk it doesn't call a system function to get if it is writeenabled?
It calls a system call, yes.

The system call puts the changes in memory. It doesn't go directly to the disk.
Quote:
why it doesn't check for this disk setting too?
This is not an operating system setting. It's not even a setting stored on the disk itself. This is a hard drive setting where if you took the drive out and put it in a different system, it would theoretically persist there. Very low level. Poking this and then complaining that it doesn't work would be like manually tristating the lines then complaining it can't communicate.
Quote:
I tested the creation and editing of a file and OS told me the file is there and changed. After restart the file was still there.
Then I don't think your drive supports the hardware read-only feature.
 

Previous Thread | Next Thread
Test Your Knowledge in Computers #834
Difficulty: Medium
JSON supports comments.
True or False?

8 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

removing readonly behaviour from variable

Hi, I am new to shell programming. I just wanted to know if I set a variable to readonly. How do I revert it back to normal. name="some_name" readonly name Now I want to make name variable back to it normal, on which I can perform write operation too. Thanks (3 Replies)
Discussion started by: dearvivekkumar
3 Replies

2. Linux

root filesystem goes readonly

I see this when tried to create a dir using root fstab entries are pretty normal tried to remount with rw but it is still the same block device /dev/sda2 is write-protected ---------- Post updated at 04:57 PM ---------- Previous update was at 03:51 PM ---------- fstab entry ... (4 Replies)
Discussion started by: robo
4 Replies

3. AIX

How to make LOGNAME writeable? It is set as READONLY in .profile

LOGNAME variable is set as READONLY in .profile. I want to make it WRITEABLE so that I can modify the LOGNAME values programatically/throush shell programs. Thanks, Guru (1 Reply)
Discussion started by: gurubbc
1 Replies

4. Debian

Force readonly mount always.

I would want one of my partition to be mounted read only always... How to do that ? 1. /etc/fstab I know that, in options we can give ro -- so when the machine boots up or 'mount -a' it will be mounted read only. But i dont want that to be mounted when machine boots up. We will mount that... (3 Replies)
Discussion started by: thegeek
3 Replies

5. Shell Programming and Scripting

Readonly

After I issused $readonly THIN. How to change back the varaibale from read only to writeable? (1 Reply)
Discussion started by: Paris Heng
1 Replies

6. UNIX for Advanced & Expert Users

how to unset the readonly variable

Hi All, May be this is a very simple question... $ b=8 $ readonly b $ echo $b 8 $ b=90 -bash: b: readonly variable $ unset b -bash: unset: b: cannot unset: readonly variable I m not able to change the readonly mode of variable b Please help me out.. Thanks Nidhi (2 Replies)
Discussion started by: Nidhi2177
2 Replies

7. UNIX for Dummies Questions & Answers

Readonly access

Hi, I have create a user using the following command useradd -d /home/rozan -s /bin/bash -c "Rozan ahmed" -g dba rozan I would like to give her only the read only access to $BDUMP_HOME/alert.log file The owner of the file is oracle:oinstall Regards Faruque (13 Replies)
Discussion started by: faruque.ahmed
13 Replies

8. UNIX for Dummies Questions & Answers

Making files readonly with vi?

Hi, I'm new at this whole Unix thing, but definately learning (lots of fun)... and I was wondering - how do you make a file read-only with vi? I don't mean how do you load up vi in read-only mode, but how do you save a file (or flag a file, or whatever) in vi to read-only? How do you make it... (2 Replies)
Discussion started by: Flyguy
2 Replies

Featured Tech Videos