Aws-storage: Difference between revisions

From Bashlinux
Jump to navigationJump to search
Content deleted Content added
Manpaz (talk | contribs)
No edit summary
Manpaz (talk | contribs)
Redirected page to AWS persistent storage
 
Line 1: Line 1:
#REDIRECT [[AWS persistent storage]]
__NOTOC__
= Persistent Storage =

== Prepare the work environment ==
Before start ensure you have the latest EC2 API tools installed on system.

Download the latest EC2 API from Amazon:
[http://developer.amazonwebservices.com/connect/entry.jspa?externalID=351]

And follow the instructions in [[aws-build|Buindling an AMI]] to install or replace the current API.


<pre><nowiki>#!wiki warning
'''Warning'''

Older releases of EC2 API cannot handle persistent volume commands.
</nowiki></pre>


== Create volume ==
# Look for available zones
<pre><nowiki>
# ec2-describe-availability-zones
AVAILABILITYZONE us-east-1a available
AVAILABILITYZONE us-east-1b available
AVAILABILITYZONE us-east-1c available
</nowiki></pre>

# Create a volume, the `-s` specifies the size in Gigabytes.
<pre><nowiki>
# ec2-create-volume -z us-east-1a -s 549755813888
Client.InvalidParameterValue: Volume of 549755813888GiB is too large; maximum is 1024GiB.
# ec2-create-volume -z us-east-1a -s 128
VOLUME vol-cd2dc8a4 128 us-east-1a creating 2008-08-29T01:07:22+0000
</nowiki></pre>

# Check the volume status
<pre><nowiki>
# ec2-describe-volumes
VOLUME vol-cd2dc8a4 128 us-east-1a available 2008-08-29T01:07:22+0000
</nowiki></pre>


== Attach volume to an instance ==
# Get the instance name
<pre><nowiki>
# ec2-describe-instances
RESERVATION r-9f5c9ff6 367161194499 default
INSTANCE i-577aae3e ami-43ab4f2a ec2-75-101-129-154.compute-1.amazonaws.com domU-12-31-39-00-A2-02 .compute-1.internal running bashlinux-general-server-keypair 0 m1.small 2008-06-20T01:57:42+0000 us-east-1a
</nowiki></pre>

# Attach the volume using the instance name `i-577aae3e` obtained from the last command, note that `/dev/sdb` must not exist, in case it does, then just use another name not used yet
<pre><nowiki>
# ec2-attach-volume vol-cd2dc8a4 -i i-577aae3e -d /dev/sdb
ATTACHMENT vol-cd2dc8a4 i-577aae3e /dev/sdb attaching 2008-08-29T01:18:06+0000
</nowiki></pre>

# Login into the instance
<pre><nowiki>
# ssh -i .ssh/bashlinux-general-server-keypair [email protected]
</nowiki></pre>

# Format the new attached drive `/dev/sdb`
<pre><nowiki>
[root@ec2 ~]# mkfs -t ext3 /dev/sdb
mke2fs 1.39 (29-May-2006)
/dev/sdb is entire device, not just one partition!
Proceed anyway? (y,n) y
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
16777216 inodes, 33554432 blocks
1677721 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=0
1024 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872

Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 38 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
</nowiki></pre>

# Mount the new partitioned drive
<pre><nowiki>
[root@ec2 ~]# mkdir -p /mnt/storage
[root@ec2 ~]# mount /dev/sdb /mnt/storage
</nowiki></pre>

# Check new partition space
<pre><nowiki>
[root@ec2 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 4.0G 4.0G 0 100% /
none 851M 0 851M 0% /dev/shm
/dev/sda2 147G 388M 139G 1% /mnt
/dev/sdb 126G 188M 120G 1% /mnt/storage
</nowiki></pre>


== Remove volume ==
# Login into the instance
<pre><nowiki>
# ssh -i .ssh/bashlinux-general-server-keypair [email protected]
</nowiki></pre>

# Unmount the volume
<pre><nowiki>
[root@ec2 log]# umount /mnt/storage
</nowiki></pre>

# Check the volume was unmounted
<pre><nowiki>
[root@ec2 log]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda1 4.0G 4.0G 0 100% /
none 851M 0 851M 0% /dev/shm
/dev/sda2 147G 388M 139G 1% /mnt
</nowiki></pre>

# Logout from the instance
<pre><nowiki>
[root@ec2 log]# exit
</nowiki></pre>

# Detach the volume
<pre><nowiki>
# ec2-detach-volume vol-cd2dc8a4 -i i-577aae3e -d /dev/sdb
ATTACHMENT vol-cd2dc8a4 i-577aae3e /dev/sdb detaching 2008-08-29T01:18:06+0000
</nowiki></pre>

# Delete volume
<pre><nowiki>
# ec2-delete-volume vol-cd2dc8a4
VOLUME vol-cd2dc8a4
</nowiki></pre>

# Check deleted volume
<pre><nowiki>
# ec2-describe-volumes
VOLUME vol-cd2dc8a4 128 us-east-1a deleting 2008-08-29T01:07:22+0000
</nowiki></pre>

Latest revision as of 23:22, 9 June 2015