Elastic Block Store (EBS)


It acts like your backup hard drive, to store copies of your files. It can be easily plugged in and off to build extra memory space for your system.

Backup your EC2 Instance

  1. EC2 instance → Select instance.
  2. Click Storage Tab at the bottom bar → Click on volume to backup /dev/sda1.
  3. Create Snapshot → Write some description → Encrytion (optional) → Click Create Snapshot button to confirm.
  4. Under EBS → Click Snapshots → View your snapshots created here.
  5. Under EBS, select Snapshot → Actions → Create Volume → Choose the correct availability zone because ec2 instance can only attach volume at the same zone → Check Encryption then default Master Key → Create Volume to confirm.
  6. Under EBS, Volume → New Volume will be created in previous step → Select Volume → Actions: Attach Volume → Choose ec2 instance to attach → Device auto/manual name → Attach.
  7. Login the ec2 instance via SSH. Check attached volumes it should appear without mountpoint.
  8. 
    lsblk
        
  9. Check file system type. Filesystem data should mount to Boot sector.
  10. 
    sudo file -s /dev/xvdf1 # filesystem data, this is the target
    sudo file -s /dev/xvdf # not this
        
  11. Mount the new attached volume to data folder.
  12. 
    sudo mkdir /data
    sudo mount /dev/xvdf1 /data
        
  13. Edit settings in /etc/fstab to make sure the volume always be mounted after reboot.
  14. 
    LABEL=cloudimg-rootfs / ext4 defaults,discard 0 0
    /dev/xvdf1 /data ext4 defaults,nofail 0 2
        
  15. Unmount, Mount again and Reboot.
  16. 
    sudo umount /data
    sudo mount -a
    sudo reboot
        

References