<p dir="ltr">Hardware and software are two separate things. The disk is "mounted" entirely it's just that the disks says it has two, one or more partitions. The disk's description is read when plugged. When you mount you're using the software part not the hardware nature of the disk.</p>
<br><div class="gmail_quote"><div dir="ltr">On Sun, Sep 6, 2015, 6:20 PM Colin Watson <<a href="mailto:cjwatson@ubuntu.com">cjwatson@ubuntu.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Sun, Sep 06, 2015 at 05:59:13PM +1000, Karl Auer wrote:<br>
> While looking at another poster's issue I started wondering whether it<br>
> is possible to attach an entire hard disk drive in read-only mode.<br>
> Mounting a partition read-only is easy, but I'm not talking about<br>
> partitions here - I mean the entire drive.<br>
><br>
> That is, can I have a read-only /dev/sdb?<br>
<br>
(Disclaimer: some of the following is from reading kernel code and I<br>
haven't actually tried it on a whole disk device.)<br>
<br>
"blockdev --setro" is a useful tool that makes a block device read-only.<br>
In and of itself I do not believe that applying it to a disk device,<br>
e.g. "blockdev --setro /dev/sdb", automatically applies it to all the<br>
partitions on that disk.  However, when a new partition is added, it<br>
inherits the read-only policy from its disk; so I believe that if you<br>
mark the disk and all its partitions read-only using "blockdev --setro"<br>
after it appears (and figure out a non-racy way to do this), then that<br>
should be sufficient.<br>
<br>
Does that help?  It should at least give you something to experiment<br>
with.<br>
<br>
Some people mentioned journalling filesystems: if the block device is<br>
read-only, those will simply refuse to "mount -oro" if they still need<br>
to make changes such as replaying a journal.  For such cases, grub-mount<br>
can be useful since it can read most filesystems but entirely lacks<br>
write support, so it can safely be used to inspect things in a<br>
guaranteed read-only mode.<br>
<br>
--<br>
Colin Watson                                       [<a href="mailto:cjwatson@ubuntu.com" target="_blank">cjwatson@ubuntu.com</a>]<br>
<br>
--<br>
ubuntu-users mailing list<br>
<a href="mailto:ubuntu-users@lists.ubuntu.com" target="_blank">ubuntu-users@lists.ubuntu.com</a><br>
Modify settings or unsubscribe at: <a href="https://lists.ubuntu.com/mailman/listinfo/ubuntu-users" rel="noreferrer" target="_blank">https://lists.ubuntu.com/mailman/listinfo/ubuntu-users</a><br>
</blockquote></div>