1

Right now /mnt/resource is owned by root and only root can read/write. How can I make this readable/writable by other users on the system?

And this should be persistent (i.e. after system restart it should still work)

3 Answers 3

1

How to make /mnt/resource readable/writable but other users in Azure Linux VM?

To do this you need to use a command similar to the following:

chown other_user /mnt/resource

And this should be persistent (i.e. after system restart it should still work)

Based on this documentation, the Azure Linux Agent (/usr/sbin/waagent) does the following:

• Manages the resource disk

• Formats and mounts the resource disk

Upon provisioning an instance (starting/restarting) the device /dev/sdb1 will be mounted by waagent upon boot based on the setting ResourceDisk.MountPoint= in /etc/waagent.conf, defaulting to /mnt/resource. You can verify this by typing the command cat /var/log/waagent.log | grep sdb1 after stopping and starting an instance should show something like this:

2016/06/17 09:06:42 Resource disk (/dev/sdb1) is mounted at /mnt/resource with fstype ext4 

Because waagent creates the mount some time after the boot, setting permissions immediately upon boot will not work. (I've experienced a race condition where I created a directory in /mnt/resource only to have it deleted when the mount occurs.)

You can create a service which will wait until /dev/sdb1 is mounted to /mnt/resource/ then change permissions as needed.

One way would be to have a script similar to the following run as an init script:

#!/bin/sh

LOG=/tmp/startup.log
while [ `mount | grep /mnt/resource | wc -l` -lt 1 ];
do
    echo "Waiting for mount to be created by waagent..." >> ${LOG}
    sleep 5
done
echo "Changing /mnt/resource permissions..." >> ${LOG}
chown other_user /mnt/resource
2
  • /dev/sdb1 is the mount point for the local scratch disk. It is not relevant when mounting an attached disk. And waagent doesn't impact mounted disks. Jun 17, 2016 at 20:46
  • @DavidMakogon If the waagent doesn't mount the disk as I have described, can you please explain to me what does make the mount?
    – bamcclur
    Jul 13, 2016 at 4:40
0

Chown and Chmod are the commands to achieve this.

Probably easier just to read this https://en.wikipedia.org/wiki/Chmod

6
  • Yes, but will these persists after reboot? As that folder looks like it's mounted by github.com/Azure/WALinuxAgent
    – daniels
    Oct 30, 2015 at 14:07
  • I think as long as your mount point is persistent then it should
    – Dan
    Oct 30, 2015 at 14:19
  • Im not sure how WALinuxAgent will affect this, sorry.
    – Dan
    Oct 30, 2015 at 14:21
  • Just tested, and just with chmod after reboot permissions are reset to being readonly for rest of the users, only root can write there.
    – daniels
    Oct 30, 2015 at 15:59
  • You could normally put the permissions in your etc/fstab file with the mount config but i'm really not sure with this agent thing, sorry.
    – Dan
    Oct 30, 2015 at 16:17
0

/mnt/resource WILL NOT PERSIST no matter what you do with it Documentation

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .