阿里云ECS服务器扩容系统盘
4.3 调用growpart为需要扩容的磁盘和对应的第几个分区扩容
5.1 安装dracut-modules-growroot工具
5.5 调用growpart为需要扩容的磁盘和对应的第几个分区扩容
在阿里云ECS控制台中,选择你要扩容的那个服务器,进行扩容。扩容完成后,重启服务器,并创建快照以备份数据。
2.1 CentOS 7、Aliyun Linux:
yum install cloud-utils-growpart
2.2 Ubuntu 14、Ubuntu 16、Ubuntu 18、Debian 9:
apt install cloud-guest-utils
2.3 Debian 8、OpenSUSE 42.3、OpenSUSE 13.1、SUSE Linux Enterprise Server 12 SP2:请使用上游版本(upstream)的growpart工具
[root@izwz9e66hx6no4074nle2lz~]# uname -aLinux izwz9e66hx6no4074nle2lz3.10.0-693.5.2.el7.x86_64#1 SMP Fri Oct 20 20:32:50 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux[root@izwz9e66hx6no4074nle2lz~]#
3.10.0,就是我的服务器内核版本。
[root@localhost~]# fdisk -lDisk/dev/vda:107.4GB,107374182400bytes,209715200sectorsUnits=sectors of1*512=512bytesSector size(logical/physical):512bytes/512bytesI/O size(minimum/optimal):512bytes/512bytesDisk labeltype:dosDisk identifier:0x0008d73aDevice Boot Start End Blocks Id System/dev/vda1*2048419430392097049683Linux
示例返回磁盘(/dev/vda)容量是100 GiB,但是分区容量只有20G。
[root@localhost~]# df -hFilesystem Size Used Avail Use%Mounted on/dev/vda1 20G 19G 0G100%/devtmpfs7.8G07.8G0%/devtmpfs7.8G07.8G0%/dev/shmtmpfs7.8G 344K7.8G1%/runtmpfs7.8G07.8G0%/sys/fs/cgrouptmpfs1.6G01.6G0%/run/user/0
4.3 调用growpart为需要扩容的磁盘和对应的第几个分区扩容
[root@localhost~]# growpart /dev/vda 1CHANGED:partition=1start=2048old:size=41940992end=41943040new:size=209710462,end=209712510
命令表示:为系统盘的第一个分区扩容,即4.2步骤中的第一个分区。
[root@localhost~]# resize2fs /dev/vda1resize2fs1.42.9(28-Dec-2013)Filesystem at/dev/vda1ismounted on/;on-line resizing requiredold_desc_blocks=2,new_desc_blocks=7The filesystem on/dev/vda1isnow26213807blockslong.
命令表示:为系统盘的/dev/vda1分区扩容文件系统。
[root@localhost~]# df -hFilesystem Size Used Avail Use%Mounted on/dev/vda1 100G 19G 80G25%/devtmpfs7.8G07.8G0%/devtmpfs7.8G07.8G0%/dev/shmtmpfs7.8G 344K7.8G1%/runtmpfs7.8G07.8G0%/sys/fs/cgrouptmpfs1.6G01.6G0%/run/user/0
以CentOS 6操作系统为例演示分区扩展的步骤
5.1 安装dracut-modules-growroot工具
[root@AliYunOS~]# yum install -y dracut-modules-growroot
[root@AliYunOS~]# dracut -f
[root@AliYunOS ~]# fdisk -l
Disk /dev/vda: 107.4 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0003a7b4
Device Boot Start End Blocks Id System
/dev/vda1 * 1 2611 20970496 83 Linux
[root@AliYunOS~]# df -hFilesystem Size Used Avail Use%Mounted on/dev/vda1 20G1.1G 18G6%/tmpfs7.8G07.8G0%/dev/shm
5.5 调用growpart为需要扩容的磁盘和对应的第几个分区扩容
[root@AliYunOS~]# growpart /dev/vda 1CHANGED:partition=1start=2048old:size=41940992end=41943040new:size=209710462,end=209712510
命令表示:为系统盘的第一个分区扩容。
[root@AliYunOS~]# reboot
[root@AliYunOS~]# resize2fs /dev/vda1resize2fs1.41.12(17-May-2010)Filesystem at/dev/vda1ismounted on/;on-line resizing requiredold desc_blocks=2,new_desc_blocks=7Performing an on-line resize of/dev/vda1 to26213807(4k)blocks.The filesystem on/dev/vda1isnow26213807blockslong.
[root@AliYunOS~]# df -hFilesystem Size Used Avail Use%Mounted on/dev/vda1 99G1.1G 93G2%/tmpfs7.8G07.8G0%/dev/shm