【问题标题】:How to resize root partition on aws ec2 rhel7 ami?如何在 aws ec2 rhel7 ami 上调整根分区的大小?
【发布时间】:2014-07-10 11:14:10
【问题描述】:

我从 rhel7 ami-f7f03d80 ami 创建了一个 t2.micro 实例,具有 39gb gp2 xfs_ebs 存储、6gb / xfs 文件系统和 24gb 可用空间。我正在尝试使用xfs_growfs -d / 调整分区大小,它显示data size unchanged, skipping。当我将-D 2572864 指定给xfs_growfs 时,它会显示data size 2572864 too large, maximum is 1572864。看起来我需要先调整一个分区的大小,然后再调整一个文件系统的大小,但我不能在挂载的 fs 上这样做。我可以将 fdisk 和 xfs_growfs 打包到 initrd,然后从它启动,但这似乎太难了)似乎我错过了一些东西,可以通过其他方式完成。谢谢。

【问题讨论】:

  • 我无法执行第 5 步:分离当前卷。这是根 fs。
  • 为什么不呢?我已经做了 100 次这个程序,效果很好。

标签: linux amazon-web-services amazon-ec2 redhat xfs


【解决方案1】:

感觉有点吓人(先拍个快照)但是:

fdisk /dev/YOURDEVICE

删除您的分区,创建一个占用整个磁盘的新分区,写入更改,重新启动。

之后您应该会看到整个驱动器。

【讨论】:

  • 之后我必须运行xfs_growfs /dev/sda1,以便df -h 会更新。这在我的 1 个分区根磁盘上完美运行。
【解决方案2】:

我在 RHEL 7 上通过 gdisk 增加了我的根分区空间

1) yum -y 安装 gdisk

2) sudo gdisk /dev/xvda

删除所有分区

3)

Command (? for help): o This option deletes all partitions and creates a new protective MBR. Proceed? (Y/N): Y

4) 使用 n 命令为设备上的每个分区创建一个新的分区条目。

Command (? for help): n Partition number (1-128, default 1): 1 First sector (34-209715166, default = 2048) or {+-}size{KMGTP}: 2048 Last sector (2048-209715166, default = 209715166) or {+-}size{KMGTP}: 4095 Current type is 'Linux filesystem' Hex code or GUID (L to show codes, Enter = 8300): EF02 Changed type of partition to 'BIOS boot partition'

Command (? for help): n Partition number (2-128, default 2): 2 First sector (34-209715166, default = 4096) or {+-}size{KMGTP}: 4096 Last sector (4096-209715166, default = 209715166) or {+-}size{KMGTP}: 209715166 Current type is 'Linux filesystem' Hex code or GUID (L to show codes, Enter = 8300): 0700 Changed type of partition to 'Microsoft basic data'

5) 使用 w 命令将更改写入设备并退出。

Expert command (? for help): w

最终检查完成。即将写入 GPT 数据。这将覆盖现有的 分区!!

您要继续吗? (是/否):是 好的;将新的 GUID 分区表 (GPT) 写入 /dev/xvda。 操作已成功完成。

6) 重启系统 7) 重启后你可以看到你的 /root 分区大小增加了

【讨论】:

  • 谢谢 - 我尝试过的第一个没有损坏我在 AWS/RHEL 上的分区表的指南。
猜你喜欢
  • 2014-07-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-05-16
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多