-   Linux - Newbie (
-   -   aw block devices and raw character devices (

Joy Stick 01-29-2016 12:00 AM

aw block devices and raw character devices
Hi all;

What is difference between raw block devices raw character devices ?

How they are different from each other ?

MensaWater 01-29-2016 09:13 AM

A raw device is a/k/a a character device.

The essential difference is that on a raw (character) device all writes are per character (i.e. each byte is written as they are sent) whereas a block device writes per block. Blocks are collections of bytes (e.g. 512 k or 1024 k).

Block writes are generally faster but might take up more space (e.g. if you were only sending 210 k of data but your block size was 1024 k it would use up 1024 k of space). Databases sometimes prefer raw writes to make data contiguous and will have their own mechanisms for managing reads and writes that might actually do block sizes defined in the database itself rather than at the device level.

There are many things that go into the design of how things are written but the above is the basic difference.

Joy Stick 01-29-2016 09:56 AM

Thanks Mensa Water

PHP Code:

# ls -l /dev/raw/raw1 /dev/sdb1
crw-rw----  1 root disk 162,  1 Jan  9 19:18 /dev/raw/raw1
-rw----  1 root disk   817 Jan  9 19:16 /dev/sdb1 

PHP Code:

# vi /etc/sysconfig/rawdevices /dev/raw/raw1 /dev/sdb1 

Generally IO is good for RAW devices.

By default /dev/sdb1 is block device.
A raw device can be assigned or bound to block devices
IF raw devices are bounded with Block device

1) Does /dev/sdb1 act as raw device or block device ?
2) Any major difference between Block device I/O Vs Raw device IO ?

I am extremely sorry to disturb you.

MensaWater 01-29-2016 03:55 PM

The "c" you see at start of the permissions of the raw device means it is a "character" device (confirming it does in fact do raw I/O).
The "b" you see at start of permissions of sdb show it is a "block" device.

Which is "better" depends on the use. For filesystems you have to layout on block devices. For some database uses such as early Oracle RAC/GRID you had to use raw devices as configured in ASM.

Originally raw devices were configured with raw command (type "man 8 raw" for details) but over time more and more things have gone to udev rules. If you look in /etc/udev/rules.d you may see a template file for raw devices. For Oracle ASM they suggest using a completely different rules file that you create but its contents are heavily dependent on the underlying storage.

Joy Stick 01-30-2016 06:47 AM

I think, you are not getting my question.

1) I am adding SCSI disk to the LINUX server.
2) Done Partition using fdisk command.
3) configuring a raw device with block device using raw utility

>> Binding a raw device with Block device
PHP Code:

# raw /dev/raw/raw1 /dev/sdb1
/dev/raw/raw1:  bound to major 8minor 17 

PHP Code:

# ls -l /dev/raw/raw1 /dev/sdb
crw-rw----  1 root disk 162,  1 Jan 30 21:22 /dev/raw/raw1
-rw----  1 root disk   816 Jan 30 11:43 /dev/sdb 

PHP Code:

--> character device and  --> block device
--> /dev/raw/raw1 --> raw devices performs unbuffered IO
--> /dev/sdb1     --> block devices which uses kernel buffers 

In my case, raw device is bound with block device using raw utility.
If i configure ASM (Standalone) database using RAW device without any additional S/w like (asmLib or etc ..)

Now raw device is bound with block device

1) Does /dev/sdb1 behave as raw device or block device ?
2) Does /dev/raw/raw1 behave as raw device or block device ?

All times are GMT -5. The time now is 09:07 AM.