您的位置:首页 > 其它

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

2018-02-23 17:16 239 查看
实验环境

操作系统类型
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.
4000

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


前后大小进行对比的截图

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息