How to access to the files inside of an Elastic Block Store volume
The information and steps documented here are outside the scope of Hipchat Server support offerings. It is provided to help those that are less familiar with Amazon AWS services.
Purpose
Describe how to access the files inside of a Hipchat Server's Elastic Block Store (EBS) volume.
Solution
Part A - Detaching the EBS volume
1. Stop the EC2 Instance
2. In the EC2 Web Console, click on the 'root' device (/dev/sda1) found in the Instance details
3. Make a note of the EBS ID (e.g. vol-12345678)
4. Take a snapshot of the instance
5. Click on the EBS Volume ID to view the Elastic Block Store listing of the volume
6. Right-click on the Volume and select "Detach Volume"
Part B - Attaching the EBS volume
1. Start/Launch a new EC2 Instance (e.g. the latest Hipchat Server AMI)
2. After the new instance is booted, make a note of the Instance ID
3. Right-click on the Volume that is detached and shows an "available" state
4. Fill in the Instance: ID (AWS Web Console will autocomplete for you and indicate the name and status)
5. The Device field will autocomplete (e.g. /dev/sdf), make a note of it
2. In the EC2 Web Console's Instance details there should now be an additional Block device, e.g. /dev/sdf
Part C - Mounting the device to the operating system
1. SSH into the new EC2 Instance and become root:
sudo dont-blame-hipchat
2. List the block devices available:
lsblk
xvdf 202:80 0 60G 0 disk
xvdf1 202:81 0 60G 0 part
3. Check the type of data on the volume:
file -s /dev/xvdf
/dev/xvdf: x86 boot sector
file -s /dev/xvdf1
/dev/xvdf1: Linux rev 1.0 ext4 filesystem data, UUID=5866667e-914b-41fa-bc6c-836db0c9725f, volume name "cloudimg-rootfs" (needs journal recovery) (extents) (large files) (huge files)
4. Create a mount point, then mount the volume:
mkdir -p /mnt/myhipchatdata
mount /dev/xvdf1 /mnt/myhipchatdata -t ext4
ls -ahl /mnt/myhipchatdata
The newly mounted space contains all of the underlying folders and data from the EBS volume. In the example above, it can be access at /mnt/myhipchatdata.
Additional Resources
- The following article is helpful but "assumes that you're mounting an empty volume" which is what we are doing: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-using-volumes.html
- https://alestic.com/2011/02/ec2-fix-ebs-root/
- http://stackoverflow.com/questions/28792272/attaching-and-mounting-existing-ebs-volume-to-ec2-instance-filesystem-issue