Resize2fs

I usually prefer the graphical way with gparted , it is possible find this useful command in a live disk of ubuntu or knoppix
but in amazon use this approach is a bit tricky so I learn another way with the command resize2fs. Anyway the graph interface is always preferable if you can use it.

I found two guides one with fdisk (https://codesilence.wordpress.com/2013/03/14/live-resizing-of-an-ext4-filesytem-on-linux/ ) the other with parted (http://www.gnu.org/software/parted/manual/html_node/parted_31.html)

the parted approach didn't work well for me with ubuntu 12.04 so I used with success the fisk method

staring point

df -h 
/dev/xvdf1       99G   94G   26M 100% /var/hg/repos

Fdisk delete a partition

this is the scary part if you don't do the makefs command the data will be not deleted. You need of course to recreate a good partition

enter in the disk

fdisk /dev/xvdf

it is very importat use the device not the partition in the above command fdisk /dev/xvdf1 IT IS WRONG!!!!

visualize , delete , visualize

Command (m for help): p   

Disk /dev/xvdf: 214.7 GB, 214748364800 bytes
255 heads, 63 sectors/track, 26108 cylinders, total 419430400 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000828a9

    Device Boot      Start         End      Blocks   Id  System
/dev/xvdf1            2048   390625279   195311616   83  Linux

Command (m for help): d
Selected partition 1

Command (m for help): p

Disk /dev/xvdf: 214.7 GB, 214748364800 bytes
255 heads, 63 sectors/track, 26108 cylinders, total 419430400 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000828a9

    Device Boot      Start         End      Blocks   Id  System

create a new partition

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
Partition number (1-4, default 1): 
Using default value 1
First sector (2048-419430399, default 2048): 
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-419430399, default 419430399): 
Using default value 419430399

resize

resize2fs /dev/xvdf1
resize2fs 1.42 (29-Nov-2011)
Filesystem at /dev/xvdf1 is mounted on /var/hg/repos; on-line resizing required
old_desc_blocks = 7, new_desc_blocks = 13
Performing an on-line resize of /dev/xvdf1 to 52428544 (4k) blocks.
The filesystem on /dev/xvdf1 is now 52428544 blocks long.

ending point

/dev/xvdf1      197G   94G   94G  50% /var/hg/repos
Salvo diversa indicazione, il contenuto di questa pagina è sotto licenza Creative Commons Attribution-ShareAlike 3.0 License