LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Character device Vs Block device (https://www.linuxquestions.org/questions/linux-newbie-8/character-device-vs-block-device-4175563059/)

Joy Stick 01-04-2016 10:40 AM

Character device Vs Block device
 
Dear all,

PHP Code:

HOST   Windows 7 ultimate
GUEST  
RHEL
WORK STATION 
VMWARE VERSION 11 

I added 20gb space to linux machine from d:\ -->(host)

Raw partitions are unformatted disk partitions; -because( ntfs cannot recongnized by ext3)

I read Raw devices are character devices.
Terminals operate in character mode.

PHP Code:

# fdisk -l | grep ^Disk

Disk /dev/sdb doesn't contain a valid partition table
Disk /dev/sda: 86.9 GB, 86973087744 bytes
Disk /dev/sdb: 21.4 GB, 21474836480 bytes 

The first entry in the permission field indicates either b--> block, or c--> character

PHP Code:

# ls -l /dev/sda /dev/sdb
brw-rw----  1 root disk 8,  0 Jan  2 19:05 /dev/sda
brw
-rw----  1 root disk 816 Jan  2 19:05 /dev/sdb 

/dev/sdb - This is a raw partition

Then why Linux shows /dev/sdb as 'BLOCK DEVICE'
It must start with c (character device)

Thanks in advance.

Simple explantion wolud be better to get better idea.
From my previous post i got very big explantions.
For me it was NOT easy to understand.

Soadyheid 01-04-2016 11:02 AM

A Character device is a terminal, VDU, keyboard, serial connection as data is transferred one character at a time. There are various handshake signals to inform the sender that the character has been received, etc. The processor generally handles all the transfer handshaking.

A Block device; hard disk (includes pendrives), tape drive, CD/DVDs reads and writes data as "blocks" of data rather than one character at a time, they also tend to do this without use of the processor which is only used to initiate the transfer by DMA (Direct Memory Access) The protocol for block transfer needs to know where the data starts and it's length which means there is a much lower processor overhead.

My :twocents:

Play Bonny!

:hattip:

rknichols 01-04-2016 11:02 AM

Quote:

Originally Posted by Joy Stick (Post 5472922)
I read Raw devices are character devices.

That is simply wrong. Disks are block devices. They are addressed and accessed in blocks.

What problem are you actually having.

Joy Stick 01-04-2016 12:43 PM

Originally Posted by Joy Stick

I read Raw devices are character devices.
Quote:

- That is simply wrong. Disks are block devices. They are addressed and accessed in blocks.

Raw devices are character devices (i found via Google)

REF_LINKS:

Unformatted disk partitions are called 'RAW DEVICES'
All unpartitioned devices are Raw devices.

Quote:

/dev/sdb - This is a raw partition
Then why Linux shows /dev/sdb as 'BLOCK DEVICE'

PHP Code:

# ls -l /dev/sda /dev/sdb 
brw-rw----  1 root disk 8,  0 Jan  2 19:05 /dev/sda 
brw
-rw----  1 root disk 816 Jan  2 19:05 /dev/sdb 

Thanks

suicidaleggroll 01-04-2016 12:55 PM

Quote:

Originally Posted by Joy Stick (Post 5472922)
Raw partitions are unformatted disk partitions; -because( ntfs cannot recongnized by ext3)

No, that has nothing to do with it. It's unformatted because VMWare doesn't format the "disk" for you, that's up to the VM. The filesystem used on the host is irrelevant, the guest never sees the host's filesystem, that's the point of virtualization.

A disk that contains an unsupported filesystem will look VERY different from one that is not partitioned/formatted at all. You're looking at the output for an unformatted disk, not an unsupported filesystem.

You have an unpartitioned, unformatted disk (block device), not a "raw device". Some people might call it "raw" because it's untouched, similar to "raw" meat that hasn't been cooked, but it's not the same thing as the "raw device" being referenced in those links.

michaelk 01-04-2016 01:11 PM

A raw device i.e. /dev/raw* is not the same thing as /dev/sdx or an unpartitioned or unallocated space on a hard drive. As you have discovered it is typically used to perform raw I/O on a block device and bypass caching like Oracle

https://en.wikipedia.org/wiki/Raw_device

exvor 01-04-2016 03:50 PM

regardless of a drive being formatted or unformatted has nothing to do with its device type.

The link that michaelk posted shows a very good example of what a raw device is. Its basiclly a device that is exposed to the user without much OS implementation.

A extremely simple explanation is below, as you asked for.

These first two are setup and managed by the Operating System.
Character device - device communicates via character exchange.
Block Device - Device communicates via blocks of data.

Raw device - Device is not managed by the OS to communicate. ( gives you raw access )


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