阿里云Linux CENTOS 根分区扩容云盘(CentOS 7系统)
一、前文
阿里云ECS服务器,原本购买了40GB的云盘,用了不到一年,就不够用了
只能加钱扩容了
扩容后发现好像没生效,只能花时间研究研究
二、查看分区容量
[root@iZ2zej1nogjvot6f4dzt6eZ var]# fdisk -lu
Disk /dev/vda: 107.4 GB, 107374182400 bytes, 209715200 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
Disk label type: dos
Disk identifier: 0x0002b49c Device Boot Start End Blocks Id System
/dev/vda1 * 2048 83886046 41941999+ 83 Linux
[root@iZ2zej1nogjvot6f4dzt6eZ var]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
devtmpfs devtmpfs 3.7G 0 3.7G 0% /dev
tmpfs tmpfs 3.7G 0 3.7G 0% /dev/shm
tmpfs tmpfs 3.7G 880K 3.7G 1% /run
tmpfs tmpfs 3.7G 0 3.7G 0% /sys/fs/cgroup
/dev/vda1 ext4 40G 23G 16G 60% /
tmpfs tmpfs 756M 0 756M 0% /run/user/0
overlay overlay 40G 23G 16G 60% /var/lib/docker/overlay2/e79cb8bc0017b936119a0b697d82a082f7a44edd0b8fdbb943d6323c75769bd1/merged
tmpfs tmpfs 756M 0 756M 0% /run/user/1000
三、扩容分区
[root@iZ2zej1nogjvot6f4dzt6eZ var]# yum install gdisk -y
Loaded plugins: fastestmirror
Determining fastest mirrors
base | 3.6 kB 00:00:00
docker-ce-stable | 3.5 kB 00:00:00
emqx-ce-stable | 2.9 kB 00:00:00
epel | 4.7 kB 00:00:00
extras | 2.9 kB 00:00:00
influxdb | 2.5 kB 00:00:00
mysql-connectors-community | 2.6 kB 00:00:00
mysql-tools-community | 2.6 kB 00:00:00
mysql57-community | 2.6 kB 00:00:00
updates | 2.9 kB 00:00:00
(1/11): epel/x86_64/group_gz | 96 kB 00:00:00
(2/11): epel/x86_64/updateinfo | 1.0 MB 00:00:00
(3/11): extras/7/x86_64/primary_db | 243 kB 00:00:00
(4/11): docker-ce-stable/x86_64/primary_db | 70 kB 00:00:00
(5/11): epel/x86_64/primary_db | 7.0 MB 00:00:00
(6/11): mysql-tools-community/x86_64/primary_db | 92 kB 00:00:00
(7/11): mysql-connectors-community/x86_64/primary_db | 87 kB 00:00:00
(8/11): updates/7/x86_64/primary_db | 13 MB 00:00:00
(9/11): influxdb/7/x86_64/primary_db | 60 kB 00:00:01
(10/11): mysql57-community/x86_64/primary_db | 288 kB 00:00:01
(11/11): emqx-ce-stable/primary_db | 1.1 MB 00:00:05
Resolving Dependencies
–> Running transaction check
—> Package gdisk.x86_64 0:0.8.10-3.el7 will be installed
–> Finished Dependency Resolution
Dependencies Resolved
===========================================================================================================================================================================
Package Arch Version Repository Size
Installing:
gdisk x86_64 0.8.10-3.el7 base 190 k
Transaction Summary
Install 1 Package
Total download size: 190 k
Installed size: 660 k
Downloading packages:
gdisk-0.8.10-3.el7.x86_64.rpm | 190 kB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : gdisk-0.8.10-3.el7.x86_64 1/1
Verifying : gdisk-0.8.10-3.el7.x86_64 1/1
Installed:
gdisk.x86_64 0:0.8.10-3.el7
Complete!
[root@iZ2zej1nogjvot6f4dzt6eZ var]# growpart /dev/vda 1
CHANGED: partition=1 start=2048 old: size=83883999 end=83886047 new: size=209713119 end=209715167
四、扩容文件系统
[root@iZ2zej1nogjvot6f4dzt6eZ var]# resize2fs /dev/vda1
resize2fs 1.42.9 (28-Dec-2013)
Filesystem at /dev/vda1 is mounted on /; on-line resizing required
old_desc_blocks = 3, new_desc_blocks = 7
The filesystem on /dev/vda1 is now 26214139 blocks long.
[root@iZ2zej1nogjvot6f4dzt6eZ var]# df -Th
Filesystem Type Size Used Avail Use% Mounted on
devtmpfs devtmpfs 3.7G 0 3.7G 0% /dev
tmpfs tmpfs 3.7G 0 3.7G 0% /dev/shm
tmpfs tmpfs 3.7G 880K 3.7G 1% /run
tmpfs tmpfs 3.7G 0 3.7G 0% /sys/fs/cgroup
/dev/vda1 ext4 99G 23G 72G 24% /
tmpfs tmpfs 756M 0 756M 0% /run/user/0
overlay overlay 99G 23G 72G 24% /var/lib/docker/overlay2/e79cb8bc0017b936119a0b697d82a082f7a44edd0b8fdbb943d6323c75769bd1/merged
tmpfs tmpfs 756M 0 756M 0% /run/user/1000
五、最后验证
成功,撒花