Skip to main content

Adding a new EBS to EC2 and move /var to new EBS

To follow the previous blog article, what if we need to extend /var by moving it to another partition?

The following article outlines the key steps. Meanwhile, I found some of the steps are only required if you have SELINUX enabled.

The key steps are:

1) Launch a new EBS, choose SSD for speed, or HDD for higher volume.
2) Attach the EBS to the server instance.
3) Login via SSH client.
4) fdisk /dev/xvdf - Note when you provision a new EBS and attach it to EC2, it will say it will rename automatically to /dev/xvdf through /xvdp
5 )mkfs -t ext4 /dev/xvdf1 - format new partition for Linux use
6) mount /dev/xvdf1 /mnt - mount it at /mnt
7) shopt -s dotglob - copy files from /var to /mnt
rsync -aulvXpogtr /var/* /mnt
8) umount /mnt - unmount
9) Edit /etc/fstab
/dev/xvdf1   /var       ext4    defaults,noatime,nofail 0   2
10) mv /var/ /var.old - change the original to become a backup
11) mkdir /var - re-create the /var
12) mount -av
13) Reboot


Comments