1

I am using CentOS Linux 7 (Core). I have an issue with df command: it do not show all disks without root.

Compare:

$ df -h
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/centos-root   19G  2.2G   17G  12% /
devtmpfs                 3.9G     0  3.9G   0% /dev
tmpfs                    3.9G   28K  3.9G   1% /dev/shm
tmpfs                    3.9G  201M  3.7G   6% /run
tmpfs                    3.9G     0  3.9G   0% /sys/fs/cgroup
/dev/sda1                497M  282M  215M  57% /boot
tmpfs                    783M     0  783M   0% /run/user/1001

, and

$ sudo df -h
Filesystem                     Size  Used Avail Use% Mounted on
/dev/mapper/centos-root         19G  2.2G   17G  12% /
devtmpfs                       3.9G     0  3.9G   0% /dev
tmpfs                          3.9G   28K  3.9G   1% /dev/shm
tmpfs                          3.9G  201M  3.7G   6% /run
tmpfs                          3.9G     0  3.9G   0% /sys/fs/cgroup
/dev/sda1                      497M  282M  215M  57% /boot
tmpfs                          783M     0  783M   0% /run/user/1001
/dev/mapper/postgres-postgres  148G   14G  129G  10% /var/lib/pgsql/10

There is one additional line in last example. How to fix this issue? I need see all disks without root permissions.

dev.brutus
  • 211
  • 3
  • 7
  • This might not be generally encouraged, but you can set the SUID as root, so any user not root that runs df, will run it as root. – cusco Apr 11 '19 at 11:48
  • 1
    What is the output of `sudo grep -v shared /proc/self/mountinfo`. I'm looking for use of mount namespaces and private mounts. – Mark Wagner Apr 11 '19 at 16:58
  • @MarkWagner it show nothing: $ sudo grep -v shared /proc/self/mountinfo – dev.brutus Apr 12 '19 at 15:47

1 Answers1

1

Every directory from the parent to the root needs to have the execute bit set (for user, group, or other, depending on your u and g and the u and g of the direcotries). Fix for your case:

chmod o+x /var/lib/pgsql

Notes:

  • read bit is not needed
  • mount point does not need the execute bit
  • adding your user to the group that owns /var/lib/pgsql may be more secure
  • there may be other acl mechanisms applied such as extended attributes and selinux contets
Mark Wagner
  • 18,019
  • 2
  • 32
  • 47
  • Looks like the solution. I have added the executable bit and the disk is visible now. It is visible for my Zabbix also. – dev.brutus Apr 15 '19 at 12:07