怎样给centos系统扩展磁盘分区的实现方法
发表于:2026-11-01 作者:千家信息网编辑
千家信息网最后更新 2026年11月01日,问题/故障/场景/需求eve-ng的虚拟机ova的硬盘只有38G,需要增加空间,在vmware直接扩展硬盘后,重启系统,使用fdisk -l可以看到硬盘扩大了,但文件系统并没有扩大,还需要将这些新增的
千家信息网最后更新 2026年11月01日怎样给centos系统扩展磁盘分区的实现方法
问题/故障/场景/需求
eve-ng的虚拟机ova的硬盘只有38G,需要增加空间,在vmware直接扩展硬盘后,重启系统,使用fdisk -l可以看到硬盘扩大了,但文件系统并没有扩大,还需要将这些新增的空间扩展分配到某个文件系统才行。下面记录了整个扩展过程
解决方法/步骤
在VM里扩大磁盘到250G重启系统后,查看当前的文件系统的情况
root@eve-ng:~# df -hFilesystem Size Used Avail Use% Mounted onudev 7.9G 0 7.9G 0% /devtmpfs 1.6G 19M 1.6G 2% /run/dev/mapper/eve--ng--vg-root 38G 13G 23G 36% /tmpfs 7.9G 0 7.9G 0% /dev/shmtmpfs 5.0M 0 5.0M 0% /run/locktmpfs 7.9G 0 7.9G 0% /sys/fs/cgroup/dev/sda1 472M 83M 365M 19% /bootroot@eve-ng:~# fdisk -l...省略部分内容Disk /dev/sda: 250 GiB, 268435456000 bytes, 524288000 sectors //可以看到已经有250G了Units: sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisklabel type: dosDisk identifier: 0x3e3ca055Device Boot Start End Sectors Size Id Type/dev/sda1 * 2048 999423 997376 487M 83 Linux/dev/sda2 1001470 83884031 82882562 39.5G 5 Extended/dev/sda5 1001472 83884031 82882560 39.5G 8e Linux LVMDisk /dev/mapper/eve--ng--vg-root: 38.6 GiB, 41406169088 bytes, 80871424 sectorsUnits: sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk /dev/mapper/eve--ng--vg-swap_1: 980 MiB, 1027604480 bytes, 2007040 sectorsUnits: sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytes//下面执行分区root@eve-ng:~# fdisk /dev/sdaWelcome to fdisk (util-linux 2.27.1).Changes will remain in memory only, until you decide to write them.Be careful before using the write command.Command (m for help): nPartition type p primary (1 primary, 1 extended, 2 free) l logical (numbered from 5)Select (default p): pPartition number (3,4, default 3): 3First sector (999424-524287999, default 999424): 83884032 //注意,这里是之前分配的最后一块(sda5 end)加一(83884031+1)Last sector, +sectors or +size{K,M,G,T,P} (83884032-524287999, default 524287999): //注意看这是不是最后一块Created a new partition 3 of type 'Linux' and of size 210 GiB.Command (m for help): tPartition number (1-3,5, default 5): 3 3Partition type (type L to list all types): 8eChanged type of partition 'Linux' to 'Linux LVM'.Command (m for help): wThe partition table has been altered.Calling ioctl() to re-read partition table.Re-reading the partition table failed.: Device or resource busyThe 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).root@eve-ng:~# rebootroot@eve-ng:~# pvcreate /dev/sda3 Physical volume "/dev/sda3" successfully createdroot@eve-ng:~# vgdisplay --- Volume group --- VG Name eve-ng-vg System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 3 VG Access read/write VG Status resizable MAX LV 0 Cur LV 2 Open LV 2 Max PV 0 Cur PV 1 Act PV 1 VG Size 39.52 GiB PE Size 4.00 MiB Total PE 10117 Alloc PE / Size 10117 / 39.52 GiB Free PE / Size 0 / 0 VG UUID EvwUbc-nfsg-dHqA-znxB-U3gv-V782-Q8ZxkIroot@eve-ng:~# vgextend eve-ng-vg /dev/sda3 Volume group "eve-ng-vg" successfully extendedroot@eve-ng:~# vgdisplay --- Volume group --- VG Name eve-ng-vg System ID Format lvm2 Metadata Areas 2 Metadata Sequence No 4 VG Access read/write VG Status resizable MAX LV 0 Cur LV 2 Open LV 2 Max PV 0 Cur PV 2 Act PV 2 VG Size 249.52 GiB PE Size 4.00 MiB Total PE 63877 Alloc PE / Size 10117 / 39.52 GiB Free PE / Size 53760 / 210.00 GiB VG UUID EvwUbc-nfsg-dHqA-znxB-U3gv-V782-Q8ZxkIroot@eve-ng:~# lvdisplay --- Logical volume --- LV Path /dev/eve-ng-vg/root LV Name root VG Name eve-ng-vg LV UUID ktUpR0-VpqS-rJJv-a1FC-u6Gd-U8yN-2WYQ53 LV Write Access read/write LV Creation host, time eve-ng, 2018-03-21 02:25:21 +0200 LV Status available # open 1 LV Size 38.56 GiB Current LE 9872 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:0//扩展逻辑卷root@eve-ng:~# lvextend -l +100%FREE /dev/eve-ng-vg/root Size of logical volume eve-ng-vg/root changed from 38.56 GiB (9872 extents) to 248.56 GiB (63632 extents). Logical volume root successfully resized.root@eve-ng:~# df -hFilesystem Size Used Avail Use% Mounted onudev 7.9G 0 7.9G 0% /devtmpfs 1.6G 19M 1.6G 2% /run/dev/mapper/eve--ng--vg-root 38G 13G 23G 36% /tmpfs 7.9G 0 7.9G 0% /dev/shmtmpfs 5.0M 0 5.0M 0% /run/locktmpfs 7.9G 0 7.9G 0% /sys/fs/cgroup/dev/sda1 472M 83M 365M 19% /boot//在线扩容,要先查看当前的文件系统的类型,可以通过cat /etc/fstab来查看root@eve-ng:~# resize2fs /dev/eve-ng-vg/rootresize2fs 1.42.13 (17-May-2015)Filesystem at /dev/eve-ng-vg/root is mounted on /; on-line resizing requiredold_desc_blocks = 3, new_desc_blocks = 16The filesystem on /dev/eve-ng-vg/root is now 65159168 (4k) blocks long.root@eve-ng:~# df -hFilesystem Size Used Avail Use% Mounted onudev 7.9G 0 7.9G 0% /devtmpfs 1.6G 19M 1.6G 2% /run/dev/mapper/eve--ng--vg-root 245G 13G 222G 6% /tmpfs 7.9G 0 7.9G 0% /dev/shmtmpfs 5.0M 0 5.0M 0% /run/locktmpfs 7.9G 0 7.9G 0% /sys/fs/cgroup/dev/sda1 472M 83M 365M 19% /boot参考
在线扩容
使用 resize2fs或xfs_growfs 对挂载目录在线扩容
- resize2fs 针对文件系统ext2 ext3 ext4
- xfs_growfs 针对文件系统xfs
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。
系统
文件
硬盘
在线
内容
空间
分配
方法
磁盘
只有
可以通过
场景
就是
情况
故障
步骤
目录
类型
过程
这是
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
广东猪兼强互联网科技有限公司
互联网科技官网
网络科技有限互联网
广州互联网科技公司
美国互联网科技
为想互联网科技
电子科技大学互联网
互联网科技公司介绍
成都玖崟互联网科技有限公司乐商圈怎么样
互联网科技公司需要的职位
南平创想时代互联网科技有限公司
阿大互联网科技有限公司
互联网科技产业特征
广州市恰铎互联网科技有限公司
南博望互联网科技有限公司
每天都有哪些好的互联网科技
互联网营销推广黑科技
西安有哪些互联网高科技企业
互联网科技接地气
中国互联网公司的科技投入
咖啡豆
云信互联网科技有限公司
科技股互联网
互联网是不是新科技
智能科技公司是互联网公司吗
互联网的科技创新
互联网科技创新服务
广州新华互联网科技学校电竞方面
互联网科技数字货币
亚光科技低轨卫星互联网