小智 13
我采用的减少EBS根卷的方法如下:
停止(不终止)目标实例,并分离根EBS卷.或者,您可以快照根卷(或使用现有快照)并从中创建新的EBS卷.(例如/ dev/xvda1)
注意:您在上述步骤中使用的音量将被更改 - 因此您可能想拍摄快照(如果尚未拍摄).
Create a new EBS volume that is the desired size (e.g. /dev/xvdg)
Launch an instance, and attach both EBS volumes to it
Check the file system (of the original root volume): (e.g.) e2fsck -f /dev/xvda1
Maximally shrink the original root volume: (e.g. ext2/3/4) resize2fs -M -p /dev/xvda1
Copy the data over with dd:
Choose a chunk size (I like 16MB)
Calculate the number of chunks (using the number of blocks from the resize2fs output): blocks*4/(chunk_size_in_mb*1024) - round up a bit for safety
Copy the data: (e.g.) dd if=/dev/xvda1 ibs=16M of=/dev/xvdg obs=16M count=80
Resize the filesystem on the new (smaller) EBS volume: (e.g.) resize2fs -p /dev/xvdg
Check the file system (of the new volume): (e.g.) e2fsck -f /dev/xvdg
Detach your new EBS root volume, and attach it to your original instance
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
10693 次 |
| 最近记录: |