一、添加硬盘,在线扫描出来

首先到虚拟机那里添加一块硬盘,注意必须是SCSI类型的硬盘。

扫描硬盘,不用重启操作系统的。

echo "- - -" > /sys/class/scsi_host/host0/scan

echo "- - -" > /sys/class/scsi_host/host1/scan

echo "- - -" > /sys/class/scsi_host/host2/scan

echo "- - -" > /sys/class/scsi_host/host3/scan

.......

echo "- - -" > /sys/class/scsi_host/hostn/scan

有几个host就扫描几次就可以了!记得修改host的编号。我经过测试发现,无论是虚拟机还是物理机,从远端存储分配一些物理卷给主机,主机上都可以直接用这个命令把新添加的硬盘识别出来。

然后再运行fdisk -l就能发现新添加的硬盘已经被系统识别了,查看系统日志/var/log/messages,发现对SCSI设备进行了一次重新扫描
注意:三个- – -号之间有空隔。

以下是我添加完硬盘以后执行的过程:

[root@con4test ~]# fdisk -l

Disk /dev/sda: 107.3 GB, 107374182400 bytes

255 heads, 63 sectors/track, 13054 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       13054  104751832+  8e  Linux LVM

[root@con4test ~]# echo "- - -" >/sys/class/scsi_host/host0/scan

[root@con4test ~]#

[root@con4test ~]# fdisk -l

Disk /dev/sda: 107.3 GB, 107374182400 bytes

255 heads, 63 sectors/track, 13054 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       13054  104751832+  8e  Linux LVM

Disk /dev/sdb: 53.6 GB, 53687091200 bytes

255 heads, 63 sectors/track, 6527 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdb doesn't contain a valid partition table

二、添加硬盘到原有分区

在RedHat 使用中,我们经常会碰到硬盘空间用完的问题。今天也是因为服务器硬盘空间用完,才用到这个增加硬盘,并加入LVM现有空间的操作。

详细内容见内文。

1.收集相关数据

执行如下命令:

[root@con4test ~]#vgs

/dev/hdc: open failed: No medium found

VG         #PV #LV #SN Attr   VSize VFree

VolGroup00   1   2   0wz--n- 99.88G    0

[root@con4test ~]# lvs-a -o +devices

/dev/hdc: open failed: No medium found

LV       VG         Attr  LSize   Origin Snap%  Move Log Copy%  Convert Devices

LogVol00 VolGroup00 -wi-ao 99.12G                                      /dev/sda2(0)

LogVol01 VolGroup00 -wi-ao 768.00M                                      /dev/sda2(3172)

2.新加硬盘初始化配置

执行如下命令:

[root@con4test ~]# fdisk-l

Disk /dev/sda: 107.3 GB, 107374182400 bytes

255 heads, 63 sectors/track, 13054cylinders

Units = cylinders of 16065 * 512 = 8225280bytes

Device Boot      Start         End      Blocks  Id  System

/dev/sda1  *           1          13      104391  83  Linux

/dev/sda2              14      13054   104751832+  8e Linux LVM

Disk/dev/sdb: 53.6 GB, 53687091200 bytes

255heads, 63 sectors/track, 6527 cylinders

Units= cylinders of 16065 * 512 = 8225280 bytes

 

Disk/dev/sdb doesn't contain a valid partition table

fdisk /dev/sdb

将硬盘分为一个分区。结果如下:

[root@con4test~]# fdisk -l

Disk /dev/sda: 107.3 GB, 107374182400 bytes

255 heads, 63 sectors/track, 13054cylinders

Units = cylinders of 16065 * 512 = 8225280bytes

Device Boot      Start         End      Blocks  Id  System

/dev/sda1  *           1          13      104391  83  Linux

/dev/sda2              14       13054  104751832+  8e  Linux LVM

Disk/dev/sdb: 53.6 GB, 53687091200 bytes

255heads, 63 sectors/track, 6527 cylinders

Units= cylinders of 16065 * 512 = 8225280 bytes

 

   Device Boot      Start         End      Blocks  Id  System

/dev/sdb1               1        6527   52428096   83  Linux

执行如下命令:

[root@con4test ~]# pvcreate /dev/sdb1

Physical volume "/dev/sdb1" successfully created

3.LVM配置命令详解

pvcreate  /dev/sdb1  #将sdb1创建为pv,可以先用pvdisplay查看情况

vgcreatevmax_bkup /dev/emcpowerk  /dev/emcpowerl   #VG创建

vgrenamevmax_bkup vmax_bkupvg   #VG重命名

lvcreate   -L 2.43T   -i 5   -I1024  -n  vmax_bkuplv   vmax_bkupvg

#LV创建,-L指定lv大小,-i指定条带化个数,-I指定条带化尺寸,-n指定lv名称

mkfs-t ext3  /dev/vmax_bkupvg/vmax_bkuplv

vgextend  VolGroup00  /dev/sdb1 #将sdb1加入到VolGroup00

lvextend –l  +100%FREE  /dev/VolGroup00/LogVol00  #扩展所有空余空间

resize2fs  –f /dev/VolGroup00/LogVol00

4.配置后的核实

执行如下命令:

[root@con4test ~]# vgs

VG         #PV #LV #SN Attr   VSize  VFree

VolGroup00   2  2   0 wz--n- 149.84G    0

[root@con4test ~]#lvs -a -o +devices

LV       VG         Attr  LSize   Origin Snap%  Move Log Copy%  Convert Devices

LogVol00 VolGroup00 -wi-ao 149.09G                                      /dev/sda2(0)

LogVol00 VolGroup00 -wi-ao 149.09G                                      /dev/sdb1(0)

LogVol01 VolGroup00 -wi-ao 768.00M                                      /dev/sda2(3172)

[root@con4test ~]#df -Th

Filesystem    Type   Size  Used Avail Use% Mounted on

/dev/mapper/VolGroup00-LogVol00

ext3    145G  97G   41G  71% /

/dev/sda1     ext3    99M   13M   82M 14% /boot

tmpfs       tmpfs    3.9G     0 3.9G   0% /dev/shm

本篇文章来源于 Linux公社网站(www.linuxidc.com)  原文链接:http://www.linuxidc.com/Linux/2010-04/25799.htm

常见错误:

[root@con4test ~]# vgextend volgroup00/dev/sdb1

/dev/hdc: open failed: No medium found

Volume group "volgroup00" not found

[root@con4test ~]# vgextend VolGroup00/dev/sdb1

Nophysical volume label read from /dev/sdb1

/dev/sdb1not identified as an existing physical volume

Unable to add physical volume '/dev/sdb1' to volume group 'VolGroup00'.

需要先创建pv

[root@con4test ~]# pvcreate /dev/sdb1

Physical volume "/dev/sdb1" successfully created

三.案例(EMC存储上的卷划分LVM详细过程)

pvcreate /dev/emcpowerk

Physical volume "/dev/emcpowerk" successfully created

bi-bkdb:/ # pvcreate /dev/emcpowerl

Physical volume "/dev/emcpowerl" successfully created

bi-bkdb:/ #

bi-bkdb:/ #

bi-bkdb:/ # pvcreate /dev/emcpowerm

Physical volume "/dev/emcpowerm" successfully created

bi-bkdb:/ # pvcreate /dev/emcpowern

Physical volume "/dev/emcpowern" successfully created

bi-bkdb:/ # pvcreate /dev/emcpowero

Physical volume "/dev/emcpowero" successfully created

bi-bkdb:/ #

bi-bkdb:/ #

bi-bkdb:/ # pvscan

PV/dev/emcpowerb   VG oraclevg        lvm2 [500.00 GiB / 0    free]

PV/dev/emcpowera   VG oraclevg        lvm2 [500.00 GiB / 0    free]

PV/dev/emcpowerc   VG oraclevg        lvm2 [500.00 GiB / 0    free]

PV/dev/emcpowerf   VG oraclevg        lvm2 [500.00 GiB / 0    free]

PV/dev/emcpowere   VG oraclevg        lvm2 [500.00 GiB / 0    free]

PV/dev/emcpowerd   VG oraclevg        lvm2 [500.00 GiB / 0    free]

PV/dev/emcpowerg   VG oraclevg        lvm2 [500.00 GiB / 0    free]

PV/dev/emcpowerj   VG oraclevg        lvm2 [500.00 GiB / 0    free]

PV/dev/emcpowerh   VG oraclevg        lvm2 [500.00 GiB / 0    free]

PV/dev/emcpoweri   VG oraclevg        lvm2 [500.00 GiB / 0    free]

PV/dev/emcpowerk                      lvm2 [500.00 GiB]

PV/dev/emcpowerl                      lvm2[500.00 GiB]

PV/dev/emcpowerm                      lvm2[500.00 GiB]

PV/dev/emcpowern                      lvm2[500.00 GiB]

PV/dev/emcpowero                      lvm2[500.00 GiB]

Total: 15 [7.32 TiB] / in use: 10 [4.88 TiB] / in no VG: 5 [2.44 TiB]

bi-bkdb:/ # vgcreate vmax_bkup/dev/emcpowerk  /dev/emcpowerl/dev/emcpowerm /dev/emcpowern /dev/emcpowero

Volume group "vmax_bkup" successfully created

bi-bkdb:/ #

bi-bkdb:/ #

bi-bkdb:/ # vgscan

Reading all physical volumes. This may take a while...

Found volume group "vmax_bkup" using metadata type lvm2

Found volume group "oraclevg" using metadata type lvm2

bi-bkdb:/ # vgrename vmax_bkup vmax_bkupvg

Volume group "vmax_bkup" successfully renamed to"vmax_bkupvg"

bi-bkdb:/ # vgs

VG          #PV #LV #SN Attr   VSize VFree

oraclevg     10   2   0wz--n- 4.88t    0

vmax_bkupvg   5   0   0wz--n- 2.44t 2.44t

bi-bkdb:/ # lvcreate -L  2.43T -i 5 -I 1024  -n vmax_bkuplv vmax_bkupvg

Rounding up size to full physical extent 2.43 TiB

Logical volume "vmax_bkuplv" created

bi-bkdb:/ # mkfs -t ext3 -c/dev/vmax_bkupvg/vmax_bkuplv

四.案例(redhat AS5的LVM在线扩充)

redhat AS5 LVM添加磁盘空间 实例

[root@virus_update /]# df -h
Filesystem           Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
2.9G 2.4G 396M 86% /
/dev/sda1 99M 11M 83M 12% /boot
tmpfs 1014M 0 1014M 0% /dev/shm
[root@virus_update /]# fdisk -l

Disk /dev/sda: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 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 652 5132767+ 8e Linux LVM

Disk /dev/sdb: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/sdb doesn't contain a valid partition table
[root@virus_update /]# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSFdisklabel
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 5221.
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)
p
Partition number (1-4): 1
First cylinder (1-5221, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-5221, default 5221):
Using default value 5221

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

Calling ioctl() to re-read partition table.
Syncing disks.
[root@virus_update /]# fdisk -l

Disk /dev/sda: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 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 652 5132767+ 8e Linux LVM

Disk /dev/sdb: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sdb1 1 5221 41937651 83 Linux

[root@virus_update /]# pvcreate /dev/sdb1
Physical volume "/dev/sdb1" successfully created
[root@virus_update /]# pvdisplay /dev/sdb1
--- NEW Physical volume ---
PV Name /dev/sdb1
VG Name
PV Size 39.99 GB
Allocatable NO
PE Size (KByte) 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID kW7PHZ-CtMC-0SzR-PNvV-OrZW-2s2d-LFfJ6I

[root@virus_update /]# vgdisplay
--- Volume group ---
VG Name VolGroup00
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 4.88 GB
PE Size 32.00 MB
Total PE 156
Alloc PE / Size 156 / 4.88 GB
Free PE / Size 0 / 0
VG UUID 4Iob4o-byje-ckbV-7dGt-49zm-J27Q-w0NtrU

[root@virus_update /]# vgextend VolGroup00 /dev/sdb1
Volume group "VolGroup00" successfully extended
[root@virus_update /]# lvextend -L +40G /dev/VolGroup00/
[root@virus_update /]# lvscan
ACTIVE '/dev/VolGroup00/LogVol00' [2.94 GB] inherit
ACTIVE '/dev/VolGroup00/LogVol01' [1.94 GB] inherit
[root@virus_update /]# df -h
Filesystem           Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
2.9G 2.4G 396M 86% /
/dev/sda1 99M 11M 83M 12% /boot
tmpfs 1014M 0 1014M 0% /dev/shm

[root@virus_update ~]# resize2fs /dev/VolGroup00/LogVol00
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/VolGroup00/LogVol00 is mounted on /; on-line resizingrequired
Performing an on-line resize of /dev/VolGroup00/LogVol00 to 10993664 (4k)blocks.

The filesystem on /dev/VolGroup00/LogVol00 is now 10993664 blocks long.

[root@virus_update ~]# df -h
Filesystem           Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
41G 2.4G 37G 6% /
/dev/sda1 99M 11M 83M 12% /boot
tmpfs 1014M 0 1014M 0% /dev/shm
[root@virus_update ~]#

___________________________________________________________________________________

版权所有,文章允许转载,但必须以链接方式注明源地址,否则追究法律责任!

Author:   laven54 (lurou)

Email:    laven54@163.com

Blog:      http://blog.csdn.net/laven54

QQ群: 164734649  可以到群里来提问,Oracle相关的问题我都很感兴趣

在线添加磁盘,扩展LVM卷案例的更多相关文章

  1. Linux下添加磁盘创建lvm分区

    shell> fdisk /dev/xvdb #### 选择磁盘 Command (m for help): m #### 帮助 Command action a toggle a bootab ...

  2. linux 虚拟机在线添加新磁盘

    在线添加磁盘,扩展LVM卷案例   一.添加硬盘,在线扫描出来 首先到虚拟机那里添加一块硬盘,注意必须是SCSI类型的硬盘. 扫描硬盘,不用重启操作系统的. echo "- - -" ...

  3. 管理lvm 卷 system-storage-manager

    安装 sudo yum install system-storage-manager [root@si-test-blueking--4 ~]# ssm list 创建物理磁盘到物理卷,<poo ...

  4. 管理员技术(六): 硬盘分区及格式化、 新建一个逻辑卷、调整现有磁盘的分区、扩展逻辑卷的大小、添加一个swap分区

    一.硬盘分区及格式化 问题: 本例要求熟悉硬盘分区结构,使用fdisk分区工具在磁盘 /dev/vdb 上按以下要求建立分区: 1> 采用默认的 msdos 分区模式        2> ...

  5. LVM卷的创建及案例演示

    LVM:Logical Volume Manager, Version:2dm: device mapper,将一个或多个底层块设备组织成一个逻辑设备的模块. /dev/dm-# 这里的#表示数字,代 ...

  6. kvm在线磁盘扩展

    1,查看指定kvm虚拟机的现有磁盘domblklist

  7. 新添加一块硬盘制作LVM卷并进行分区挂载

    linux服务器新添加一块硬盘,可以直接将盘格式化挂载就能用,比如挂载在/usr/local目录,但是这样有一个弊端,就是如果这一块磁盘满了,后续想要扩容的话,不能继续挂载这个/usr/local挂载 ...

  8. linux磁盘 分区 物理卷 卷组 逻辑卷 文件系统加载点操作案例

    转自:truemylife.linux磁盘 分区 物理卷 卷组 逻辑卷 文件系统加载点操作案例 基本概念: 磁盘.分区.物理卷[物理部分] 卷组[中间部分] 逻辑卷.文件系统[虚拟化后可控制部分] 磁 ...

  9. 【linux】新添加一块硬盘制作LVM卷并进行分区挂载

    linux服务器新添加一块硬盘,可以直接将盘格式化挂载就能用,比如挂载在/usr/local目录,但是这样有一个弊端,就是如果这一块磁盘满了,后续想要扩容的话,不能继续挂载这个/usr/local挂载 ...

随机推荐

  1. 遍历String字符串,得到出现次数最多的字母

    //There is no need to explain the code right? package com.hp.test; import java.util.HashMap; import ...

  2. AngularJS中ng-options简单用法及预选项失败的原因

    刚刚接触AngularJs,记录一下ng-options的使用. 1.构造key-value数据 $scope.types = [ {id:"1",type:"AA&qu ...

  3. 图形用户界面入门:EasyGui - 零基础入门学习Python035

    图形用户界面入门:EasyGui 让编程改变世界 Change the world by program 今天我们来谈谈图形用户界面编程,也就是我们常说的GUI(Graphical User Inte ...

  4. Escape character is '^]'. Connection closed by foreign host.

    今天在用易汇金的接口回调时候,老是回调不到我的机器上面.我的ip通过公网映射,按说是可以访问到我的ip,思考是什么问题. 1.防火墙关闭,不行 2.防火墙开启,但是把自己的端口号改为可以访问(参考:h ...

  5. Codeforces Round #277 (Div. 2) 解题报告

    题目地址:http://codeforces.com/contest/486 A题.Calculating Function 奇偶性判断,简单推导公式. #include<cstdio> ...

  6. Cocos2d-x程序Windows下VC中文乱码的解决(用MultiByteToWideChar进行转换,VC2010有非常厉害的execution_character_set)

    Cocos2d-x默认字符串常量编码都是UTF8的,而Windows中的VC默认都是跟系统相同,比如简体Windows是GB2312或者GBK.繁体就是BIG5编码.而我们大多数中国人用VC编译出来的 ...

  7. Linux 下的下载文件命令

    普通文件只需 wget  fileAddr 下载带有登录验证的文件 [chen@localhost Downloads]$ wget --user='av\bname' --ask-password ...

  8. jsp中全局变量和局部变量的设置

  9. 《Algorithms 4th Edition》读书笔记——2.4 优先队列(priority queue)-Ⅰ

    许多应用程序都需要处理有序的元素,但不一定要求他们全部有序,或者是不一定要以此就将他们排序.很多情况下我们会手机一些元素,处理当前键值最大的元素,然后再收集更多的元素,再处理当前键值最大的元素.如此这 ...

  10. Unity PlayerPrefs类进行扩展(整个对象进行保存)

    盘子脸在制作单机游戏的时候,先以为没有好多数据需要保存本地. 就没有使用json等格式自己进行保存. 使用PlayerPrefs类,但是后面字段越来越多的时候. PlayerPrefs保存就发现要手动 ...