將VM關機,並將20G磁盤擴容爲40Gnode
fdisk -l
linux
能夠看到sda已經擴容到40G,但實際只分配了20Gshell
fdisk /dev/sda
centos
[root@k8s-node01 ~]# fdisk /dev/sda Welcome to fdisk (util-linux 2.23.2). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Command (m for help): p Disk /dev/sda: 42.9 GB, 42949672960 bytes, 83886080 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: 0x00013140 Device Boot Start End Blocks Id System /dev/sda1 * 2048 411647 204800 83 Linux /dev/sda2 411648 41943039 20765696 8e Linux LVM Command (m for help): n Partition type: p primary (2 primary, 0 extended, 2 free) e extended Select (default p): p Partition number (3,4, default 3): 3 First sector (41943040-83886079, default 41943040): Using default value 41943040 Last sector, +sectors or +size{K,M,G} (41943040-83886079, default 83886079): Using default value 83886079 Partition 3 of type Linux and of size 20 GiB is set Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. WARNING: Re-reading the partition table failed with error 16: Device or resource busy. The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8) Syncing disks.
[root@k8s-node01 ~]# fdisk /dev/sda Welcome to fdisk (util-linux 2.23.2). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Command (m for help): t Partition number (1-3, default 3): 3 Hex code (type L to list all codes): 8e Changed type of partition 'Linux' to 'Linux LVM' Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. WARNING: Re-reading the partition table failed with error 16: Device or resource busy. The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8) Syncing disks.
reboot
app
[root@k8s-node01 ~]# lvm lvm> pvcreate /dev/sda3 Physical volume "/dev/sda3" successfully created. lvm> vgextend centos /dev/sda3 Volume group "centos" successfully extended lvm> lvextend -L +19G /dev/mapper/centos-root Size of logical volume centos/root changed from 19.30 GiB (4941 extents) to 38.30 GiB (9805 extents). Logical volume centos/root successfully resized. lvm> pvdisplay --- Physical volume --- PV Name /dev/sda2 VG Name centos PV Size 19.80 GiB / not usable 3.00 MiB Allocatable yes (but full) PE Size 4.00 MiB Total PE 5069 Free PE 0 Allocated PE 5069 PV UUID VuaN5u-jbeg-Qrxt-iu2R-9WdZ-RYhg-OZaPHO --- Physical volume --- PV Name /dev/sda3 VG Name centos PV Size 20.00 GiB / not usable 4.00 MiB Allocatable yes PE Size 4.00 MiB Total PE 5119 Free PE 255 Allocated PE 4864 PV UUID Z4giaI-h4f3-PeU0-AExT-C0p7-vAdR-wCyXqL lvm> quit
resize2fs /dev/mapper/centos-root
ide
報錯,xfs文件系統的擴容須要使用下面的命令ui
xfs_growfs /dev/mapper/centos-root
操作系統
df -h
code
擴容完成blog