Hello Developers,
While testing our addon on CentOS 7 host I’ve hit the following flaw.
mkfs.xfs
failed to format a device where mkfs.ext4
succeeded.
To grant rw rights I’ve added oneadmin
user to the system ‘disk’ group. This was enough to have mkfs.extX working untill I’ve tried to create XFS:
$ mkfs -t xfs -f -q /dev/storpool/one-sys-22-4-xfs
mkfs.xfs: error - cannot set blocksize 512 on block device /dev/storpool/one-sys-22-4-xfs: Permission denied
I’ve straced mkfs.xfs
and found that in the kernel CAP_SYS_ADMIN
is required to set BLKBSZSET
on block devices, that is required by mkfs.xfs
.
So I’ve tried with sudo
but again failed. This time because of PATH/rights mismatch.
By default on CentOS 7 the oneadmin
user is created with following path:
$ echo $PATH
/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/var/lib/one/.local/bin:/var/lib/one/bin`
But in /etc/sudoers.d/opennebula
we have allowed /sbin/mkfs
(where it is placed on most distributions):
Cmnd_Alias ONE_MISC = /bin/dd, /sbin/mkfs, /bin/sync
Obviously it can be solved by appending /sbin
to the PATH or call explicitly /sbin/mkfs
.
In our drivers I am using the function mkfs_command
found in $LIB_LOCATION/sh/scripts_common.sh
.
For the moment I’ve solved the case by replacing MKFS
variable in our scripts to:
MKFS=“sudo /sbin/mkfs”
Is there a safe way to change MKFS
variable that will not be overwritten on update?
Kind Regards,
Anton Todorov