LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-29-2016, 01:00 AM   #1
Joy Stick
Member
 
Registered: Dec 2015
Distribution: RHEL 4.7
Posts: 127

Rep: Reputation: 0
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 ?

Last edited by Joy Stick; 01-29-2016 at 01:57 AM.
 
Old 01-29-2016, 10:13 AM   #2
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,820
Blog Entries: 15

Rep: Reputation: 1664Reputation: 1664Reputation: 1664Reputation: 1664Reputation: 1664Reputation: 1664Reputation: 1664Reputation: 1664Reputation: 1664Reputation: 1664Reputation: 1664
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.
 
1 members found this post helpful.
Old 01-29-2016, 10:56 AM   #3
Joy Stick
Member
 
Registered: Dec 2015
Distribution: RHEL 4.7
Posts: 127

Original Poster
Rep: Reputation: 0
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
brw
-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.
 
Old 01-29-2016, 04:55 PM   #4
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,820
Blog Entries: 15

Rep: Reputation: 1664Reputation: 1664Reputation: 1664Reputation: 1664Reputation: 1664Reputation: 1664Reputation: 1664Reputation: 1664Reputation: 1664Reputation: 1664Reputation: 1664
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.
 
1 members found this post helpful.
Old 01-30-2016, 07:47 AM   #5
Joy Stick
Member
 
Registered: Dec 2015
Distribution: RHEL 4.7
Posts: 127

Original Poster
Rep: Reputation: 0
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
brw
-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 ?

Last edited by Joy Stick; 01-30-2016 at 07:48 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
What are the differences between character devices and block devices? david_8274 Linux - Newbie 4 01-13-2015 07:48 PM
How do I map ATA devices to /dev/sd* block devices when using a port multiplier? Mahonri Linux - Hardware 0 02-20-2014 12:44 AM
Difference between using Raw block device with O_DIRECT and Raw Character Device srithi Linux - Newbie 1 08-19-2009 11:52 AM
what is the different btw raw devices and block devices yenonn Linux - General 2 02-10-2006 10:34 PM
Raw devices gauol Linux - General 2 09-23-2004 03:01 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:02 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration