Few days (a month) back I had faced a strange (amateur) problem in Linux with Amazon EBS volume. For some reason I had to increase the volume size say double the size of current volume attached to an instance.
As a normal (not an “advance” user of Linux) I did the following steps:
- Dismounted the device (EBS Volume) by “umount /dev/sdf“.
- Logged into AWS console and detached the attached volume from the instance.
- Took a snapshot of that EBS volume.
- Created another volume from above created snapshot with double the size of the current volume.
- Attached the above newly created volume back to the instance.
- SSH to the instance and mounted the volume (a handy – “mount /dev/sdf/mnt/ebs”).
- Just curious (being a naive Linuxian), I tried to see the size of the volume by running “df -h”.
- It shows the size of the volume as the old one.
- I confirmed it in the AWS console the size of the new EBS volume is double the size of the original.
- What the HECK is happening???
Something challenging (at that time, remember I am not an “advance” user of Linux), I took a revenge, tried to figure out the problem. I throwed my keywords at the google and it gave me bunch of results. Ah there you go, one of the results paid the reward.
You have to tell Linux to recalculate the size of the attached device. There is a handy command to do that in Linux, try “resizefs /dev/sdf”, thats it. Now give a try to “df -h” – I hope the size what you see now won’t give you a SHOCK.
High chance of you getting a shock even after “resizefs” command, don’t be PANIC, it might display little lower (size) than you expected and that is because the way “df” & “EBS” calculates their block size.
The output reflects “99 GB” instead of “100 GB” because of slight differences in how “df” and “EBS” calculate “GB” (e.g., 1024 MB vs 1000 MB).
$ df -h / Filesystem Size Used Avail Use% Mounted on /dev/sda1 15G 1.6G 13G 12% /
$ sudo resize2fs /dev/sda1 resize2fs 1.40.4 (31-Dec-2007) Filesystem at /dev/sda1 is mounted on /; on-line resizing required old desc_blocks = 1, new_desc_blocks = 7 Performing an on-line resize of /dev/sda1 to 26214400 (4k) blocks. The filesystem on /dev/sda1 is now 26214400 blocks long.
$ df -h / Filesystem Size Used Avail Use% Mounted on /dev/sda199G 1.6G 92G 2% /
- Amazon EBS VOLUME – Attach/Detach – Mount/UMount – device is busy [SOLUTION] (rakeshsankar.wordpress.com)