增加我的 centos vm 的磁盘空间后(在 esxi 虚拟机管理程序中)
当我执行 fdsik 时
[root@sopiqecommerce ~]# fdisk -l
Disk /dev/sda: 504.7 GB, 504658657280 bytes, 985661440 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: 0x000bd0c1
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 2099199 1048576 83 Linux
/dev/sda2 2099200 985661439 491781120 8e Linux LVM
Disk /dev/mapper/centos-root: 241.7 GB, 241721933824 bytes, 472113152 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 /dev/mapper/centos-swap: 4160 MB, 4160749568 bytes, 8126464 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 /dev/mapper/centos-home: 21.5 GB, 21474836480 bytes, 41943040 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
当我执行 df -h 时:
[root@sopiqecommerce ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 226G 106G 120G 48% /
devtmpfs 2.9G 0 2.9G 0% /dev
tmpfs 2.9G 0 2.9G 0% /dev/shm
tmpfs 2.9G 8.8M 2.9G 1% /run
tmpfs 2.9G 0 2.9G 0% /sys/fs/cgroup
/dev/sda1 1014M 186M 829M 19% /boot
/dev/mapper/centos-home 20G 33M 20G 1% /home
tmpfs 581M 0 581M 0% /run/user/0
我使用 gparted 向磁盘添加了 200 GB
是否缺少任何配置来使用未分配的 200gb?
[更新]
当我执行 lvdisplay 时:
[root@sopiqecommerce ~]# lvdisplay
--- Logical volume ---
LV Path /dev/centos/swap
LV Name swap
VG Name centos
LV UUID S40JP2-OofD-BRls-TeFj-uP6g-aBuh-mjKHyP
LV Write Access read/write
LV Creation host, time sopiqecommerce, 2019-02-19 14:55:47 +0100
LV Status available
# open 2
LV Size <3.88 GiB
Current LE 992
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:1
--- Logical volume ---
LV Path /dev/centos/root
LV Name root
VG Name centos
LV UUID rHtm3b-0dqp-PXvF-OAaS-rLzR-TeW5-7E21cd
LV Write Access read/write
LV Creation host, time sopiqecommerce, 2019-02-19 14:55:47 +0100
LV Status available
# open 1
LV Size 225.12 GiB
Current LE 57631
Segments 4
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:0
--- Logical volume ---
LV Path /dev/centos/home
LV Name home
VG Name centos
LV UUID g33dwM-E1cZ-G6BM-2OP1-ilap-yS7k-ABU5Po
LV Write Access read/write
LV Creation host, time sopiqecommerce, 2019-02-23 13:22:22 +0100
LV Status available
# open 1
LV Size 20.00 GiB
Current LE 5120
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 8192
Block device 253:2
我应该执行lvextend -l+100%FREE /dev/mapper/centos-root
,来增加 /root 分区吗?
答案1
您很可能正在使用 LVM 磁盘,因此您也需要扩展逻辑卷。
您需要运行:
lvdisplay
找到要添加空间的逻辑卷,然后运行以下命令:
lvextend -l+100%FREE /dev/full/path/here
完成后,您还需要运行:
resize2fs /dev/full/path/here
df -h 现在应该显示正确的尺寸