'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 1:[1]
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" [email protected] -p 22
ssh: connect to host ec2-172.1.1.3.compute-1.amazonaws.com port 22: Operation timed out
Solution 2:[2]
here's exactly what to do:
df -h
#print the name of your boot partition
lsblk
#show info on all your block devices
You'll see from that output what the name of the disk is of your root partition. For example, you probably see something like this:
xvde 202:64 0 32G 0 disk
??xvde1 202:65 0 8G 0 part /
Our goal is to make xvde1
use the whole available space from xvde
.
Here's how to resize your partition:
fdisk /dev/xvda
(the disk name, not your partition)
This enters into the fdisk
utility.
u
#Change the display to sectorsp
#Print infod
#Delete the partitionn
#New partitionp
#Primary partition1
#Partition number2048
#First sector- Press Enter to accept the default
p
#Print infoa
#Toggle the bootable flag1
#Select partition 1w
#Write table to disk and exit
Now, reboot your instance:
reboot
After it comes back do:
resize2fs /dev/xvde1
(the name of your partition, not the block device)
And finally verify the new disk size:
df -h
Solution 3:[3]
You need to extend the available space:
$ lsblk
xvda 202:0 0 500G 0 disk
??xvda1 202:1 0 100G 0 part /
$ growpart /dev/xvda 1
$ resize2fs /dev/xvda1
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | jacobcan118 |
Solution 2 | error2007s |
Solution 3 | Anil Koppula |