操作场景
弹性云服务器创建成功后,如果发现系统盘分区的容量大小和实际购买的系统盘大小不一致,可以将空白分区扩容到根分区,扩容系统盘的空白空间。
本节介绍了怎样将空白分区在线扩容到末尾的root分区。
操作步骤
以centos 6.5 64bit 50GB系统盘为例,root分区在最末尾分区(e.g: /dev/xvda1: swap,/dev/xvda2: root)的扩容场景。
[root@sluo-ecs-5e7d ~]# parted -l /dev/xvda Model: Xen Virtual Block Device (xvd) Disk /dev/xvda: 53.7GB Sector size (logical/physical): 512B/512B Partition Table: msdos Number Start End Size Type File system Flags 1 1049kB 4296MB 4295MB primary linux-swap(v1) 2 4296MB 42.9GB 38.7GB primary ext4 boot
/dev/xvda1: UUID="25ec3bdb-ba24-4561-bcdc-802edf42b85f" TYPE="swap" /dev/xvda2: UUID="1a1ce4de-e56a-4e1f-864d-31b7d9dfb547" TYPE="ext4"
[root@sluo-ecs-5e7d ~]# growpart /dev/xvda 2 CHANGED: partition=2 start=8390656 old: size=75495424 end=83886080 new: size=96465599,end=104856255
[root@sluo-ecs-5e7d ~]# parted -l /dev/xvda Model: Xen Virtual Block Device (xvd) Disk /dev/xvda: 53.7GB Sector size (logical/physical): 512B/512B Partition Table: msdos Number Start End Size Type File system Flags 1 1049kB 4296MB 4295MB primary linux-swap(v1) 2 4296MB 53.7GB 49.4GB primary ext4 boot
[root@sluo-ecs-a611 ~]# resize2fs -f /dev/xvda2 resize2fs 1.42.9 (28-Dec-2013) Filesystem at /dev/xvda2 is mounted on /; on-line resizing required old_desc_blocks = 3, new_desc_blocks = 3 .... [root@sluo-ecs-a611 ~] # df -hT //检查文件系统扩容情况
resize2fs 命令前需要重启下,官网手册没写这个。可能和系统版本内核太低有关系。