Wednesday, October 2, 2013

Cannot Resize Amazon EC2 Volume after Increasing Volume Size ? Check this out!

Do the following to resize Amazon Ec2 VM Size :

1. Stop the instance
2. Create a snapshot from the volume
3. Create a new volume based on the snapshot increasing the size
4. Check and remember the current's volume mount point, in amazon ec2 console it is /dev/sda for old volume
5. Detach current volume
6. Attach the recently created volume to the instance, set the exact mount point
7. Restart the instance
8. Access via SSH to the instance and run fdisk /dev/xvde
9. Hit to show current partitions
10. Hit d to delete current partitions (if there are more than one, you have to delete one at a time) NOTE: Don't worry data is not lost
11. Hit n to create a new partition
12. Hit p to set it as primary
13. Hit 1 to set the first cylinder
14. Go with default values for prompt messages or set proper values (up to you to decide)
15. Hit a to make it bootable
16. Hit 1 and w to write changes
17. Reboot instance
18. Log via SSH and run resize2fs /dev/xvde1 , terminal will show you something like this

resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/xvde1 is mounted on /; on-line resizing required
old desc_blocks = 2, new_desc_blocks = 7
Performing an on-line resize of /dev/xvde1 to 26214055 (4k) blocks.



The filesystem on /dev/xvde1 is now 26214055 blocks long.

19. Finally check the new space running df -h

Enjoy!

Source http://stackoverflow.com/questions/11014584/ec2-cant-resize-volume-after-increasing-size

Saturday, September 28, 2013

Search and Replace a string in set of files recursively in Linux/Mac using terminal

Hi,

I found this stackoverflow question/answer about searching set of files and replacing a string using terminal
http://stackoverflow.com/questions/9704020/recursive-search-and-replace-on-mac-and-linux

Here is the command I used to replace .com with .org in a .jade files I have in express.js application

find . -type f -name '*.ejs' -exec sed -i 's/.com/.org/g' {} +

Enjoy!