-
-
Save bhardin/21ba3daaea7187c8e603d1fa30768f5a to your computer and use it in GitHub Desktop.
How to mount another EBS as /var on EC2 (ubuntu)
This file contains 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 characters
#!/bin/bash | |
#attach the EBS to /dev/sdf before running it | |
# If not mounted... format EBS | |
mkfs -t ext4 /dev/xvdb | |
mkdir /mnt/new | |
mount /dev/xvdb /mnt | |
#copy original /var to /dev/xvdb | |
sudo cp -ax /var/* /mnt | |
cd / | |
sudo mv var var.old # just in case | |
#mount EBS as new /var | |
umount /dev/xvdb | |
sudo mkdir /var | |
sudo mount /dev/xvdb /var | |
sudo rm -rf /var.old/ | |
#update fstab file to mount EBS on system startup | |
echo "/dev/xvdb /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