Skip to content

Instantly share code, notes, and snippets.

@madhuakula
Forked from anvol/azure-disk.sh
Created April 5, 2017 06:45
Show Gist options
  • Select an option

  • Save madhuakula/4670a5cbc75c475e23798d3b7b572fb8 to your computer and use it in GitHub Desktop.

Select an option

Save madhuakula/4670a5cbc75c475e23798d3b7b572fb8 to your computer and use it in GitHub Desktop.
#!/bin/sh -x
# Script usage example
# sudo sh azure-disk.sh /dev/sdc /datadisk
DEVICE="$1"
MOUNT_DIR="$2"
sfdisk $DEVICE << EOF
start=2048, type=83
EOF
mkfs -t ext4 "${DEVICE}1"
mkdir -p "${MOUNT_DIR}"
mount "${DEVICE}1" "${MOUNT_DIR}"
devUUID=$(blkid -o value -s UUID ${DEVICE}1)
cp /etc/fstab /etc/fstab.backup
echo "UUID=${devUUID} ${MOUNT_DIR} ext4 defaults,nofail 1 2" >> /etc/fstab
chmod go+w ${MOUNT_DIR}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment