# writeprotection for a usbstick

## flo89

Hi - i am searching for a solution to declare a usb stick as "write protected" - like a cdrom device.

in the moment you are trying to mount - the kernel drops a msg: "volume is writeprotected - mounting read only."

any idea? i do not mean, that you can lock the stick with a switch on the case. It should be a digital/software solution.

yours sincerly,

flo89

edit:\

dmesg output: Here should be a "Write Protect is On"

 *Quote:*   

> sd 7:0:0:0: [sda] 1002496 512-byte hardware sectors (513 MB)
> 
> sd 7:0:0:0: [sda] Write Protect is off
> 
> sd 7:0:0:0: [sda] Mode Sense: 03 00 00 00
> ...

 

----------

## costel78

I don't know if it fit your needs but what about use readonly (ro) option in fstab ?

Something like: /dev/[...] [mountpoint]	auto ro 0 0

Of course, this restriction could be avoided using manual mount.

----------

## flo89

sure - this is possible.

put i plan to use the stick on different systems and it should be unwriteable everytime.

but thank you for your try  :Smile: 

----------

## disi

I have actual seen sticks with a switch on it to turn on/off write protection. 

Which operating systems? If it's all NIX-like you could put on another filesystem like ext2, then set the permissions to only root can write to it? (or ntfs, but that requires the ntfs driver in linux)

----------

## flo89

it should protect the mbr too, so the filesystemrights are irrelevant.

is there no flag which i can set with a hex editor or sth. else?

----------

## Jaglover

I do remember there was a DOS virus which set my harddrive readonly once upon time. Have no clue how it did it, though.   :Confused: 

----------

## flo89

hoho - let's run a 80er virus =)

ok ehm - it does not have to protect the mbr too - it's my fault, sorry.

it could be nice to be able to protect the parition with sth. like fdisk.

----------

