Last active
March 6, 2022 23:08
-
-
Save ctompkinson/30f570882af38879b36fc7bffe3d1a60 to your computer and use it in GitHub Desktop.
Revisions
-
ctompkinson revised this gist
Dec 13, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -31,6 +31,6 @@ if ! $(mount | grep -q /mnt) ; then mount /dev/xvdb fi else echo "detected drive already mounted to /mnt, skipping mount..." lsblk | grep mnt fi -
ctompkinson created this gist
Jun 28, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,36 @@ set -o pipefail set -o errtrace set -o nounset set -o errexit set -a # Scratch mount is the device which will be mounted on /mnt # and generally used for logs, core dumps etc. if ! $(mount | grep -q /mnt) ; then # Detected NVME drives # They do not always have a consistent drive number, this will scan for the drives slot in the hypervisor # and mount the correct ones, with sda1 always being the base disk and sdb being the extra, larger, disk if lshw | grep nvme &>/dev/null; then for blkdev in $(nvme list | awk '/^\/dev/ { print $1 }'); do mapping=$(nvme id-ctrl --raw-binary "${blkdev}" | cut -c3073-3104 | tr -s ' ' | sed 's/ $//g') if [[ ${mapping} == "sda1" ]]; then echo "$blkdev is $mapping skipping..." elif [[ ${mapping} == "sdb" ]]; then echo "$blkdev is $mapping formatting and mounting..." mkfs -t ext4 ${blkdev} echo "${blkdev} /mnt ext4 defaults,comment=cloudconfig 0 2" >> /etc/fstab mount ${blkdev} else echo "detected unknown drive letter $blkdev: $mapping. Skipping..." fi done else echo "Configuring /dev/xvdb..." mkfs -t ext4 /dev/xvdb echo "/dev/xvdb /mnt ext4 defaults,comment=cloudconfig 0 2" >> /etc/fstab mount /dev/xvdb fi else echo "detected drive already mounted to /mnt, skipping mount˝..." lsblk | grep mnt fi