简体   繁体   中英

How to add volume to a ec2 instance on aws?

Created an ec2 instance with default Root Volume Type . That's just 8 GB.

$ df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            7.9G     0  7.9G   0% /dev
tmpfs           1.6G   25M  1.6G   2% /run
/dev/xvda1      7.7G  7.3G  439M  95% /
tmpfs           7.9G     0  7.9G   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           7.9G     0  7.9G   0% /sys/fs/cgroup
tmpfs           1.6G     0  1.6G   0% /run/user/1000
tmpfs           1.6G     0  1.6G   0% /run/user/113

Now the instace is full used like above. Want to add volume size, created an EBS volume, how to attach it to the instance without deleting the original data?

Option 1. Add another volume. Go to AWS Console -> EC2 -> Elastic Block Store -> Volumes. Create a volume, attach it to your instance. From that point on you should see the new volume from your instance with lsblk . Make a file system with mk2fs or whatever and mount with mount .

Option 2. Extend your current volume. Stop the instance, make a volume snapshot, create a new volume of the required size from that snapshot, detach old volume from the instance, attach the new volume. Make sure you're creating volume in the same availability zone that your EC2 instance is in. Start your instance. In most cases that's enough. If you file system was not resized automatically, use resize2fs to do it manually.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM