Skip to content

Instantly share code, notes, and snippets.

@snallami
Created October 4, 2017 03:44
Show Gist options
  • Save snallami/ddd598917cf60fcc6c2856a75235e439 to your computer and use it in GitHub Desktop.
Save snallami/ddd598917cf60fcc6c2856a75235e439 to your computer and use it in GitHub Desktop.
Mount i3 ephermal disk
create_cachefs() {
echo "${FUNCNAME[0]}"
BLOCK_DEVICE='/dev/nvme0n1'
NVME_CACHE_MOUNT_POINT='/cache-fs'
SERVICE_USER_NAME='tooladmin'
# Only set this up if we have an nvme ephemeral
if [[ ! -e ${BLOCK_DEVICE} ]] ; then
echo "FAILURE: Service needs a specific amazon instance type"
return 1
fi
# g create a new empty GPT partition table
# n creates a new partition.
# p indicates that it's a primary partition being created.
# 1 indicates that it should be primary partition
# the following blank line accepts the default end sector
# w writes changes to disk.
(echo g; echo n; echo p; echo 1; echo ; echo; echo w) | fdisk ${BLOCK_DEVICE} || return 1
sleep 10
#create file system
mkfs.ext4 -F ${BLOCK_DEVICE} || return 1
mkdir "${NVME_CACHE_MOUNT_POINT}" || return 1
mount ${BLOCK_DEVICE} "${NVME_CACHE_MOUNT_POINT}" || return 1
# Create required folders
mkdir -p ${NVME_CACHE_MOUNT_POINT}/tmp
chmod 777 "${NVME_CACHE_MOUNT_POINT}" || return 1
chown -R "${SERVICE_USER_NAME}":"${SERVICE_USER_NAME}" "${NVME_CACHE_MOUNT_POINT}" || return 1
return 0
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment