阿里云磁盘在线扩容踩坑(ubuntu)

问题:

阿里云购买磁盘在线扩容10GB之后 df -h 显示:

root@ushow-basic-component:~# df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            7.9G     0  7.9G   0% /dev
tmpfs           1.6G  3.7M  1.6G   1% /run
/dev/vda1        30G   26G  2.2G  93% /
tmpfs           7.9G     0  7.9G   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           7.9G     0  7.9G   0% /sys/fs/cgroup
tmpfs           1.6G     0  1.6G   0% /run/user/0
/dev/vdb1        20G   17G  2.4G  88% /root/.jenkins/workspace

磁盘容量没有扩大。dfisk -lu 显示磁盘容量为30G

root@ushow-basic-component:~# fdisk -lu
Disk /dev/vda: 30 GiB, 32212254720 bytes, 62914560 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: 0x77ba45a4
Device     Boot Start      End  Sectors Size Id Type
/dev/vda1  *     2048 62912511 62910464  30G 83 Linux
Disk /dev/vdb: 30 GiB, 32212254720 bytes, 62914560 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: 0xa9dd68b5
Device     Boot Start      End  Sectors Size Id Type
/dev/vdb1        2048 41943039 41940992  20G 83 Linux

解决方案

1、安装apt install -y cloud-utils-growpart
2、自适应分区扩容(注意数字前的空格 1:表示为第一个分区扩容) growpart /dev/vdb 1
3、重设分区大小 resize2fs /dev/vdb1
df -h查看结果:磁盘扩容成功
root@ushow-basic-component:~# df -h
Filesystem      Size  Used Avail Use% Mounted on
udev            7.9G     0  7.9G   0% /dev
tmpfs           1.6G  3.7M  1.6G   1% /run
/dev/vda1        30G   26G  2.2G  93% /
tmpfs           7.9G     0  7.9G   0% /dev/shm
tmpfs           5.0M     0  5.0M   0% /run/lock
tmpfs           7.9G     0  7.9G   0% /sys/fs/cgroup
tmpfs           1.6G     0  1.6G   0% /run/user/0
/dev/vdb1        30G   17G   12G  59% /root/.jenkins/workspace

你可能感兴趣的:(阿里云磁盘在线扩容踩坑(ubuntu))