
使用中的云盘在不挂载不格式化情况下进行扩容(适用于系统盘和数据盘)
目录
1、扩容物理盘
2、安装growpart和resize2fs工具
3、检查扩容磁盘属性
4、使用growpart工具扩容分区
5、使用resize2fs工具扩容文件系统
6、检查扩容结果
注意: *** 作之前需要对云盘进行快照或者其它方式备份,扩容云盘存在数据丢失风险
1、检查云盘大小
/dev/vda显示容量为107G(在线扩容后的容量,扩容部分只是增加了物理容量,分区和文件系统还不能使用)
2、运行df -h命令查看云盘分区大小。
以下示例返回分区(/dev/vda1)容量是20G
growpart 是磁盘分区扩容工具
示例命令表示给系统盘的第一个分区扩容(是第一个分区,而不是分区名称)
若运行命令后报以下错误,您可以运行LANG=en_US.UTF-8切换ECS实例的字符编码类型。
resize2fs 是扩容文件系统工具
示例命令表示为扩容系统盘的/dev/vda1分区文件系统(ext4格式)
备注:
***如果您使用的是xfs文件系统,运行xfs_growfs /dev/vda1命令扩容文件系统。
文件系统检查命令:
***执行命令如提示已到达最大分区时,需使用reboot重启Linux后再次执行命令
分区/dev/vda1容量显示为100G,成功扩容
从MBR转换到GPT分区错误提示:
[root@iZuf6 ~]# gdisk /dev/vdd
GPT fdisk (gdisk) version 0.8.10
Partition table scan:
MBR: MBR only
BSD: not present
APM: not present
GPT: not present
Found invalid GPT and valid MBRconverting MBR to GPT format
in memory. THIS OPERATION IS POTENTIALLY DESTRUCTIVE! Exit by
typing 'q' if you don't want to convert your MBR partitions
to GPT format!
Warning! Secondary partition table overlaps the last partition by
32 blocks!
Try reducing the partition table size by 128 entries.
(Use the 's' item on the experts' menu.)
Command (? for help): w
Warning! Secondary partition table overlaps the last partition by
32 blocks!
Try reducing the partition table size by 128 entries.
(Use the 's' item on the experts' menu.)
Aborting write of new partition table.
原因: 磁盘空间不够,无法转换
扩容磁盘描述
当前仅支持对数据盘的扩容 *** 作。
只有数据盘类型为普通云盘、高效云盘、SSD
云盘,才可以进行扩容 *** 作。
挂载在实例上的数据盘,只有实例为
Running
或者
Stopped
状态时,才可以进行扩容 *** 作。
磁盘上如果正在执行打快照的 *** 作,则此时不允许进行扩容 *** 作。
挂载在实例上的磁盘,在进行扩容 *** 作后,需要在控制台或者使用
Open
API
重启实例才能使扩容生效。
扩容仅做磁盘容量的扩大,不做分区和文件系统的扩大,扩容完成后,用户还需要手动分配存储空间。
请求参数
名称
类型
是否必须
描述
Action
String
是
系统规定参数,取值:ResizeDisk
DiskId
String
是
磁盘的编号
NewSize
Integer
是
希望扩容到的磁盘大小。
以
GB
为单位,取值范围为
Cloud:5
~
2000
ClientToken
String
否
用于保证请求的幂等性。由客户端生成该参数值,要保证在不同请求间唯一,最大不值过
64
个
ASCII
字符。
返回参数
全是公共返回参数,详见公共返回参数
错误码
错误代码
描述
Http
状态码
语义
InvalidDiskSize.TooSmall
Specified
new
disk
size
is
less
than
the
original
disk
size
403
指定的新磁盘容量比原磁盘容量小
InvalidParameter
The
specified
parameter
"NewSize"
is
not
valid.
403
指定的新磁盘容量超出了限制范围
OperationDenied
The
status
of
the
disk
or
the
instance
that
the
disk
is
attaching
with
does
not
support
the
operation
403
磁盘或者磁盘所挂载的实例状态不支持扩容
OperationDenied
The
type
of
the
disk
does
not
support
the
operation
403
磁盘类型不支持扩容
InvalidDiskId.NotFound
The
specified
disk
does
not
exist.
404
磁盘不存在
InvalidInstanceId.NotFound
The
specified
instance
does
not
exist.
404
磁盘所挂载的实例不存在
InstanceExpiredOrInArrears
The
specified
operation
is
denied
as
your
prepay
instance
is
expired
(prepay
mode)
or
in
arrears
(afterpay
mode).
403
磁盘挂载的实例过期
示例
请求示例
https://ecs.aliyuncs.com/?Action=ResizeDisk
&DiskId=xxx
&NewSize=1024
&<公共请求参数>
返回示例
'XML'格式
F3CD6886-D8D0-4FEE-B93E-1B73239673DE
'JSON'格式
{
"RequestId":
"F3CD6886-D8D0-4FEE-B93E-1B73239673DE"
}
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)