question about raw disk devices

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

question about raw disk devices

Luca Ferrari
Hi all,
this may sound trivial, in the case please insult me, but I've a
little doubt about disk devices.
In the OpenBSD way there are two devices: a block one and a character
one (and I believe this is the rightmost way). You do low level
operations on the raw device and mount the  block device.
On other Unix operating system there is a single character device on
which you do low level operations and that you can mount.
On pretending-to-be-unix operating system you have a single block
device on which you can do both low level and mounting operations.
Now, the raw device in OpenBSD is just an alias of the block device
(or vice versa) and there is no caching of data outside the vnode
layer, or is there a more complex eplaination?

Thanks,
Luca

Reply | Threaded
Open this post in threaded view
|

Re: question about raw disk devices

bodie
On 20.11.2014 18:07, Luca Ferrari wrote:

> Hi all,
> this may sound trivial, in the case please insult me, but I've a
> little doubt about disk devices.
> In the OpenBSD way there are two devices: a block one and a character
> one (and I believe this is the rightmost way). You do low level
> operations on the raw device and mount the  block device.
> On other Unix operating system there is a single character device on
> which you do low level operations and that you can mount.
> On pretending-to-be-unix operating system you have a single block
> device on which you can do both low level and mounting operations.
> Now, the raw device in OpenBSD is just an alias of the block device
> (or vice versa) and there is no caching of data outside the vnode
> layer, or is there a more complex eplaination?
>
> Thanks,
> Luca


You mean behind this one? http://www.openbsd.org/faq/faq14.html

Then from http://www.openbsd.org/faq/faq9.html

The names of hard disks are usually /dev/wd (IDE) and /dev/sd (SCSI or
devices emulating SCSI disks)

OpenBSD/i386, amd64, and several other platforms use a "two layer" disk
partitioning system, where the first layer is the fdisk, BIOS-visible
partition, familiar to most users of IBM compatible computers. The
second layer is the disklabel, a traditional BSD partitioning system.
OpenBSD supports up to 15 disklabel partitions on a disk, all residing
within one fdisk partition. This permits OpenBSD to coexist with other
OSs, including other Unix-like OSs. OpenBSD must be one of the four
"primary" partitions.

man disklabel
man fdisk in which you can find eg.

  disk
     Specify the disk to operate on. It can be specified either by its
full pathname or an abbreviated disk form. In its abbreviated form, the
path to the device, the ‘r’ denoting “raw device”, and the
partition letter, can all be omitted. For example, the first IDE disk
can be specified as either /dev/rwd0c, /dev/wd0c, or wd0.

Generally FAQ is recommended reading for start, but in simplified form
any disk device in /dev starting with r is raw (character), without r
it's block device plus you have BSD partitions where c means whole your
disk, a is /, b is swap and rest is completely on you.

Reply | Threaded
Open this post in threaded view
|

Re: question about raw disk devices

Ted Unangst-6
In reply to this post by Luca Ferrari
On Thu, Nov 20, 2014 at 18:07, Luca Ferrari wrote:

> Hi all,
> this may sound trivial, in the case please insult me, but I've a
> little doubt about disk devices.
> In the OpenBSD way there are two devices: a block one and a character
> one (and I believe this is the rightmost way). You do low level
> operations on the raw device and mount the  block device.
> On other Unix operating system there is a single character device on
> which you do low level operations and that you can mount.
> On pretending-to-be-unix operating system you have a single block
> device on which you can do both low level and mounting operations.
> Now, the raw device in OpenBSD is just an alias of the block device
> (or vice versa) and there is no caching of data outside the vnode
> layer, or is there a more complex eplaination?

The block devices are mostly historic artifact. You usually want the
character device; the block device is almost exclusively for mount.
It's probably a mistake to try to use both at the same time.

Reply | Threaded
Open this post in threaded view
|

Re: question about raw disk devices

Luca Ferrari
On Thu, Nov 20, 2014 at 6:36 PM, Ted Unangst <[hidden email]> wrote:
> The block devices are mostly historic artifact. You usually want the
> character device; the block device is almost exclusively for mount.
> It's probably a mistake to try to use both at the same time.
>

Thanks, therefore I can assume that raw and block device are the same
thing, with no special menaning except for a syntactical one.
I was not talking about using both at the same time, it does not make
to me any sense to, for instance, do an fdisk and mount a disk at the
same time, rather I was talking about having the two of them instead
of a single one under /dev.

Thanks,
Luca

Reply | Threaded
Open this post in threaded view
|

Re: question about raw disk devices

Theo de Raadt
In reply to this post by Luca Ferrari
>On Thu, Nov 20, 2014 at 6:36 PM, Ted Unangst <[hidden email]> wrote:
>> The block devices are mostly historic artifact. You usually want the
>> character device; the block device is almost exclusively for mount.
>> It's probably a mistake to try to use both at the same time.
>>
>
>Thanks, therefore I can assume that raw and block device are the same
>thing, with no special menaning except for a syntactical one.

No, it is not a syntax issue.  One is buffered, the other is not.
The swizzling to do selection automatically at open() vs mount()
time has not occured.