Expanding root partition on AWS EC2

2019-07-14 01:23发布

I created a public VPC and then added a bunch of nodes to it so that I can use it for a spark cluster. Unfortunately, all of them have a partition setup that looks like the following:

ec2-user@sparkslave1: lsblk
/dev/xvda 100G
/dev/xvda1 5.7G /

I setup a cloud manager on top of these machines and all of the nodes only have 1G left for HDFS. How do I extend the partition so that it takes up all of the 100G?

I tried created /dev/xvda2, then created a volume group, added all of /dev/xvda* to it but /dev/xvda1 doesn't get added as it's mounted. I cannot boot from a live CD in this case, it's on AWS. I also tried resize2fs but it says that the root partition already takes up all of the available blocks, so it cannot be resized. How do I solve this problem and how do I avoid this problem in the future?

Thanks!

2条回答
放荡不羁爱自由
2楼-- · 2019-07-14 02:02

I had a same problem before, but can't remember the solution. Did you try to run

e2resize /dev/xvda1 

*This is when your using ext3, which is usually the default. The e2resize command will "grow" the ext3 filesystem to use the remaining free space.

查看更多
叛逆
3楼-- · 2019-07-14 02:22

I don't think you can just resize the running root volume. This is how you'd go about increasing the root size:

  1. create a snapshot of your current root volume
  2. create a new volume from this snapshot of the size that you want (100G?)
  3. stop the instance
  4. detach the old small volume
  5. attach the new bigger volume
  6. start instance
查看更多
登录 后发表回答