0
votes

My Amazon EC2 Instance only have 8GB of EBS Volume sda1, this volume is near to full capacity.

Then I attach new 21GB EBS Volume sdf to this EC2 Instance.

When I use df -h to check this usage, this is what I get:

Filesystem            Size  Used Avail Use% Mounted on
/dev/xvdf             7.9G  5.3G  2.6G  67% /
tmpfs                 298M     0  298M   0% /dev/shm

Then I use resize2fs /dev/xvdf to resize, this is the df -h:

Filesystem            Size  Used Avail Use% Mounted on
/dev/xvdf              21G  5.3G   16G  26% /
tmpfs                 298M     0  298M   0% /dev/shm

Should I detach the first EBS Volume sda1 ? Why is sda1 not showing in df -h?

Updated Results:

$ ls /dev/xvd*

/dev/xvda1  /dev/xvdf
1
It looks like you attached a volume to /dev/xvdf but detached (or at least did not mount) the volume that was previously at /dev/sda1. It's a little odd to have your root file system (/) mounted from a volume attached to /dev/xvdf on EC2, but apparently it's working with whatever distro you're using.Eric Hammond
If you still are looking for an answer, consider updating your question with the results of (1) ls /dev/xvd* (2) ec2-describe-instances <instanceid> | grep BLOCKDEVICE (3) cat /etc/fstab | grep /dev/xvdEric Hammond
@EricHammond I have updated my question. Number 2 return with this error: Required option '-O, --aws-access-key KEY' missing (-h for usage) while number 3 has no result.did1k
You have two EBS volumes attached, one at /dev/xvda1 and one at /dev/xvdf. The former is not mounted. The latter is mounted as your root file system. It would be difficult to give advice on where to go from here without knowing exactly what was on each volume and your plans for that data.Eric Hammond

1 Answers

2
votes

No. You need to mount the volume before it will show up in the df command.

Also a little education, the 8gb drive is your root drive. Try not to put stuff there other than application installs, etc.

Creating and mounting a new volume like you want takes the following steps:

  1. Create the volume in the AWS Management Console.
  2. Attach the volume in the AWS Management Console.
  3. Decide what type of file system you want it to be, I typically use XFS.
  4. yum install xfsprogs, or apt-get it or whatever
  5. mkfs.xfs /dev/NEWVOLUME (note: amazon will tell you its attached to sdf or whatever when sometimes its really attached to xvdf or something)
  6. Warm up the volume. This is a little known secret, but all the space on the volume as be assigned to that volume but not yet allocated. So writing a bunch of zeros to the volume will warm it up and make it perform much faster. This can take a while for big volumes. The command is: dd if=/dev/<device> of=/dev/null
  7. Make a dir to mount it to: mkdir /logs (or whatever)
  8. mount /dev/NEWVOLUME /logs

Done. Now run your df -h and you will see it.