Linux服务器由于应用变更或需求的缘故,有可能出现分区空间不足的情况,此时往往需要进行扩容(要增加分区的空间),而采用LVM的好处就是可以在不需停机的情况下可以方便地调整各个分区大小。如下所示,分区/u05由于备份集保留的时间调整,RMAN备份时出现空间不足的情况,如下所示,

[root@getlnx01 ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
                       97G   37G   55G  41% /
/dev/mapper/VolGroup01-LogVol00
                       79G   33G   43G  44% /u01
/dev/mapper/VolGroup02-LogVol00
                      197G  168G   19G  90% /u02
/dev/mapper/VolGroup03-LogVol00
                      197G  127G   60G  68% /u03
/dev/mapper/VolGroup04-LogVol00
                      138G  126G  5.6G  96% /u04
/dev/mapper/VolGroup05-LogVol00
                      178G  104G   65G  62% /u05
/dev/sda1              99M   23M   71M  25% /boot
tmpfs                  12G     0   12G   0% /dev/shm
[root@getlnx01 ~]# vgscan
  Reading all physical volumes.  This may take a while...
  Found volume group "VolGroup05" using metadata type lvm2
  Found volume group "VolGroup04" using metadata type lvm2
  Found volume group "VolGroup03" using metadata type lvm2
  Found volume group "VolGroup02" using metadata type lvm2
  Found volume group "VolGroup01" using metadata type lvm2
  Found volume group "VolGroup00" using metadata type lvm2
[root@getlnx01 ~]# 

我在添加了一块虚拟磁盘后(虚拟机),此时使用fdisk -l查不到刚刚添加的新磁盘,此时需要运行命令echo "- - -" > /sys/class/scsi_host/host0/scan重新扫描该接口下的SCSI磁盘设备。

关于该命令它是通过/sys下的属性设置运行SCSI扫描。echo "- - -" > scan "- - -"代表channel,target和LUN编号。以上命令会导致hba4下所有channel,target以及可见LUN被扫描。

 
[root@getlnx01 ~]# echo "- - -" > /sys/class/scsi_host/host0/scan
[root@getlnx01 ~]# fdisk -l
 
Disk /dev/sda: 55.8 GB, 55834574848 bytes
255 heads, 63 sectors/track, 6788 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
 
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1          13      104391   83  Linux
/dev/sda2              14        6788    54420187+  8e  Linux LVM
 
Disk /dev/sdb: 85.8 GB, 85899345920 bytes
255 heads, 63 sectors/track, 10443 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
 
   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1       10443    83883366    5  Extended
/dev/sdb5               1       10443    83883334+  83  Linux
 
Disk /dev/sdd: 214.7 GB, 214748364800 bytes
255 heads, 63 sectors/track, 26108 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
 
   Device Boot      Start         End      Blocks   Id  System
/dev/sdd1               1       26108   209712478+   5  Extended
/dev/sdd5               1       26108   209712447   83  Linux
 
Disk /dev/sdc: 214.7 GB, 214748364800 bytes
255 heads, 63 sectors/track, 26108 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
 
   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1               1       26108   209712478+   5  Extended
/dev/sdc5               1       26108   209712447   83  Linux
 
Disk /dev/sdf: 64.4 GB, 64424509440 bytes
255 heads, 63 sectors/track, 7832 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
 
   Device Boot      Start         End      Blocks   Id  System
/dev/sdf1               1        7832    62910508+   5  Extended
/dev/sdf5               1        7832    62910477   83  Linux
 
Disk /dev/sde: 150.3 GB, 150323855360 bytes
255 heads, 63 sectors/track, 18275 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
 
   Device Boot      Start         End      Blocks   Id  System
/dev/sde1               1       18275   146793906    5  Extended
/dev/sde5               1       18275   146793874+  83  Linux
 
Disk /dev/sdg: 193.2 GB, 193273528320 bytes
255 heads, 63 sectors/track, 23497 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
 
   Device Boot      Start         End      Blocks   Id  System
/dev/sdg1               1       23497   188739621    5  Extended
/dev/sdg5               1       23497   188739589+  83  Linux
 
Disk /dev/dm-0: 107.2 GB, 107206410240 bytes
255 heads, 63 sectors/track, 13033 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
 
Disk /dev/dm-0 doesn't contain a valid partition table
 
Disk /dev/dm-1: 12.8 GB, 12884901888 bytes
255 heads, 63 sectors/track, 1566 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
 
Disk /dev/dm-1 doesn't contain a valid partition table
 
Disk /dev/sdh: 85.8 GB, 85899345920 bytes
255 heads, 63 sectors/track, 10443 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
 
Disk /dev/sdh doesn't contain a valid partition table

1:格式化分区

格式化磁盘设备/dev/sdh, 下面是采用逻辑扩展分区。关于格式分区时是否一定要修改分区类型为8e(LVM格式),我查了一些资料,这个不是必须的。鸟哥的Linux私房菜里面的原话为:“那个8e的出现会导致system变成Linux LMV! 其实没有设定为8e也没有关系,不过某些LMV的侦测指令可能会侦测不到该partition就是了”

[root@getlnx01 ~]# fdisk /dev/sdh
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.
 
 
The number of cylinders for this disk is set to 10443.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)
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)
e
Partition number (1-4): 1
First cylinder (1-10443, default 1): 
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-10443, default 10443): 
Using default value 10443
 
Command (m for help): w
The partition table has been altered!
 
Calling ioctl() to re-read partition table.
Syncing disks.
[root@getlnx01 ~]# fdisk /dev/sdh
 
The number of cylinders for this disk is set to 10443.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)
 
Command (m for help): p
 
Disk /dev/sdh: 85.8 GB, 85899345920 bytes
255 heads, 63 sectors/track, 10443 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
 
   Device Boot      Start         End      Blocks   Id  System
/dev/sdh1               1       10443    83883366    5  Extended
 
Command (m for help): n
Command action
   l   logical (5 or over)
   p   primary partition (1-4)
l
First cylinder (1-10443, default 1): 
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-10443, default 10443): 
Using default value 10443
 
Command (m for help): w
The partition table has been altered!
 
Calling ioctl() to re-read partition table.
Syncing disks.
[root@getlnx01 ~]# 
 

2:新建物理卷(PV)

[root@getlnx01 ~]# pvcreate /dev/sdh5
  Physical volume "/dev/sdh5" successfully created
[root@getlnx01 ~]# pvdisplay /dev/sdh5
  "/dev/sdh5" is a new physical volume of "80.00 GB"
  --- NEW Physical volume ---
  PV Name               /dev/sdh5
  VG Name               
  PV Size               80.00 GB
  Allocatable           NO
  PE Size (KByte)       0
  Total PE              0
  Free PE               0
  Allocated PE          0
  PV UUID               LgKUuj-UddY-AHHO-ewqX-1iF1-6HYN-N5EITM

3:扩展卷组(VG)

首先查看VG的详细信息,然后扩展VG

[root@getlnx01 ~]# vgdisplay VolGroup05
  --- Volume group ---
  VG Name               VolGroup05
  System ID             
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  2
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                1
  Open LV               1
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               179.97 GB
  PE Size               32.00 MB
  Total PE              5759
  Alloc PE / Size       5759 / 179.97 GB
  Free  PE / Size       0 / 0   
  VG UUID               UNFxZH-lAGM-vqF3-jtNK-yuKT-enUX-WwL7FQ
   
 
   
[root@getlnx01 ~]# vgextend VolGroup05 /dev/sdh5
  Volume group "VolGroup05" successfully extended
[root@getlnx01 ~]# vgdisplay VolGroup05
  --- Volume group ---
  VG Name               VolGroup05
  System ID             
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  3
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                1
  Open LV               1
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size               259.94 GB
  PE Size               32.00 MB
  Total PE              8318
  Alloc PE / Size       5759 / 179.97 GB
  Free  PE / Size       2559 / 79.97 GB
  VG UUID               UNFxZH-lAGM-vqF3-jtNK-yuKT-enUX-WwL7FQ
   
[root@getlnx01 ~]# 

4:处理文件系统

VG扩展后,/u05分区还不能实时增加空间,还需要使用resize2fs –p命令激活新增加的空间

 
[root@getlnx01 ~]# resize2fs -p  /dev/VolGroup05/LogVol00 
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/VolGroup05/LogVol00 is mounted on /u05; on-line resizing required
Performing an on-line resize of /dev/VolGroup05/LogVol00 to 68141056 (4k) blocks.
 
The filesystem on /dev/VolGroup05/LogVol00 is now 68141056 blocks long.
 
[root@getlnx01 ~]# 
[root@getlnx01 ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
                       97G   37G   55G  41% /
/dev/mapper/VolGroup01-LogVol00
                       79G   33G   43G  44% /u01
/dev/mapper/VolGroup02-LogVol00
                      197G  168G   19G  90% /u02
/dev/mapper/VolGroup03-LogVol00
                      197G  127G   60G  68% /u03
/dev/mapper/VolGroup04-LogVol00
                      138G  126G  5.6G  96% /u04
/dev/mapper/VolGroup05-LogVol00
                      256G  104G  140G  43% /u05
/dev/sda1              99M   23M   71M  25% /boot
tmpfs                  12G     0   12G   0% /dev/shm
[root@getlnx01 ~]# 

Linux LVM学习总结——创建卷组VG

Linux LVM学习总结——删除卷组VG

Linux LVM学习总结——扩展卷组VG

转载于:https://www.cnblogs.com/kerrycode/p/4651126.html

Linux LVM学习总结——扩展卷组VG相关推荐

  1. linux lvm分区教程,Linux LVM入门使用教程

    文章目录 [隐藏] LVM测试说明 准备磁盘分区 准备物理卷(PV) 准备卷组(VG) 创建逻辑卷(LV) 扩展一个LVM卷 缩减一个LVM卷 扩展一个卷组 逻辑卷管理LVM是一个多才多艺的硬盘系统工 ...

  2. LVM逻辑卷、卷组的新建及调整

    LVM逻辑卷 练习:关闭虚拟机,添加一场80G 的硬盘,划分3个主分区,1个扩展分区,3个逻辑分区,每个分区10G 传统分区的局限性:1)分区容量调整不方便 2)单个分区的总大小有限 LVM逻辑卷(L ...

  3. 通用线程: 学习 Linux LVM

    为什么80%的码农都做不了架构师?>>>    通用线程: 学习 Linux LVM "逻辑卷管理"为存储器管理带来的魔力 Daniel Robbins ( dr ...

  4. 学习 Linux LVM

    简介: 在本文中,Daniel 和我们一起分享了他将 cvs.gentoo.org 的 /home 文件系统转换成 LVM 逻辑卷的经历.在转换之后,当 cvs.gentoo.org 的 /home ...

  5. linux lvm 8e下继续划分分区,linux下LVM学习_逻辑卷管理

    一.LVM介绍 LVM是 Logical Volume Manager(逻辑卷管理)的简写,它是Linux环境下对磁盘分区进行管理的一种机制,通过LVM可以在不停机的情况下调整分区大小,提高了磁盘分区 ...

  6. linux系统下卷组管理,Linux LVM卷组管理

    Linux LVM卷组管理 由于传统的磁盘管理不能对磁盘进行磁盘管理,因此诞生了LVM技术,LVM技术最大的特点就是对磁盘进行动态管理. 由于LVM的逻辑卷的大小更改可以进行动态调整,且不会出现丢失数 ...

  7. Linux 物理卷(PV)、逻辑卷(LV)、卷组(VG)管理

    (一)相关概念 逻辑卷是使用逻辑卷组管理(Logic Volume Manager)创建出来的设备,如果要了解逻辑卷,那么首先需要了解逻辑卷管理中的一些概念. 物理卷(Physical Volume, ...

  8. Linux入门学习(六)—— 怎么更改文件的所有者、所属组?以及怎么更改系统创建的默认权限?

    引言:上期回顾(想要学习的童鞋可以点击看看) 关于文件的入门操作这是最后一个章节,如果是新手从第一章开始安装linux系统学习,到上一章学会修改文件的权限,那我相信之前的文章对你是所有帮助的.之前有介 ...

  9. Linux中卷组VG的缩小

    需求:Linux中实现卷组VG的缩小 实现步骤 1.将PV中指定卷组中移除 vgreduce cmpServer /dev/sdd 2.查看缩小后的卷组 vgdisplay

最新文章

  1. 通过Camera进行拍照
  2. 大型对冲基金正训练AI交易 5年后AI在量化中将成主流
  3. 【笔记】jstree插件的基本使用
  4. psp能装安卓软件吗_客户crm 软件能定制吗
  5. CentOS挂Windows的NFS备忘
  6. C++中指针与引用的区别
  7. win7桌面图片不显示缩略图问题
  8. Python字典二次开发实现稀疏矩阵表示与简单计算
  9. mysql 5.6 my.cnf配置文件_mysql 5.6 my.cnf 配置
  10. 抽象代数学习笔记三《群:对称性变换与对称性群》
  11. 硕士毕业论文页眉页脚页码设置
  12. 踩坑前端框架 - iview DatePicker 时间选择年月日时分秒
  13. 基于微信小程序的大学生心理健康测试设计与实现 .docx
  14. 二维占用栅格地图Occupancy grid maps
  15. Python从零到就业
  16. 关于wiretap库
  17. 安装ST LINK驱动后显示成功,但无法识别问题的解决办法之一
  18. AT89C52RC定时器T2
  19. 企业管理概论试题库【1】
  20. oracle 12c ins 13001,安装Oracle 12c Release 2报错:INS-13001

热门文章

  1. MySql默认编码所造成的乱码麻烦1.222
  2. My.Ioc 代码示例——避免循环依赖
  3. 消息(6)——WCF,构建简单的WCF服务,MTOM编码
  4. matplotlib plt.subplot
  5. 分隔和截断字符串, boost string algorithm library中的split和trim
  6. 在Myeclipse buildpath 加server lib (server runtime)
  7. oracle数据库升级失败,Oracle 11.2.0.1 rac 升级失败后,数据库降级方案(flashback database)...
  8. AUTOSAR从入门到精通100讲(八十五)-AUTOSAR基础篇之BswM
  9. matlab13节点线路模型,13节点配电网的建模与仿真.doc
  10. java rx.observable_Rxjava2 Observable的条件操作符详解及实例