EC2 Can't resize volume after increasing size

后端 未结 14 494
青春惊慌失措
青春惊慌失措 2020-11-30 16:30

I have followed the steps for resizing an EC2 volume

  1. Stopped the instance
  2. Took a snapshot of the current volume
  3. Created a new volume out of t
相关标签:
14条回答
  • 2020-11-30 17:03

    This will work for xfs file system just run this command

    xfs_growfs /
    
    0 讨论(0)
  • 2020-11-30 17:04

    Thanks, @Dimitry, it worked like a charm with a small change to match my file system.

    source: http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-expand-volume.html#recognize-expanded-volume-linux

    Then use the following command, substituting the mount point of the filesystem (XFS file systems must be mounted to resize them):

    [ec2-user ~]$ sudo xfs_growfs -d /mnt
    meta-data=/dev/xvdf              isize=256    agcount=4, agsize=65536 blks
             =                       sectsz=512   attr=2
    data     =                       bsize=4096   blocks=262144, imaxpct=25
             =                       sunit=0      swidth=0 blks
    naming   =version 2              bsize=4096   ascii-ci=0
    log      =internal               bsize=4096   blocks=2560, version=2
             =                       sectsz=512   sunit=0 blks, lazy-count=1
    realtime =none                   extsz=4096   blocks=0, rtextents=0
    data blocks changed from 262144 to 26214400
    

    Note If you receive an xfsctl failed: Cannot allocate memory error, you may need to update the Linux kernel on your instance. For more information, refer to your specific operating system documentation. If you receive a The filesystem is already nnnnnnn blocks long. Nothing to do! error, see Expanding a Linux Partition.

    0 讨论(0)
  • 2020-11-30 17:05

    Thank you Wilman your commands worked correctly, small improvement need to be considered if we are increasing EBSs into larger sizes

    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 (i.e. /dev/sda1)
    5. Detach current volume
    6. Attach the recently created volume to the instance, setting the exact mount point
    7. Restart the instance
    8. Access via SSH to the instance and run fdisk /dev/xvde

      WARNING: DOS-compatible mode is deprecated. It's strongly recommended to switch off the mode (command 'c') and change display units to sectors (command 'u')

    9. Hit p 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. Set the desired new space (if empty the whole space is reserved)
    15. Hit a to make it bootable
    16. Hit 1 and w to write changes
    17. Reboot instance OR use partprobe (from the parted package) to tell the kernel about the new partition table
    18. Log via SSH and run resize2fs /dev/xvde1
    19. Finally check the new space running df -h
    0 讨论(0)
  • 2020-11-30 17:07

    Put space between name and number, ex:

    sudo growpart /dev/xvda 1
    

    Note that there is a space between the device name and the partition number.

    To extend the partition on each volume, use the following growpart commands. Note that there is a space between the device name and the partition number.

    https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/recognize-expanded-volume-linux.html

    0 讨论(0)
  • 2020-11-30 17:08
    1. login into AWS web console -> EBS -> right mouse click on the one you wish to resize -> "Modify Volume" -> change "Size" field and click [Modify] button

    2. growpart /dev/xvda 1

    3. resize2fs /dev/xvda1

    This is a cut-to-the-chase version of Dmitry Shevkoplyas' answer. AWS documentation does not show the growpart command. This works ok for ubuntu AMI.

    0 讨论(0)
  • 2020-11-30 17:09
    1. sudo growpart /dev/xvda 1
    2. sudo resize2fs /dev/xvda1

    the above two commands saved my time for AWS ubuntu ec2 instances.

    0 讨论(0)
提交回复
热议问题