1836433 Members
2648 Online
110100 Solutions
New Discussion

block and char. dev

 
SOLVED
Go to solution
YLTan
Frequent Advisor

block and char. dev


Why does HP servers need to have a block device file /dev/dsk and character device file /dev/rdsk for hardisk and CDROM?

Can I use only one? It is rather confusing as to which one actually controls the hardisk or CDROM.
tyl
2 REPLIES 2
Ajit Natarajan
Valued Contributor
Solution

Re: block and char. dev

Block and device files are common in all flavors of UNIX. They are not specific to HP-UX.

A device driver that controls a storage device, e.g., a disk, will export a block interface and a character interface to the same device. The block interface is accessible through the block device file (/dev/dsk/*) and the character interface is accessible through the character device file (/dev/rdsk/*).

The block device, as the name implies, allows the storage unit to be viewed as a collection of blocks. This view is required if you want to place a filesystem on the device and mount the filesystem. Only a block device can contain a filesystem that can be mounted [see mount(1M)].

A character device gives access to the raw device, i.e., the unit is viewed as a collection of bytes. This is used, for example, by mediainit(1) to format the disk and by fsck(1M) to check the disk. A utility that creates a filesystem [e.g., newfs(1M)] would need access to the character device.

Once the filesystem is created, the block device is used to mount the filesystem.

Hope this brief explanation helps.

Thanks.

Ajit
HP Gigabit Ethernet
Bill Hassell
Honored Contributor

Re: block and char. dev

The above explanation is correct. For disks (including CDROMs), it is common to have filesystems stored on them and to improve performance, a separate driver is needed to utilize the buffer cache in HP-UX. The block device file runs through the buffer cache while the character device file does not.

Generally, you never use the character device file except for initialization (newfs or mkfs), or for specialized applications that need a 'raw' device (Sybase for instance). Even LVM has a character and block device file for each logical volume but other than useage in /etc/fstab, these device files are seldom used.


Bill Hassell, sysadmin