Topics: AIX, LVM, System Administration

Logical volumes with customized owner / group / mode

Some applications, for example Oracle when using raw logical volumes, may require specific access to logical volumes. Oracle will require that the raw logical volume is owned by the oracle account, and it may or may not require custom permissions.

The default values for a logical volume are: dev_uid=0 (owned by user root), dev_gid=0 (owned by group system) and dev_perm=432 (mode 660). You can check the current settings of a logical volume by using the readvgda command:

# readvgda vpath51 | egrep "lvname|dev_|Logical"
lvname:         testlv (i=2)
dev_uid:        0
dev_gid:        0
dev_perm:       432
If the logical volume was create with or has been modified to use customized owner/group/mode values, the dev_values will show the current uid/gid/perm values, for example:
# chlv -U user -G staff -P 777 testlv
# ls -als /dev/*testlv
   0 crwxrwxrwx 1 user staff 57, 3 Mar 10 14:39 /dev/rtestlv
   0 brwxrwxrwx 1 user staff 57, 3 Mar 10 14:39 /dev/testlv
# readvgda vpath51 | egrep "lvname|dev_|Logical"
lvname:         testlv (i=2)
dev_uid:        3878
dev_gid:        1
dev_perm:       511
When the volume group is exported, and re-imported, this information is lost:
# errpt
# exportvg testvg
# importvg -y testvg vpath51
testvg
# ls -als /dev/*testlv
   0 crw-rw---- 1 root system 57, 3 Mar 10 15:11 /dev/rtestlv
   0 brw-rw---- 1 root system 57, 3 Mar 10 15:11 /dev/testlv
To avoid this from happening, make sure to use the -R option, that will restore any specific settings:
# chlv -U user -G staff -P 777 testlv
# ls -als /dev/*testlv
   0 crwxrwxrwx 1 user staff 57, 3 Mar 10 15:11 /dev/rtestlv
   0 brwxrwxrwx 1 user staff 57, 3 Mar 10 15:11 /dev/testlv
# readvgda vpath51 | egrep "lvname|dev_|Logical"
lvname:         testlv (i=2)
dev_uid:        3878
dev_gid:        1
dev_perm:       511
# varyoffvg testvg
# exportvg testvg
importvg -Ry testvg vpath51
testvg
# ls -als /dev/*testlv
   0 crwxrwxrwx 1 user staff 57, 3 Mar 10 15:14 /dev/rtestlv
   0 brwxrwxrwx 1 user staff 57, 3 Mar 10 15:14 /dev/testlv
Never use the chown/chmod/chgrp commands to change the same settings on the logical volume. It will work, however, the updates will not be written to the VGDA, and as soon as the volume group is exported out and re-imported on the system, the updates will be gone:
# chlv -U root -G system -P 660 testlv
# ls -als /dev/*testlv
   0 crw-rw---- 1 root system 57, 3 Mar 10 15:14 /dev/rtestlv
   0 brw-rw---- 1 root system 57, 3 Mar 10 15:14 /dev/testlv
# chown user.staff /dev/testlv /dev/rtestlv
# chmod 777 /dev/testlv /dev/rtestlv
# ls -als /dev/*testlv
   0 crwxrwxrwx 1 user staff 57, 3 Mar 10 15:14 /dev/rtestlv
   0 brwxrwxrwx 1 user staff 57, 3 Mar 10 15:14 /dev/testlv
# readvgda vpath51 | egrep "lvname|dev_|Logical"
lvname:         testlv (i=2)
dev_uid:        0
dev_gid:        0
dev_perm:       360
Notice above how the chlv command changed the owner to root, the group to system, and the permissions to 660. Even after the chown and chmod commands are run, and the changes are visible on the device files in /dev, the changes are not seen in the VGDA. This is confirmed when the volume group is exported and imported, even with using the -R option:
# varyoffvg testvg
# exportvg testvg
# importvg -Ry testvg vpath51
testvg
# ls -als /dev/*testlv
   0 crw-rw---- 1 root system 57, 3 Mar 10 15:23 /dev/rtestlv
   0 brw-rw---- 1 root system 57, 3 Mar 10 15:23 /dev/testlv
So, when you have customized user/group/mode settings for logical volumes, and you need to export and import the volume group, always make sure to use the -R option when running importvg.

Also, make sure never to use the chmod/chown/chgrp commands on logical volume block and character devices in /dev, but use the chlv command instead, to make sure the VGDA is updated accordingly.

Note: A regular volume group does not store any customized owner/group/mode in the VGDA. It is only stored for Big or Scalable volume groups. In case you're using a regular volume group with customized owner/group/mode settings for logical volumes, you will have to use the chmod/chown/chgrp commands to update it, especially after exporting and re-importing the volume group.