Skip to content

Instantly share code, notes, and snippets.

@bsantraigi
Last active April 15, 2019 12:49
Show Gist options
  • Save bsantraigi/2b16093aba0b5c13aaba539163101112 to your computer and use it in GitHub Desktop.
Save bsantraigi/2b16093aba0b5c13aaba539163101112 to your computer and use it in GitHub Desktop.
Script for mounting an additional disk to gcp vm
sudo lsblk # Lists all and confirm if the disk is attached to the vm
# Format the disk
# Assuming new disk is detected and named as /dev/sdb
# Uncomment if you want to format
# sudo mkfs.ext4 -m 0 -F -E lazy_itable_init=0,lazy_journal_init=0,discard /dev/sdb
# Going the mount the disk on blackhole
sudo mkdir -p /blackhole
sudo mount -o discard,defaults /dev/sdb /blackhole
# Set permissions
sudo chmod a+w /blackhole
# Update fstab + backup the old one
sudo cp /etc/fstab /etc/fstab.backup
echo UUID=`sudo blkid -s UUID -o value /dev/sdb` /blackhole ext4 discard,defaults,nofail 0 2 | sudo tee -a /etc/fstab
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment