Skip to content

Instantly share code, notes, and snippets.

@ndamulelonemakh
Last active May 31, 2022 06:58
Show Gist options
  • Select an option

  • Save ndamulelonemakh/553f7ac745dddf20235300efa6a606ef to your computer and use it in GitHub Desktop.

Select an option

Save ndamulelonemakh/553f7ac745dddf20235300efa6a606ef to your computer and use it in GitHub Desktop.
Misc config scripts for Azure
# Reference: https://docs.microsoft.com/en-us/azure/virtual-machines/linux/expand-disks
# Accoring to the documentation, this is only supported for data disks only
# At the time of this writing, this feature is still experimental
# i. Opt-in as follows:
az feature register --namespace Microsoft.Compute --name LiveResize
RG=myResourceGroup
VM=myVmName
# ii. Find the name of the disk to be resized
az disk list \
--resource-group myResourceGroup \
--query '[*].{Name:name,Gb:diskSizeGb,Tier:accountType}' \
--output table
# iii. Update disk to the desired size
az disk update \
--resource-group $RG \
--name myDataDiskName \
--size-gb 200 \
--sku Standard_HDD # Other options:Premium_LRS, StandardSSD_LRS etc.
#!/bin/bash
AZ_CONTAINER="https://<replace-account-name>.blob.core.windows.net/<container-name>/<optional-subpath>"
LOCAL_SRC_DIR="$HOME/projects/myproject1/data" # Chage as necessary
# Scenario: Sync data from a storage container to a VM running on azure
# Note: You cannot sync to a container that does not exist, for that use cp instead
azcopy login --identity
azcopy sync $AZ_CONTAINER $LOCAL_SRC_DIR --recursive --log-level DEBUG
# Scenario: Copy new files from local storage to azure
# You must append a sas token to the container URL if the host is not running on Azure
# Alternatively, you can authenticate with Azure AD
azcopy login --tenant-id <your-org-tenat-id>
# For more auth options, visit: https://docs.microsoft.com/en-us/azure/storage/common/storage-use-azcopy-authorize-azure-active-directory
azcopy copy $LOCAL_SRC_DIR $AZ_CONTAINER --recursive
# Troubleshooting
# a. Azure AD authentication error
# Run this before logging in: keyctl session workaroundSession
# Find the name of the new block(aka disk) e.g. dev/sdc
lsblk -o NAME,HCTL,SIZE,MOUNTPOINT | grep -i "sd"
# Create a new MBR or GPT partition (If disk size is over 2TB use GPT)
sudo parted /dev/sdc --script mklabel gpt mkpart xfspart xfs 0% 100%
# Format disk to create a new XFS
sudo mkfs.xfs /dev/sdc1
# Register new partition in the kernel
sudo partprobe /dev/sdc1
# Mount the new drive
sudo mount /dev/sdc1 /data
#------------------------------
# Optional: Automatically mount on boot
# i. Find the UID of /dev/sdc1
# sudo blkid
# ii. Add the following entry in /etc/fstab
# UUID=33333333-3b3b-3c3c-3d3d-3e3e3e3e3e3e /data xfs defaults,nofail 1 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment