本次扩容的目的是要扩展 / 的整体容量,具体操作如下:

1、首先查看是否存在未分配的磁盘

[root@NH-Test-44 ~]# fdisk -l

Disk /dev/vda: 53.7 GB, 53687091200 bytes
16 heads, 63 sectors/track, 104025 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00020122

Device Boot Start End Blocks Id System
/dev/vda1 * 3 409 204800 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/vda2 409 104023 52221760 8e Linux LVM
Partition 2 does not end on cylinder boundary.

Disk /dev/vdb: 10.7 GB, 10737418240 bytes  //大概是这样子,实际上这里已经被格式化了
16 heads, 63 sectors/track, 20805 cylinders
Units = cylinders of 1008 * 512 = 516096 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

2、格式化成lvm特定的8e格式

[root@localhost ~]# fdisk /dev/vdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0xb86ae868.
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)

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
Partition number (1-4): 1
First cylinder (1-145634, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-145634, default 145634):
Using default value 145634

Command (m for help): t   //注意这步的操作
Selected partition 1
Hex code (type L to list codes): 8e          //写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.

WARNING: Re-reading the partition table failed with error 22: Invalid argument.
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.

3、格式化成pv
[root@localhost ~]# pvcreate /dev/vdb1
Physical volume "/dev/vdb1" successfully created

[root@localhost ~]# vgdisplay
--- Volume group ---
VG Name vmvg
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 9.80 GiB
PE Size 4.00 MiB
Total PE 2509
Alloc PE / Size 2509 / 9.80 GiB
Free PE / Size 0 / 0
VG UUID feom8p-Nh5i-wu2E-PkuJ-8uTb-lkNv-r8zUHm

4、vg扩展
[root@localhost ~]# vgextend vmvg /dev/vdb1
Volume group "vmvg" successfully extended
[root@localhost ~]# vgdisplay
--- Volume group ---
VG Name vmvg
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 79.80 GiB
PE Size 4.00 MiB
Total PE 20428
Alloc PE / Size 2509 / 9.80 GiB
Free PE / Size 17919 / 70.00 GiB
VG UUID feom8p-Nh5i-wu2E-PkuJ-8uTb-lkNv-r8zUHm

5、还要继续操作如下2步,不然看不到磁盘的增加

[root@NH-Test-44 ~]# df -h
Filesystem                 Size  Used  Avail  Use%  Mounted on
/dev/mapper/vmvg-root  //   
                                45G   12G   32G    27%         /
tmpfs                        3.9G    0      3.9G   0%        /dev/shm
/dev/vda1                  190M  88M   93M   49%       /boot

lvextend -l +100%FREE /dev/mapper/vmvg-root   //扩容对应的lvm,在这里目录 / 对应的lvm卷名字为/dev/mapper/vmvg-root

resize2fs -p /dev/mapper/vmvg-root  //文件系统扩容(占满LV)

再用df -h查看磁盘容量就会发现增大了很多。

lvm的vg扩容的更多相关文章

  1. centos Linux下磁盘管理 parted,df ,du,fdisk,partprobe,mkfs.ext4,mount,/etc/fstab,fsck,e2fsck,mk2efs,tmpfs ,nr_inodes, LVM,传统方式扩容文件系统 第七节课

    centos Linux下磁盘管理   parted,df ,du,fdisk,partprobe,mkfs.ext4,mount,/etc/fstab,fsck,e2fsck,mk2efs,tmpf ...

  2. [转] LVM分区在线扩容

    [转] LVM分区在线扩容 在线扩容的这台服务器,LV分区格式为xfs,原大小1.2TB.增加了一块硬盘,大小为1.8TB. fdisk /dev/cciss/c0d1 # 创建分区,并指定分区类型为 ...

  3. LVM 认知与扩容操作

    继上次 "Linux系统如何迁移至LVM磁盘"反响不错,近三百的访问量吧.这次想续写点东西,主要讲的是"LVM认知和扩容操作".因为网上大多数不准确,可能作者也 ...

  4. LVM 磁盘分区扩容

    前提:将磁盘中未分区磁盘进行分区操作 https://www.cnblogs.com/guoxiangyue/p/10033367.html 然后进行vg扩容 pvcreate /dev/sdc lv ...

  5. LVM管理及扩容(转)

    LVM磁盘管理 一、LVM简介... 1 二、 LVM基本术语... 2 三、 安装LVM... 3 四、 创建和管理LVM... 4 2、 创建PV.. 6 3、 创建VG.. 7 4、 创建LV. ...

  6. LVM逻辑卷扩容、缩容

    LVM就是动态卷管理,可以将多个硬盘和硬盘分区做成一个逻辑卷,并把这个逻辑卷作为一个整体来统一管理,动态对分区进行扩缩空间大小,安全快捷方便管理. 后期出现问题恢复数据也比较麻烦. 概念: ①PE(P ...

  7. 磁盘管理 lvm减容扩容

    参考https://blog.csdn.net/wk022/article/details/50543922 新增磁盘/dev/sdb fdisk /dev/sdb  分两个分区  (n p 1 /n ...

  8. centos7下LVM挂载和扩容

    说明:此操作在centos7下进行,如果是centos6发行版,需要注意格式化LV的文件系统类型(centos7.0开始默认文件系统是xfs,centos6是ext4).最后一步写入系统的类型,其中文 ...

  9. CentOS LVM 卷在线扩容

    场景: vmware 虚拟机,装了CentOS  ,更改了虚拟机磁盘的大小:从200G,扩展到320G,可以参考本文写了步骤. 1. 在线扫描虚拟机SCSI新增的容量 # for i in `find ...

随机推荐

  1. (2)java程序走一遍工作流activiti

    工作流从流程定义到创建一个流程实例完成执行步骤 使用activi-designer创建一个流程定义(.bpmn结尾的文件) 将定义好的流程定义和生成的png图片通过RepositoryService( ...

  2. git命令实战之血泪记录

    注意: 本文章所写所有命令均在Git命令行窗口执行!非cmd窗口! 打开git命令行窗口步骤为:到项目根目录下执行bash命令行操作:右键点击Git Bash Here菜单,打开git命令窗口,不是c ...

  3. std::vector 源代码

    vector身为一个动态数组,每次以空间不够的时候会以2倍的倍数增加,而且每次扩充的时候分为3部,分配内存,拷贝数据,释放内存 vector内部有两个成员变量,begin,finish ,endcat ...

  4. uml系列(八)——部署图与构件图

    之前说了uml的设计图,现在说一下uml的最后两种图:构件图.部署图.这两种图之所以放在一起是因为它们都是软件的实现图. 构件图           构件图是描述一组构件之间的组织与依赖关系的模型.那 ...

  5. runtime ---- iOS

    1.runtime是什么?runtime是一套底层的C语言的API(包括C语言数据类型,C语言函数) 实际上平时我们写的OC代码底层都是基于runtime,实际上也就是最后都转成了runtime代码 ...

  6. (三) Angular2项目框架搭建心得

    前言: 在哪看到过angular程序员被React程序员鄙视,略显尴尬,确实Angular挺值得被调侃的,在1.*版本存在的几个性能问题,性能优化的"潜规则"贼多,以及从1.*到2 ...

  7. jenkins coding.net webhook plugin

    开源地址: https://github.com/yuzd/coding.net =========================================================== ...

  8. Python学习一:Python简介

    Python简介: Python是目前广泛使用的一门动态语言,类似Java,源代码必须首先由编译器转换成字节码(byte code),然后再由解释器来执行字节码.与Java不同的是,Python的编译 ...

  9. Angularjs学习笔记《一》

    开始慢慢的学习新的框架,Angularjs,其中原理不知深浅,但有例子练习,慢慢熟知.看的英文文档一点点翻译学习. 第一个例子,写一个增加,选中,删除的例子, 首先要引进所用的框架源码,这样引进,下面 ...

  10. JS实例——间歇循环滚动

    间歇滚动:滚动一行后,延迟2秒后继续滚动 具体实现代码如下: <!doctype html> <html lang="en"> <head> & ...