linux - 缩小 Amazon EBS 卷后无法启动

标签 linux amazon-web-services amazon-ec2

我已点击 Google 和此论坛上的几个链接以减少 Amazon AWS 上的 EBS 卷,也包括以下链接:

http://wiki.jokeru.ro/shrink-amazon-ebs-root-volume

http://www.lantean.co/shrinking-ebs-volume/

我有一个 254 GB 的 EBS 卷,需要将其大小调整为 150 GB。以下是我所做的步骤:

  1. 创建一个具有 8 GB 卷/dev/xvde(基本操作系统)的新实例
  2. 在基本操作系统上安装 254 GB 卷/dev/xvdj。
  3. 在基本操作系统上安装 150 GB 空卷/dev/xvdk。
  4. /dev/xvdj有8个分区如下:

Disk /dev/xvdj: 272.7 GB, 272730423296 bytes
255 heads, 63 sectors/track, 33157 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00029527

    Device Boot      Start         End      Blocks   Id  System
/dev/xvdj1   *           1          13      102400   83  Linux
Partition 1 does not end on cylinder boundary.
/dev/xvdj2              13        6540    52428800   83  Linux
/dev/xvdj3            6540       10457    31457280   83  Linux
/dev/xvdj4           10457       33114   181998592    5  Extended
/dev/xvdj5           10457       11501     8388608   82  Linux swap / Solaris
/dev/xvdj6           11501       12154     5242880   83  Linux
/dev/xvdj7           12154       12285     1048576   83  Linux
/dev/xvdj8           12285       33114   167314432   83  Linux

  1. 因为/dev/xvdk 是空卷,所以没有分区,我想必须根据/dev/xvdj 创建分区
  2. 根据上面的链接,我运行了 e2fsck -f/dev/xvdj1,然后是 resize2fs -M -p/dev/xvdj1,用于所有分区/dev/xvdj(/dev/xvdj4 和 5 除外)
  3. 完成上述命令后,我根据需要在/dev/xvdk 卷上创建了分区,注意大小将大于/dev/xvdj 的分区
  4. 150GB Volume的分区如下:

Disk /dev/xvdk: 161.1 GB, 161061273600 bytes
255 heads, 63 sectors/track, 19581 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xeea3d8c8

Device     Boot      Start         End      Blocks   Id  System
/dev/xvdk1   *           1         132     1060258+  83  Linux
/dev/xvdk2             133        9271    73409017+  83  Linux
/dev/xvdk3            9272       17105    62926605   83  Linux
/dev/xvdk4           17106       19581    19888470    5  Extended
/dev/xvdk5           17106       18150     8393931   82  Linux swap / Solaris
/dev/xvdk6           18151       19456    10490413+  83  Linux
/dev/xvdk7           19457       19581     1004031   83  Linux
    

  1. 对于第一个分区,我还使用 fdisk/dev/xvdk 并选择 a 和分区号(即 1)添加了一个可引导标志
  2. 分区后,我按照上面的链接计算 block 数,发出dd命令复制数据。
  3. dd 命令完成后,我对/dev/xvdk(/dev/xvdk4 和 5 除外)
  4. 完成上述命令后,我关闭了基本操作系统,然后分离了 150 GB 的卷。
  5. 我为 150 GB 的卷创建了一个快照,在创建快照后,我从该快照创建了一个镜像 (AMI)。
  6. 我使用此图像启动了一个实例,我成功启动了该实例,但启动后我无法连接到该实例。
  7. 此外,2 次状态检查中有 1 次抛出有关连接的错误,我无法调查哪里出错了。

谁能告诉我我哪里做错了或者我完全偏离了轨道吗?

最佳答案

我在 AWS 的知识库中找到了一个优雅的解决方案。

链接在这里:http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/storage_expand_partition.html#expanding-partition-parted

它使用了 parted 工具。

注意:您需要将卷附加到不同的实例才能调整它的大小。

关于linux - 缩小 Amazon EBS 卷后无法启动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26622794/

相关文章:

linux - Casperjs 登录无法正常工作,不断收到重新提交错误

c - sndfile.h中的sf_count_t类型在libsndfile中是怎么定义的?

postgresql - 无法让 dblink 在只读副本上工作

java - 无法通过 Hibernate 或 sqlplus 连接到 Amazon RDS DBInstance

amazon-web-services - 如何正确使用安全组内的VpcId属性?

ubuntu - nginx - 绑定(bind)()到 0.0.0.0 :80 failed (98: Address already in use)

python - 在 ipython 中执行 `ls` 时如何修复 PermissionError?

linux - 将参数传递给具有开关的 shell 脚本

amazon-web-services - AWS 特定参数和 EC2 SecurityGroupIds 列表字符串错误

amazon-ec2 - 我应该将我的 AWS 访问 key 添加到哪个 core-site.xml?