CentOS LVM磁盘扩容

本文提供了一套详细的步骤指南,用于在Exsi5.1环境下增加虚拟机磁盘空间,并通过LVM进行空间管理和分区操作。包括删除虚拟机快照、调整虚拟机磁盘大小、创建新分区、格式化、创建PV、VG和LV,以及扩展逻辑卷等关键步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一、增加虚拟机空间配置

 

1.删除虚拟机系统快照,有快照的虚拟机是不能调整磁盘大小的。

2.在exsi5.1主机下,选中虚拟机,右键编辑设置,打开虚拟机属性设置,调整磁盘大小。

3.重新启动虚拟机,进入查看新的硬盘情况:fdisk -l

 

二、调整虚拟机磁盘LVM

 

1.查看现有的硬盘分区(现在空间没有变大)

#df-h


2.对新增的硬盘空间做新增分区(硬盘数没有增加,增加的是空间)

#fdisk /dev/sda

 

WARNING:DOS-compatible mode is deprecated. It's strongly recommended to

         switch off the mode (command 'c') andchange display units to

         sectors (command 'u').

 

Command (m for help): n说明:新增分区

Command action

   e  extended

   p  primary partition (1-4)

p

Partition number (1-4): 3说明:新增分区号(1,2默认已经使用)

First cylinder(26109-65270, default 26109):

Using default value26109

Last cylinder,+cylinders or +size{K,M,G} (26109-65270, default 65270):

Using default value65270

 

Command (m for help): t说明:修改分区类型

Partition number (1-4): 3说明:指定分区类型对应的分区号

Hex code (type L to list codes): 8e说明:8elvm磁盘类型

Changed system typeof partition 3 to 8e (Linux LVM)

 

Command (m for help): p说明:打印分区表

 

Disk /dev/sda: 536.9GB, 536870912000 bytes

255 heads, 63sectors/track, 65270 cylinders

Units = cylinders of16065 * 512 = 8225280 bytes

Sector size(logical/physical): 512 bytes / 512 bytes

I/O size(minimum/optimal): 512 bytes / 512 bytes

Disk identifier:0x000432c6

 

   Device Boot      Start         End      Blocks  Id  System

/dev/sda1   *          1          64      512000  83  Linux

Partition 1 does notend on cylinder boundary.

/dev/sda2              64       26109  209202176   8e  Linux LVM

/dev/sda3           26109       65270  314566075   8e  Linux LVM

 

 

Command (m for help): w说明:退出

The partition tablehas been altered!

 

Calling ioctl() tore-read partition table.

 

WARNING: Re-reading the partition table failed with error 16: 设备或资源忙.

The kernel stilluses the old table. The new table will be used at

the next reboot orafter you run partprobe(8) or kpartx(8)

Syncing disks.

 

3.重启系统

#reboot

 

4.查看硬盘情况(核对刚才所做的分区操作是否保存成功)

#fdisk -l /dev/sda

 

5.查看当前分区的类型

#df -T /dev/sda1 说明:查看当前的主分区类型

 

6.创建文件系统在新的磁盘上

#mkfs.ext4/dev/sda3说明:ext4为你查看到的文件系统类型(ext2、ext3、ext4等)


7.创建PV(pv组成vg,vg组成lv)

#pvcreate/dev/sda3

#pvscan


新增加PV尚未加入VG组

 

8.将新增加的PV加入VG组

#vgextend VolGroup /dev/sda3

 

9.将VG组中的空闲空间划出到/home分区所在的LV

#lvextend -L +250G /dev/mapper/VolGroup-lv_home


10.使用resizefs2命令重新加载逻辑卷的大小才能生效

#resize2fs/dev/mapper/VolGroup-lv_home


这个过程需要花费一些时间。


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值