Sometimes when you deploying a VMSS, you need to make sure all the setting is set in your custom image, basically, VMSS will need to mount a shared network drive for multiple instance purpose.
You can view this blog to see how to get use of Linux Start-up script to enable auto-mounting Azure Storage network drive.
Steps | Procedures |
1 | Mounting the network drive for first time ONLY: Linux Mount Point Name: shopify sudo mkdir /mnt/shopify if [ ! -d “/etc/smbcredentials” ]; then sudo mkdir /etc/smbcredentials fi if [ ! -f “/etc/smbcredentials/shopifstorage.cred” ]; then sudo bash -c ‘echo “username=shopifstorage” >> /etc/smbcredentials/shopifstorage.cred’ sudo bash -c ‘echo “password=O/IzHVrZFcu5R1lANy/A8PUNfVMBxxcgdgsdrgru0eCAEBnpuBvW9inp1gCoUtehAevqZOON5zU7IDw6xXPVS65m6g==” >> /etc/smbcredentials/shopifstorage.cred’ fi sudo chmod 600 /etc/smbcredentials/shopifstorage.cred sudo bash -c ‘echo “//shopifstorage.file.core.windows.net/shopify /mnt/shopify cifs nofail,vers=3.0,credentials=/etc/smbcredentials/shopifstorage.cred,dir_mode=0777,file_mode=0777,serverino” >> /etc/fstab’ sudo mount -t cifs //shopifstorage.file.core.windows.net/shopify /mnt/shopify -o vers=3.0,credentials=/etc/smbcredentials/shopifstorage.cred,dir_mode=0777,file_mode=0777,serverino |
2 | Un-Mounting the network drive: Linux Mount Point Name: shopify umount /mnt/shopify |
3 | Verify the mount point whether is unmount by using the following command: df -h |
Steps | Procedures |
1 | Create the custom start-up script named “start-up.sh” in path “/etc/init.d/start-up.sh” Sample Command: sudo nano /etc/init.d/start-up.sh |
2 | Linux Mount Point Name: shopify Edit the start-up service script content with the following: #!/bin/bash sudo bash -c ‘echo “//shopifstorage.file.core.windows.net/shopify /mnt/shopify cifs nofail,vers=3.0,credentials=/etc/smbcredentials/shopifstorage.cred,dir_mode=0777,file_mode=0777,serverino” >> /etc/fstab’ sudo mount -t cifs //shopifstorage.file.core.windows.net/shopify /mnt/shopify -o vers=3.0,credentials=/etc/smbcredentials/shopifstorage.cred,dir_mode=0777,file_mode=0777,serverino |
3 | Save and exit the script |
4 | Modify the permission for the start-up script sudo chmod +x /etc/init.d/start-up.sh |
Steps | Procedures |
1 | Edit the start-up service of the start-up script sudo nano /etc/systemd/system/my-startup.service |
2 | Edit the start-up service script content with the following: [Unit] Description=Mount Network Drive [Service] ExecStart=/etc/init.d/start-up.sh [Install] WantedBy=multi-user.target |
3 | Check the current status for the start-up service of the start-up script systemctl status my-startup.service |
4 | Enable the start-up service of the start-up script sudo systemctl enable my-startup.service |
Eric Chan
Microsoft MVP
SOS Group Limited