amazon-web-servicesamazon-ec2resizeroot

Amazon EC2 resize root device


I have one amazonw ec2 instance and would like to extend root device device form 100G to 500G. After create a new 500G volume and reattached to instance. I can see volume is there by command $lsblk. However, after I resize the disk. I cannot do it with error "The filesystem is already 26212055 blocks long. Nothing to do!

name@ip-172-1-1-3:~$ df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            3.9G  8.0K  3.9G   1% /dev
tmpfs           799M  840K  798M   1% /run
/dev/xvda1       99G   92G  3.1G  97% /
name@ip-172-1-1-3:~$ lsblk
NAME                              MAJ:MIN RM   SIZE RO TYPE       
MOUNTPOINT
xvda                              202:0    0   500G  0 disk
└─xvda1                           202:1    0   100G  0 part /
name@ip-172-1-1-3:~$sudo resize2fs /dev/xvda1
resize2fs 1.42.9 (4-Feb-2014)
The filesystem is already 26212055 blocks long.  Nothing to do!

Solution

  • After I follow @error2007s step 12 with "a" a #Toggle the bootable flag stop and reboot. I can not bring up instance.

    Disk /dev/xvda: 536.9 GB, 536870912000 bytes
    255 heads, 63 sectors/track, 65270 cylinders, total 1048576000 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: 0x00000000
    
        Device Boot      Start         End      Blocks   Id  System
    /dev/xvda1            2048  1048575999   524286976   83  Linux
    
    Command (m for help): a
    Partition number (1-4): 1
    
    Command (m for help): w
    The partition table has been altered!
    
    Calling ioctl() to re-read partition table.
    
    WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
    The kernel still uses the old table. The new table will be used at
    the next reboot or after you run partprobe(8) or kpartx(8)
    Syncing disks.
    name@ip-172-1-1-3:~$ reboot
    reboot: Need to be root
    name@ip-172-1-1-3:~$ sudo reboot
    
    Broadcast message from name@ip-172-1-1-3
        (/dev/pts/1) at 10:18 ...
    
    The system is going down for reboot NOW!
    $ ssh -i "a.pem" name@ec2-172.1.1.3.compute-1.amazonaws.com -p 22
    ssh: connect to host ec2-172.1.1.3.compute-1.amazonaws.com port 22: Operation timed out