Skip to content

Instantly share code, notes, and snippets.

@fijimunkii
Forked from stingh711/mount_ebs.sh
Created March 22, 2018 19:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fijimunkii/fa076432d9125dfca5a2d60df65bb0fa to your computer and use it in GitHub Desktop.
Save fijimunkii/fa076432d9125dfca5a2d60df65bb0fa to your computer and use it in GitHub Desktop.
How to mount another EBS as /var on EC2 (ubuntu)
#!/bin/bash
#attach the EBS to /dev/sdf before running it
#format EBS
mkfs -t ext4 /dev/xvdf
#copy original /var to /dev/xvdf
mkdir /mnt/new
mount /dev/xvdf /mnt/new
cd /var
cp -ax * /mnt/new
cd /
mv var var.old
#mount EBS as new /var
umount /dev/xvdf
mkdir /var
mount /dev/xvdf /var
#update fstab file to mount EBS on system startup
echo "/dev/xvdf /var ext4 noatime 0 0" >> /etc/fstab
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment