Searching \ for '[EE] Read-only USB hard drive?' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: www.piclist.com/techref/mems.htm?key=hard+drive
Search entire site for: 'Read-only USB hard drive?'.

Exact match. Not showing close matches.
PICList Thread
'[EE] Read-only USB hard drive?'
2008\03\07@132216 by hgraf

picon face
Another interesting question...

I've created some hardware to emulate an IDE hard drive. I've connected
this emulated drive to a computer using a USB2.0-PATA bridge.

It works well, however, due to the way things need to work it would make
my life easier if I could prevent the OS from writing to my "drive".

Is there a way under linux (Ubuntu 7.10) to cause a USB hard drive to be
mounted read-only (it's currently being auto mounted, I don't want my
changes to have any effect on other USB drives being mounted)? Is there
something in the identify drive data that a hard drive returns that I
can set to cause the hard drive to be read only (I can change anything
there I want)?

Again, I've googled, but haven't really come up with anything.

Thanks for any pointers.

TTYL

2008\03\07@173355 by David VanHorn

picon face
Don't a lot of them have write protect locks?

2008\03\07@190041 by Robert Rolf

picon face
Why not modify your code to make the drive Read only, unless
some sort of 'unlock' sequence is executed? E.g. read last sector,
N-1, n-2, n-3 then n-3 n-2 n-1 N.
Something no O/S will do, but your 'unlock' program would.

R


hgraf wrote:

{Quote hidden}

2008\03\07@192138 by sergio masci

flavicon
face
I don't know if you've already had a look at usbfs - maybe something there
that would help.

Have a look around here (if you haven't already):

http://www.linux-usb.org/USB-guide/c607.html

Regards
Sergio


{Quote hidden}

2008\03\07@192940 by Herbert Graf
flavicon
face

On Fri, 2008-03-07 at 17:33 -0500, David VanHorn wrote:
> Don't a lot of them have write protect locks?

Unfortunately I'm not dealing with a real drive, but I would be
interested in what such a switch exactly does? How does the OS get told
the drive is read only?

Thanks, TTYL

2008\03\07@193324 by Herbert Graf

flavicon
face

On Fri, 2008-03-07 at 17:00 -0700, Robert Rolf wrote:
> Why not modify your code to make the drive Read only, unless
> some sort of 'unlock' sequence is executed? E.g. read last sector,
> N-1, n-2, n-3 then n-3 n-2 n-1 N.
> Something no O/S will do, but your 'unlock' program would.

Well, the fact is it's not a "real" drive, it just looks like one to the
OS.

Nothing in my device is "writable", so I'm not concerned about the OS
attempting to write stuff and it mucking up my hardware. The issue is
because I don't have anything writable the OS gets confused when it
writes something but then notices the copy on my "drive" doesn't match
(I get dropped write page errors in dmesg). The most common occurance is
updating the root directory entries with access times. So far it doesn't
appear that these errors are an issue, things seem to work fine, but I
am concerned that with the right software/hardware combination it will
pop up as a problem.

How does a hard drive tell an OS it's write protected? Is it even
possible?

Thanks, TTYL

2008\03\07@194426 by Marcel Birthelmer

flavicon
face
Herbert,
in the USB  case, I think simply stalling the pipe on a WRITE_10 or
WRITE_12 command is enough to indicate that the device is read-only.
As for the linux side of things, you should be able to add 'ro' to
your mount options. That should be enough for read-only.
>From what I understand, though, your device works at the ATA level,
not the USB level, and I don't know anything about that, sorry.
- Marcel

{Quote hidden}

> --

2008\03\07@195355 by Michael Dipperstein

face
flavicon
face
> From: spam_OUTpiclist-bouncesTakeThisOuTspammit.edu [.....piclist-bouncesKILLspamspam@spam@mit.edu] On
Behalf
> Of Herbert Graf
>
> On Fri, 2008-03-07 at 17:33 -0500, David VanHorn wrote:
> > Don't a lot of them have write protect locks?
>
> Unfortunately I'm not dealing with a real drive, but I would be
> interested in what such a switch exactly does? How does the OS get
told
> the drive is read only?

Am I missing something, or is it enough to use /etc/fstab to tell the OS
that the drive is read only?

-Mike

2008\03\07@200606 by Herbert Graf

flavicon
face

On Fri, 2008-03-07 at 16:40 -0800, Michael Dipperstein wrote:
> > From: piclist-bouncesspamKILLspammit.edu [.....piclist-bouncesKILLspamspam.....mit.edu] On
> Behalf
> > Of Herbert Graf
> >
> > On Fri, 2008-03-07 at 17:33 -0500, David VanHorn wrote:
> > > Don't a lot of them have write protect locks?
> >
> > Unfortunately I'm not dealing with a real drive, but I would be
> > interested in what such a switch exactly does? How does the OS get
> told
> > the drive is read only?
>
> Am I missing something, or is it enough to use /etc/fstab to tell the OS
> that the drive is read only?

Considering the USB drive is automounted by the OS, and I don't want to
affect the behaviour of other USB drives that might be plugged in, I
didn't think this was an option. That was why I was hoping there was a
method over the ATA interface to indicate RO.

That said, is there a way to selectively set the mount options for USB
drives?

Thanks, TTYL

2008\03\07@201015 by Peter Todd

picon face
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Fri, Mar 07, 2008 at 04:40:18PM -0800, Michael Dipperstein wrote:
{Quote hidden}

No actually, there are some weird corner cases to that. Journaling
filesystems for instance often can't mount the filesystem until any
uncommited transactions have been rolled back. This will write to the
drive, even though you wouldn't expect it.

That said, I last read about that issue a few years ago, it may have
been fixed by now on Linux.

- --
http://petertodd.org
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)

iD8DBQFH0eY93bMhDbI9xWQRAn+YAKCu3RxuDEDsmNBavQXjsbbGbvueggCdGk+Z
0udWKo//3D1I5WnfrmvrFF8=
=LvXm
-----END PGP SIGNATURE-----

2008\03\07@211339 by Xiaofan Chen

face picon face
On Sat, Mar 8, 2008 at 9:05 AM, Herbert Graf <@spam@mailinglist4KILLspamspamfarcite.net> wrote:

> > Am I missing something, or is it enough to use /etc/fstab to tell the OS
> > that the drive is read only?
>
> Considering the USB drive is automounted by the OS, and I don't want to
> affect the behaviour of other USB drives that might be plugged in, I
> didn't think this was an option. That was why I was hoping there was a
> method over the ATA interface to indicate RO.
>
> That said, is there a way to selectively set the mount options for USB
> drives?

Maybe udev rules will help here.
Some pointer through Google.
ubuntuforums.org/showthread.php?t=268291
http://ubuntuforums.org/showpost.php?p=1574752
http://ubuntuforums.org/archive/index.php/t-633209.html


Xiaofan

2008\03\07@211619 by Wayne Topa

flavicon
face
Herbert Graf(KILLspammailinglist4KILLspamspamfarcite.net) is reported to have said:
{Quote hidden}

What your looking for is in man 8 mount.

mount -r /dev/sda1

-r     Mount the file system read-only. A synonym is -o ro.

Wayne

--
Programmers don't die, they just GOSUB without RETURN
_______________________________________________________

2008\03\07@213212 by Herbert Graf

flavicon
face

On Fri, 2008-03-07 at 20:41 -0500, Wayne Topa wrote:
> > How does a hard drive tell an OS it's write protected? Is it even
> > possible?
>
> What your looking for is in man 8 mount.
>
> mount -r /dev/sda1
>
> -r     Mount the file system read-only. A synonym is -o ro.

Any pointers on how I would go about doing this for something that is
automounted by default (I'm using Ubuntu), without affecting all devices
that are automounted?

Thanks, TTYL

2008\03\07@225240 by Wayne Topa

flavicon
face
Herbert Graf(RemoveMEmailinglist4TakeThisOuTspamfarcite.net) is reported to have said:
>
> On Fri, 2008-03-07 at 20:41 -0500, Wayne Topa wrote:
> > > How does a hard drive tell an OS it's write protected? Is it even
> > > possible?
> >
> > What your looking for is in man 8 mount.
> >
> > mount -r /dev/sda1
> >
> > -r     Mount the file system read-only. A synonym is -o ro.
>
> Any pointers on how I would go about doing this for something that is
> automounted by default (I'm using Ubuntu), without affecting all devices
> that are automounted?

If it's automounted it should /etc/fstab.  Comment that entry,
reboot then do the mount command.  If it's not in /etc/fstab find out
whats mounting it using dmesg.  

dmesg |less |grep (whatever the device is called).

To find out what the device is try the df command.
~# df
Filesystem        Size  Used Avail Use%                                    Mounted on
/dev/sda5          49G 8954M   39G 17.8 [######..........................] /
udev               10M   80k   10M  0.8 [................................] /dev
tmpfs            1007M     0 1007M  0.0 [................................] /dev/shm
/dev/sda7          30G 1434M   28G  4.7 [##..............................] /emul/chroot-lenny-i386
/dev               10M   80k   10M  0.8 [................................] /emul/chroot-lenny-i386/dev
/home            8038M  829M 7127M 10.3 [###.............................] /emul/chroot-lenny-i386/home
/root              49G 8954M   39G 17.8 [######..........................] /emul/chroot-lenny-i386/root
/tmp               49G 8954M   39G 17.8 [######..........................] /emul/chroot-lenny-i386/tmp
/usr/share/fonts   49G 8954M   39G 17.8 [######..........................] /emul/chroot-lenny-i386/usr/share/fonts
/dev/sda10       8038M  829M 7127M 10.3 [###.............................] /home
tmpfs            1007M 8192B 1007M  0.0 [................................] /lib/init/rw

dmesg |less |grep (whatever the device is called).

All this assunes you are using the CLI or in an xterm in Gnome or
KDE.

Wayne

--
Real computer scientists despise the idea of actual hardware.  Hardware
has limitations, software doesn't.  It's a real shame that Turing
machines are so poor at I/O.
_______________________________________________________

2008\03\08@155850 by Christopher Head

picon face
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Another poster has already mentioned using udev rules to get a
consistent name for your device so you can then use fstab. Another item
to consider might be the -r option to hdparm, which tells the kernel the
entire block device is readonly. Perhaps having udev invoke hdparm on
your device before automounter takes over would make things a little safer?

Chris

hgraf wrote:
| Another interesting question...
|
| I've created some hardware to emulate an IDE hard drive. I've connected
| this emulated drive to a computer using a USB2.0-PATA bridge.
|
| It works well, however, due to the way things need to work it would make
| my life easier if I could prevent the OS from writing to my "drive".
|
| Is there a way under linux (Ubuntu 7.10) to cause a USB hard drive to be
| mounted read-only (it's currently being auto mounted, I don't want my
| changes to have any effect on other USB drives being mounted)? Is there
| something in the identify drive data that a hard drive returns that I
| can set to cause the hard drive to be read only (I can change anything
| there I want)?
|
| Again, I've googled, but haven't really come up with anything.
|
| Thanks for any pointers.
|
| TTYL

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: GnuPT 2.7.2
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFH0v3jiD2svb/jCb4RAu/yAJ4kkdv2PZ+vfke3T8IYqHHrNaRsogCgqERo
mRPa539Zd/HQ2A1IuqUL5Jg=
=OFD+
-----END PGP SIGNATURE-----

2008\03\08@160048 by Christopher Head

picon face
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Another poster has already mentioned using udev rules to get a
consistent name for your device so you can then use fstab. Another item
to consider might be the -r option to hdparm, which tells the kernel the
entire block device is readonly. Perhaps having udev invoke hdparm on
your device before automounter takes over would make things a little safer?

Chris

hgraf wrote:
| Another interesting question...
|
| I've created some hardware to emulate an IDE hard drive. I've connected
| this emulated drive to a computer using a USB2.0-PATA bridge.
|
| It works well, however, due to the way things need to work it would make
| my life easier if I could prevent the OS from writing to my "drive".
|
| Is there a way under linux (Ubuntu 7.10) to cause a USB hard drive to be
| mounted read-only (it's currently being auto mounted, I don't want my
| changes to have any effect on other USB drives being mounted)? Is there
| something in the identify drive data that a hard drive returns that I
| can set to cause the hard drive to be read only (I can change anything
| there I want)?
|
| Again, I've googled, but haven't really come up with anything.
|
| Thanks for any pointers.
|
| TTYL

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (MingW32)
Comment: GnuPT 2.7.2
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFH0v3jiD2svb/jCb4RAu/yAJ4kkdv2PZ+vfke3T8IYqHHrNaRsogCgqERo
mRPa539Zd/HQ2A1IuqUL5Jg=
=OFD+
-----END PGP SIGNATURE-----

2008\03\10@113813 by Alex Harford

face picon face
On Fri, Mar 7, 2008 at 6:31 PM, Herbert Graf <spamBeGonemailinglist4spamBeGonespamfarcite.net> wrote:
>  >
>  > What your looking for is in man 8 mount.
>  >
>  > mount -r /dev/sda1
>  >
>  > -r     Mount the file system read-only. A synonym is -o ro.
>
>  Any pointers on how I would go about doing this for something that is
>  automounted by default (I'm using Ubuntu), without affecting all devices
>  that are automounted?
>

If you don't mind a manual step, you can use mount with the 'remount'
option to change it to read only.  Otherwise you'll need to make a
udev rule like Xiaofan mentioned.  The controls are very fine grained
if you need them to be, ie you can use serial numbers for
identification of hard drives.

Alex

2008\03\10@115709 by David VanHorn

picon face
On Fri, Mar 7, 2008 at 8:29 PM, Herbert Graf <TakeThisOuTmailinglist4EraseMEspamspam_OUTfarcite.net> wrote:
>
> On Fri, 2008-03-07 at 17:33 -0500, David VanHorn wrote:
> > Don't a lot of them have write protect locks?
>
> Unfortunately I'm not dealing with a real drive, but I would be
> interested in what such a switch exactly does? How does the OS get told
> the drive is read only?

I don't know that it does tell the OS, I think it disconnects the
write ability in hardware.

2008\03\10@164545 by Chris Emerson

flavicon
face
On Fri, Mar 07, 2008 at 01:21:55PM -0500, hgraf wrote:
> I've created some hardware to emulate an IDE hard drive. I've connected
> this emulated drive to a computer using a USB2.0-PATA bridge.
>
> It works well, however, due to the way things need to work it would make
> my life easier if I could prevent the OS from writing to my "drive".

Can you make it look like a CD drive instead?

Regards,

Chris

2008\03\10@173001 by Herbert Graf

flavicon
face

On Mon, 2008-03-10 at 20:45 +0000, Chris Emerson wrote:
> On Fri, Mar 07, 2008 at 01:21:55PM -0500, hgraf wrote:
> > I've created some hardware to emulate an IDE hard drive. I've connected
> > this emulated drive to a computer using a USB2.0-PATA bridge.
> >
> > It works well, however, due to the way things need to work it would make
> > my life easier if I could prevent the OS from writing to my "drive".
>
> Can you make it look like a CD drive instead?

CD Drives don't use the basic ATA commands to transfer data, they have a
much more advanced protocol to the PC called ATAPI. I'd prefer staying
away from trying to emulation that whole stack... :)

TTYL

More... (looser matching)
- Last day of these posts
- In 2008 , 2009 only
- Today
- New search...