alpine在线扩容系统盘(非ivm)

发布时间 2023-05-09 14:34:16作者: 每日一坑

扩容需要用到2个命令

我们需要使用到 resize2fs 运行 apk add e2fsprogs-extra 安装

我们需要使用到 growpart 运行 apk add cloud-utils-growpart 安装


扩容前

node215:~# fdisk -l
Disk /dev/sda: 500 GiB, 536870912000 bytes, 1048576000 sectors
Disk model: VMware Virtual S
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: 0xe39d441f

Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 616447 614400 300M 83 Linux
/dev/sda2 616448 9005055 8388608 4G 82 Linux swap / Solaris
/dev/sda3 9005056 419430399 410425344 195.7G 83 Linux

进行扩容

node215:~# growpart /dev/sda 3   #注意这里是指的sda的第3块分区,不是sda3
CHANGED: partition=3 start=9005056 old: size=410425344 end=419430399 new: size=1039570911 end=1048575966 node215:~# fdisk -l Disk /dev/sda: 500 GiB, 536870912000 bytes, 1048576000 sectors Disk model: VMware Virtual S 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: 0xe39d441f

Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 616447 614400 300M 83 Linux
/dev/sda2 616448 9005055 8388608 4G 82 Linux swap / Solaris
/dev/sda3 9005056 1048575966 1039570911 495.7G 83 Linux

node215:~# resize2fs /dev/sda3 #重新定义sda3的ext4文件系统大小
resize2fs
1.47.0 (5-Feb-2023)
Filesystem at
/dev/sda3 is mounted on /; on-line resizing required
old_desc_blocks
= 25, new_desc_blocks = 62
The filesystem on
/dev/sda3 is now 129946363 (4k) blocks long.