Skip to content

Instantly share code, notes, and snippets.

@stingh711
Created July 24, 2012 08:02
Show Gist options
  • Star 16 You must be signed in to star a gist
  • Fork 9 You must be signed in to fork a gist
  • Save stingh711/3168716 to your computer and use it in GitHub Desktop.
Save stingh711/3168716 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
@gigo6000
Copy link

Great script thanks!

@DarckBlezzer
Copy link

I only register for this, you save my ass men, this helps a lot, thanks for this again...

@plouro
Copy link

plouro commented Feb 26, 2018

Thank you very much for this

@ryandahlke
Copy link

Worked for me, I wish there was some more context on that string of fstab settings, but it worked.

@NAshwini
Copy link

NAshwini commented May 4, 2021

Thank you this really helped.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment