Use of group device file in vg

Regular Advisor

Use of group device file in vg

Hi ,


Can someone tell what is the use of group device file in each volume group

We usually create the group deice file for the vg cersion 1 with the command mknod


crw-r-----   1 root       sys         64 0x000000 Jul  3  2009 /dev/vg00/group


I would like to know what is the use of this character group file

Hiren N Dave
Valued Contributor

Re: Use of group device file in vg

The group file is used to allow communications between the lvm commands and the lvm kernel.

I am an HP Employee

Was this post useful? - You may click the KUDOS! star to say thank you.
Regular Advisor

Re: Use of group device file in vg

Could you please explain ?

Honored Contributor

Re: Use of group device file in vg

One of the original design principles of UNIX was "everything is a file". However, it turned out there were some operations that were inconvenient to implement as regular file read/write operations, particularly with devices: sometimes you want to read/write to the actual hardware device, in other situations you want to communicate with the device driver instead of the actual device.


A strict implementation of the "everything is a file" principle would have required allocating a separate device node for the communication with the driver. Then, the applications would have had to know which control device node is related to each data device... and it turned out the inconvenience of that was greater than the benefit of the strict "everything is a file" principle. So a different solution was designed.


For communication with the device driver, a standard form of control function was developed: the ioctl() system call. It allows a program to pass arbitrary data structures to the device driver that is responsible for a particular device node. When using the ioctl() system call, you must specify a file descriptor (usually a device file), the number of the ioctl operation you wish to perform, and the parameters necessary to the particular ioctl operation you want. Each device driver can have a different set of ioctl operations, but the overall interface to access them is standardized.


An ioctl operation can be a query for information: in that case, the program will provide a pointer to a memory buffer, and the driver will write its answer to the buffer in the form of a operation-specific data structure. Alternatively, an ioctl operation can be used to set some parameters: in that case, the program must typically prepare an operation-specific data structure and submit its address as a parameter to the ioctl() system call.


Some device files, like the group device file in LVM, exist only to provide the applications a target for ioctl() operations: such devices typically won't return anything useful if you attempt to read them as normal files, and return an error if you try to write to them. An ioctl operation is programmed much like a file read/write operation: you open the device file as normal, but instead of actually reading or writing, you use the ioctl() system call to communicate with the device driver.


I could not quickly find any documentation on LVM ioctl operations, but using tusc I was able to confirm that commands like vgdisplay certainly use ioctl operations:


# tusc vgdisplay vg00

[... a lot of text ...]

stat("/dev/vg00/group", 0x7f7f1e48) ...................... = 0
open("/dev/vg00/group", O_RDWR, 0100) .................... = 4
ioctl(4, 0xc0207612, 0x7f7f14e0) ......................... = 0
ioctl(4, 0xc0207610, 0x40176068) ......................... = 0
ioctl(4, 0xc0207610, 0x40176088) ......................... = 0

[... still more text...]