阿里云ECS服務(wù)器擴(kuò)容系統(tǒng)盤
1、通過(guò)ECS控制臺(tái)或者API擴(kuò)容云盤
2、根據(jù)操作系統(tǒng)安裝growpart擴(kuò)容格式化工具
4.3 調(diào)用growpart為需要擴(kuò)容的磁盤和對(duì)應(yīng)的第幾個(gè)分區(qū)擴(kuò)容
4.4 調(diào)用resize2fs擴(kuò)容文件系統(tǒng)
5.1 安裝dracut-modules-growroot工具
5.5 調(diào)用growpart為需要擴(kuò)容的磁盤和對(duì)應(yīng)的第幾個(gè)分區(qū)擴(kuò)容
5.7 調(diào)用resize2fs擴(kuò)容文件系統(tǒng)
1、通過(guò)ECS控制臺(tái)或者API擴(kuò)容云盤
在阿里云ECS控制臺(tái)中,選擇你要擴(kuò)容的那個(gè)服務(wù)器,進(jìn)行擴(kuò)容。擴(kuò)容完成后,重啟服務(wù)器,并創(chuàng)建快照以備份數(shù)據(jù)。
2、根據(jù)操作系統(tǒng)安裝growpart擴(kuò)容格式化工具
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:請(qǐng)使用上游版本(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,就是我的服務(wù)器內(nèi)核版本。
[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,但是分區(qū)容量只有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 調(diào)用growpart為需要擴(kuò)容的磁盤和對(duì)應(yīng)的第幾個(gè)分區(qū)擴(kuò)容
[root@localhost~]# growpart /dev/vda 1CHANGED:partition=1start=2048old:size=41940992end=41943040new:size=209710462,end=209712510
命令表示:為系統(tǒng)盤的第一個(gè)分區(qū)擴(kuò)容,即4.2步驟中的第一個(gè)分區(qū)。
4.4 調(diào)用resize2fs擴(kuò)容文件系統(tǒng)
[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.
命令表示:為系統(tǒng)盤的/dev/vda1分區(qū)擴(kuò)容文件系統(tǒng)。
[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操作系統(tǒng)為例演示分區(qū)擴(kuò)展的步驟
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 調(diào)用growpart為需要擴(kuò)容的磁盤和對(duì)應(yīng)的第幾個(gè)分區(qū)擴(kuò)容
[root@AliYunOS~]# growpart /dev/vda 1CHANGED:partition=1start=2048old:size=41940992end=41943040new:size=209710462,end=209712510
命令表示:為系統(tǒng)盤的第一個(gè)分區(qū)擴(kuò)容。
[root@AliYunOS~]# reboot
5.7 調(diào)用resize2fs擴(kuò)容文件系統(tǒng)
[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