[Linux服务器] 虚拟机Linux扩容

747 0
Honkers 2025-8-7 02:55:35 来自手机 | 显示全部楼层 |阅读模式
  1. 查看初始空间
  2. 查看分区

扩容:
1、磁盘分区
[root@ecs-7837 ~]# fdisk /dev/sda

WARNING: DOS-compatible mode is deprecated. It’s strongly recommended to
switch off the mode (command ‘c’) and change display units to
sectors (command ‘u’).

Command (m for help): n —新增分区
Command action
e extended
p primary partition (1-4)
p —P表示主分区
Partition number (1-4): 3 ----分区盘序号
First cylinder (1-166440, default 1): 83221 —分区开始序号
Last cylinder, +cylinders or +size{K,M,G} (83221-166440, default 166440): —直接回车
Using default value 166440

Command (m for help): t -----改变分区格式
Partition number (1-4): 3
Hex code (type L to list codes): 8e -----分区为lvm格式
Changed system type of partition 3 to 8e (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.

2.可以看到,新增的40G已划分成/dev/sda3了

这一步完成后最好重启一下服务器。

3、添加新LVM到已有的LVM组
1)pvcreate /dev/sda3

2)查看vg name
命令 vgdisplay

3)将pv加入到vg卷组
[root@ecs-7837 ~]# vgextend centos /dev/sda3


linux磁盘挂载和扩容。
4)查看 Free PE/Size 大小,这里为4863

5)查看根目录的lv名称

6)扩容lv
[root@ecs-7837 ~]# lvextend -l +10239 /dev/VolGroup/lv_root
lvextend指令用于在线扩展逻辑卷的空间大小,而不中断应用程序对逻辑卷的访问。其后有两个选项
选项 说明
-L 指定逻辑卷的大小,单位为“kKmMgGtT”字节,也就是Size
-l 指定逻辑卷的大小,单位为PE数

4、扩容文件系统
以上只是卷扩容了,还要对文件系统实现真正扩容

CentOS 6 下执行:
[root@ecs-7837 ~]# resize2fs /dev/VolGroup/lv_root

CentOS 7 下执行:
[root@ecs-7837 ~]# xfs_growfs /dev/VolGroup/lv_root

5、查看磁盘空间是否扩容

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

×
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

中国红客联盟公众号

联系站长QQ:5520533

admin@chnhonker.com
Copyright © 2001-2026 Discuz Team. Powered by Discuz! X3.5 ( 粤ICP备13060014号 )|天天打卡 本站已运行