I want to create a directory and provide user permissions in /mnt/resource folder on RHEL Azure VM during startup of the VM.
df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda2 32G 12G 20G 38% /
devtmpfs 56G 0 56G 0% /dev
tmpfs 56G 0 56G 0% /dev/shm
tmpfs 56G 8.4M 56G 1% /run
tmpfs 56G 0 56G 0% /sys/fs/cgroup
/dev/sda1 497M 103M 394M 21% /boot
/dev/sdb1 221G 2.3G 207G 2% /mnt/resource
tmpfs 12G 0 12G 0% /run/user/1000
I have tried following. But it doesn't help me.
a. chmod +x /etc/rc.d/rc.local
b. Add the following lines at end of file in /etc/rc.d/rc.local
sudo mkdir -p /mnt/resource/sample
sudo chown -R sshuser:sshuser /mnt/resource/sample
c. Restart the VM.
Result:
sample directory not created in /mnt/resource/
a. Add following in /etc/systemd/system/mount.service
[Unit] Description=Description for sample script goes here Requires=network.target After=network.target [Service] Type=simple ExecStart=/home/sshuser/mount.sh TimeoutStartSec=0 User=root [Install] WantedBy=multi-user.target
b. Add following in /home/sshuser/mount.sh
sudo mkdir -p /mnt/resource/sample
sudo chown -R sshuser:sshuser /mnt/resource/sample
c. chmod +x /home/sshuser/mount.sh
d. systemctl daemon-reload
e. systemctl enable mount.service
f. systemctl start mount.service
Stop and Started the Azure VM
Result:- sample directory not created in /mnt/resource/