[rhel6.5]在线根分区卷组扩展

  • 实验环境

    操作系统类型 rhel6.5
    KVM类型的虚拟机

  • 必须要注意的一点是,根分区必须是使用可扩展的LVM卷组的方式进行挂载的

  • 使用命令df -h进行查看
[root@server6 ~]# df -h
Filesystem                    Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root   18G  9.4G  7.1G  57% /
tmpfs                         487M     0  487M   0% /dev/shm
/dev/vda1                     485M   33M  427M   8% /boot

这里写图片描述

  • 首先需要添加一块硬盘
    这里写图片描述

这里写图片描述

  • 使用命令查看新增加的硬盘,大小为8G;
[root@server6 ~]# fdisk  -l

这里写图片描述

  • 重点内容
  • 执行划分分区的命令,需要调整类型为8e
[root@server6 ~]# fdisk  -cu /dev/vdc 
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0xadcf4a9d.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First sector (2048-16777215, default 2048): 
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-16777215, default 16777215): 
Using default value 16777215

Command (m for help): t
Selected partition 1
Hex code (type L to list codes): 8e
Changed system type of partition 1 to 8e (Linux LVM)

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
  • 通知内核重新读取分区表
[root@server6 ~]# partx /dev/vdc
# 1:      2048- 16777215 ( 16775168 sectors,   8588 MB)
# 2:         0-       -1 (        0 sectors,      0 MB)
# 3:         0-       -1 (        0 sectors,      0 MB)
# 4:         0-       -1 (        0 sectors,      0 MB)
  • 首先制作’Physical Volume’
[root@server6 ~]# pvcreate /dev/vdc1 
  Physical volume "/dev/vdc1" successfully created
  • 使用命令pvs进行查看
    这里写图片描述
  • 将制作好的加入到卷组里面
[root@server6 ~]# vgextend VolGroup /dev/vdc1 
  Volume group "VolGroup" successfully extended
  • 通过命令vgs查看卷组的大小改变
    这里写图片描述
  • 扩展逻辑卷组边界
[root@server6 ~]# lvextend -L +8G /dev/VolGroup/lv_root 
  Extending logical volume lv_root to 25.61 GiB
  Insufficient free space: 2048 extents needed, but only 2047 available
[root@server6 ~]# lvextend -l +2047 /dev/VolGroup/lv_root 
  Extending logical volume lv_root to 25.60 GiB
  Logical volume lv_root successfully resized
  • 执行逻辑卷组的边界扩展
[root@server6 ~]# resize2fs /dev/VolGroup/lv_root
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/VolGroup/lv_root is mounted on /; on-line resizing required
old desc_blocks = 2, new_desc_blocks = 2
Performing an on-line resize of /dev/VolGroup/lv_root to 6711296 (4k) blocks.
The filesystem on /dev/VolGroup/lv_root is now 6711296 blocks long.
  • 通过df -h来查看最后结果的改变
[root@server6 ~]# df -h
Filesystem                    Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root   26G  9.4G   15G  40% /
tmpfs                         487M     0  487M   0% /dev/shm
/dev/vda1                     485M   33M  427M   8% /boot
  • 前后大小进行对比的截图
    这里写图片描述
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值