Total Pageviews

Thursday, July 14, 2011

How to attach and mount EBS volume into EC2 Instance Ubuntu 10.10

 

http://yoodey.com/how-attach-and-mount-ebs-volume-ec2-instance-ubuntu-1010

Updated!
Before you do this, backup all /var into /var-backup by sudo rsync -avr /var/* /var-backup/
After mounting EBS, you can rsync restore /var by sudo rsync -avr /var-backup/* /var/
Using EBS volume can decrease risk of server crash suddenly or "permission denied" problem in EC2 server. The logic, after we create instance store, we create new EBS volume which we can set the capacity as we need. In this cases, i create 60GB EBS and will using it as /var in instance store. Now, let configure our EC2 and using EBS as indepent storage.
1. Create EBS Volume and attach it into instance store in EC2 panel management. Use same region, ex : east-1b
2. Login into instance store SSH.
3. In my configuration, EBS Volume located in /dev/sdg. So remember what yours.
4. Use sudo fdisk -l to see if your EBS already attached
Disk /dev/sdg: 64.4 GB, 64424509440 bytes
255 heads, 63 sectors/track, 7832 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
5. Formating EBS Volume so we can use it by sudo mkfs -t ext4 /dev/sdg and you will get result :
mke2fs 1.41.12 (17-May-2010)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
3932160 inodes, 15728640 blocks
786432 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
480 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424
This will takes a long time, like 10-30 minutes.
6. Edit /etc/fstab and add this :
/dev/sdg        /var    auto    defaults,nobootwait,noatime     0       0
and reboot from EC2 panel management. Now, you use EBS for all installed program and www.

No comments: