1、首先花钱完成云盘扩容,云盘扩容后(不管是在线还是离线)操作系统中的可用空间都不会增加:
1 2 3 4 5 6 7 8 9 |
root@ib2cd3uawZ:~# df -h Filesystem Size Used Avail Use% Mounted on udev 3.9G 0 3.9G 0% /dev tmpfs 798M 3.0M 795M 1% /run /dev/vda1 40G 35G 2.3G 94% / tmpfs 3.9G 0 3.9G 0% /dev/shm tmpfs 5.0M 0 5.0M 0% /run/lock tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup tmpfs 798M 0 798M 0% /run/user/0 |
可见根分区容量依然是40GB。
2、操作系统中在线对根分区扩容,需要安装几个工具:
1 2 |
apt install cloud-guest-utils apt install xfsprogs |
3、用fdisk查看下硬盘空间确实是变成了60GB,但分区大小依然是40GB:
1 2 3 4 5 6 7 8 9 10 |
root@ib2cd3uawZ:~# fdisk -l Disk /dev/vda: 60 GiB, 64424509440 bytes, 125829120 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0xea062096 Device Boot Start End Sectors Size Id Type /dev/vda1 * 2048 83884031 83881984 40G 83 Linux |
4、接下来调整分区大小:
1 2 3 4 5 6 7 8 |
root@ib2cd3uawZ:~# growpart /dev/vda 1 CHANGED: partition=1 start=2048 old: size=83881984 end=83884032 new: size=125827039,end=125829087 root@ib2cd3uawZ:~# resize2fs /dev/vda1 resize2fs 1.44.1 (24-Mar-2018) Filesystem at /dev/vda1 is mounted on /; on-line resizing required old_desc_blocks = 3, new_desc_blocks = 4 The filesystem on /dev/vda1 is now 15728379 (4k) blocks long. |
其中,growpart <DeviceName> <PartionNumber>命令调用growpart为需要扩容的云盘和对应的第几个分区扩容,上述命令表示为系统盘的第一个分区扩容。
然后查看分区大小已经成功调整好:
1 2 3 4 5 6 7 8 9 |
root@ib2cd3uawZ:~# df -h Filesystem Size Used Avail Use% Mounted on udev 3.9G 0 3.9G 0% /dev tmpfs 798M 3.0M 795M 1% /run /dev/vda1 59G 35G 22G 63% / tmpfs 3.9G 0 3.9G 0% /dev/shm tmpfs 5.0M 0 5.0M 0% /run/lock tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup tmpfs 798M 0 798M 0% /run/user/0 |
参考文档:
1、https://help.aliyun.com/document_detail/111738.html?spm=a2c4g.11186623.2.30.2ba67f6750nrPt#concept-ocb-htw-dhb
转载时请保留出处,违法转载追究到底:进城务工人员小梅 » 阿里云ECS Linux根分区扩容(数据盘也可以)