linux下对LVM扩容

操作环境:VirtualBox下RedHat6.4 64位版本

扩容原因:/dev/vg_rhel64/lv_root 占用率达到100%,导致部分应用无法继续运行

操作过程:

1.关闭系统,在虚拟机中添加一块10G的磁盘

2.查看新添加磁盘对应的名称

[[email protected] ~]# fdisk -cul 得知磁盘对应名称为 /dev/sdc

3.给sdc分区,只分一个区sdc1

[[email protected] ~]# fdisk -cu /dev/sdc
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0xa655ad49.
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-20971519, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-20971519, default 20971519):
Using default value 20971519

Command (m for help): p

Disk /dev/sdc: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders, total 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xa655ad49

Device Boot Start End Blocks Id System
/dev/sdc1 2048 20971519 10484736 83 Linux

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

Calling ioctl() to re-read partition table.
Syncing disks.

4.在sdc1上创建pv

[[email protected] ~]# pvcreate /dev/sdc1
Physical volume "/dev/sdc1" successfully created

5.查看pv的情况

[[email protected] ~]# pvdisplay
--- Physical volume ---
PV Name /dev/sdb2
VG Name vg_rhel64
PV Size 14.51 GiB / not usable 3.00 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 3714
Free PE 0
Allocated PE 3714
PV UUID VBVnoj-7R81-0BgJ-j8Tr-nq2W-i84v-xJZlqZ

--- Physical volume ---
PV Name /dev/sda5
VG Name vg_myvg
PV Size 1.00 GiB / not usable 4.00 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 255
Free PE 0
Allocated PE 255
PV UUID CmX1Tx-1LdX-wtRf-qXoX-Myg3-WR5g-klwUg9

--- Physical volume ---
PV Name /dev/sda6
VG Name vg_myvg
PV Size 1021.00 MiB / not usable 0
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 255
Free PE 0
Allocated PE 255
PV UUID Q9FgFp-0gHF-KMtK-Vrfa-2f95-eKRg-7bq40d

"/dev/sdc1" is a new physical volume of "10.00 GiB"
--- NEW Physical volume ---
PV Name /dev/sdc1
VG Name
PV Size 10.00 GiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID KrvMui-Kzmd-qGdP-SBl6-yYfZ-Q5Y6-PA1Vv0

6.查看系统当前vg的情况

[[email protected] ~]# vgdisplay
--- Volume group ---
VG Name vg_rhel64
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 14.51 GiB
PE Size 4.00 MiB
Total PE 3714
Alloc PE / Size 3714 / 14.51 GiB
Free PE / Size 0 / 0
VG UUID Yb3iGX-1SdP-MoFz-I4iS-0oDt-NhVD-SE5UAr

--- Volume group ---
VG Name vg_myvg
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 5
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 1.99 GiB
PE Size 4.00 MiB
Total PE 510
Alloc PE / Size 510 / 1.99 GiB
Free PE / Size 0 / 0
VG UUID x9sUhJ-gQ4c-avxR-daQ1-ceib-VtGF-nvwqv9

7.给vg扩容

[[email protected] ~]# vgextend vg_rhel64 /dev/sdc1
Volume group "vg_rhel64" successfully extended

8.查看扩容后vg的情况

[[email protected] ~]# vgdisplay
--- Volume group ---
VG Name vg_rhel64
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 24.50 GiB
PE Size 4.00 MiB
Total PE 6273
Alloc PE / Size 3714 / 14.51 GiB
Free PE / Size 2559 / 10.00 GiB
VG UUID Yb3iGX-1SdP-MoFz-I4iS-0oDt-NhVD-SE5UAr

--- Volume group ---
VG Name vg_myvg
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 5
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 1.99 GiB
PE Size 4.00 MiB
Total PE 510
Alloc PE / Size 510 / 1.99 GiB
Free PE / Size 0 / 0
VG UUID x9sUhJ-gQ4c-avxR-daQ1-ceib-VtGF-nvwqv9

9.查看系统当前lv的情况

[[email protected] ~]# lvdisplay
--- Logical volume ---
LV Path /dev/vg_rhel64/lv_root
LV Name lv_root
VG Name vg_rhel64
LV UUID Y2oXR6-yrXx-fetw-GiOl-iHmc-HbOV-fIUc83
LV Write Access read/write
LV Creation host, time rhel64.oracle.com, 2017-11-13 21:47:39 +0800
LV Status available
#open 1
LV Size 12.54 GiB
Current LE 3210
Segments 1
Allocation inherit
Read ahead sectors auto

  • currently set to 256
    Block device 253:0

    --- Logical volume ---
    LV Path /dev/vg_rhel64/lv_swap
    LV Name lv_swap
    VG Name vg_rhel64
    LV UUID OuuBWZ-WqMd-kZ5B-ka62-Ifgy-hfD5-6bpdZL
    LV Write Access read/write
    LV Creation host, time rhel64.oracle.com, 2017-11-13 21:47:42 +0800
    LV Status available
    #open 1
    LV Size 1.97 GiB
    Current LE 504
    Segments 1
    Allocation inherit
    Read ahead sectors auto

  • currently set to 256
    Block device 253:1

    --- Logical volume ---
    LV Path /dev/vg_myvg/lv_mylv
    LV Name lv_mylv
    VG Name vg_myvg
    LV UUID vFq38A-3mJ1-RRso-2EcI-e9gO-wz2a-YWU3x8
    LV Write Access read/write
    LV Creation host, time rhel64.oracle.com, 2018-01-12 14:14:35 +0800
    LV Status available
    #open 1
    LV Size 1.99 GiB
    Current LE 510
    Segments 2
    Allocation inherit
    Read ahead sectors auto

  • currently set to 256

    10.给lv扩容

    [[email protected] ~]# lvextend /dev/vg_rhel64/lv_root /dev/sdc1
    Extending logical volume lv_root to 22.54 GiB
    Logical volume lv_root successfully resized

    11.查看扩容后的lv

    [[email protected] ~]# lvdisplay
    --- Logical volume ---
    LV Path /dev/vg_rhel64/lv_root
    LV Name lv_root
    VG Name vg_rhel64
    LV UUID Y2oXR6-yrXx-fetw-GiOl-iHmc-HbOV-fIUc83
    LV Write Access read/write
    LV Creation host, time rhel64.oracle.com, 2017-11-13 21:47:39 +0800
    LV Status available
    #open 1
    LV Size 22.54 GiB
    Current LE 5769
    Segments 2
    Allocation inherit
    Read ahead sectors auto

  • currently set to 256
    Block device 253:0

    --- Logical volume ---
    LV Path /dev/vg_rhel64/lv_swap
    LV Name lv_swap
    VG Name vg_rhel64
    LV UUID OuuBWZ-WqMd-kZ5B-ka62-Ifgy-hfD5-6bpdZL
    LV Write Access read/write
    LV Creation host, time rhel64.oracle.com, 2017-11-13 21:47:42 +0800
    LV Status available
    #open 1
    LV Size 1.97 GiB
    Current LE 504
    Segments 1
    Allocation inherit
    Read ahead sectors auto

  • currently set to 256
    Block device 253:1

    --- Logical volume ---
    LV Path /dev/vg_myvg/lv_mylv
    LV Name lv_mylv
    VG Name vg_myvg
    LV UUID vFq38A-3mJ1-RRso-2EcI-e9gO-wz2a-YWU3x8
    LV Write Access read/write
    LV Creation host, time rhel64.oracle.com, 2018-01-12 14:14:35 +0800
    LV Status available
    #open 1
    LV Size 1.99 GiB
    Current LE 510
    Segments 2
    Allocation inherit
    Read ahead sectors auto

  • currently set to 256
    Block device 253:2

    12.查看系统当前的分区情况

    [[email protected] ~]# df -h
    Filesystem Size Used Avail Use% Mounted on
    /dev/mapper/vg_rhel64-lv_root
    13G 12G 104M 100% /
    tmpfs 1.5G 72K 1.5G 1% /dev/shm
    /dev/sdb1 485M 33M 427M 8% /boot
    /dev/sda1 18G 172M 17G 1% /u01
    /dev/sda2 7.9G 146M 7.4G 2% /software
    /dev/mapper/vg_myvg-lv_mylv
    2.0G 11M 1.9G 1% /lvm
    没有扩容

    13.对/扩容

    [[email protected] ~]# resize2fs /dev/vg_rhel64/lv_root
    resize2fs 1.41.12 (17-May-2010)
    Filesystem at /dev/vg_rhel64/lv_root is mounted on /; on-line resizing required
    old desc_blocks = 1, new_desc_blocks = 2
    Performing an on-line resize of /dev/vg_rhel64/lv_root to 5907456 (4k) blocks.
    The filesystem on /dev/vg_rhel64/lv_root is now 5907456 blocks long.

    14.查看扩容后分区的情况

    [[email protected] ~]# df -Th
    Filesystem Type Size Used Avail Use% Mounted on
    /dev/mapper/vg_rhel64-lv_root
    ext4 23G 12G 9.5G 56% /
    tmpfs tmpfs 1.5G 72K 1.5G 1% /dev/shm
    /dev/sdb1 ext4 485M 33M 427M 8% /boot
    /dev/sda1 ext4 18G 172M 17G 1% /u01
    /dev/sda2 ext4 7.9G 146M 7.4G 2% /software
    /dev/mapper/vg_myvg-lv_mylv
    ext4 2.0G 11M 1.9G 1% /lvm
    可以看到,/分区由原来的13G扩容到了23G

原文地址:http://blog.51cto.com/13489442/2060264

时间: 2024-10-05 14:19:56

linux下对LVM扩容的相关文章

Linux下的LVM和磁盘配额的配置和管理

Linux下的LVM和磁盘配额的配置和管理   一:实验目标 LVM日常管理 LVM快照 磁盘配额 二:实验概念 概念(名词):最小存储单位为:PE PV Physical Volume(物理卷) VG Volume Group(卷组) LV Logical Volume(逻辑卷) 总结: 名称      最小存储单位   cre硬盘      扇区(512字节)  文件系统  block(1K或4K ) raid     chunk (512K)  mdadm -c   LVM      PE

linux 根分区LVM扩容

linux 根分区LVM扩容 ### df -h 看看现在硬盘的情况 #lsblk 查看磁盘目录 # fdisk -l 可以看到新添加的硬盘/dev/sdb #分区: n p enter t 8e W # lvm lvm>vgdisplay 可以先看卷组是否还有剩余空间可以扩展, 有的话直接扩展,没有或不够的话把新的硬盘添加进去 同时查看到 VG组名: Centos # lvm>pvcreate /dev/sdb1 使用新的整个硬盘创建一个lvm物理卷 #将新创建的物理卷加入VG组 #vgdi

Linux下的LVM创建以及Linux快照卷

通过最的学习,我加深了对LVM的理解,在这里,我将它写成博客,一是方便自己记忆,二是让Linux的入门学习者一起学习一下. 首先我们引入LVM的概念,并展开详细的说明,主要是近期学习的看法,我们先看一个图 我们将会提到的名词有:PV.VG.LV.PE 在图中,最下面的,我们可以理解为物理存储介质,硬盘或是分区 PV:称为物理卷,是LVM的基本存储块. VG:称为卷组,我们可以看卷组是由物理卷组合而成的. LV:称为逻辑卷,是从卷组中划分出来的. PE:physical extent,我就称为物理

在linux下实现LVM

LVM概述 LVM是逻辑盘卷管理(Logical Volume Manager)的简称,它是Linux环境下对磁盘分区进行管理 的一种机制: LVM是建立在硬盘和分区之上的一个逻辑层,来提高磁盘分区管理的灵活性: 通过LVM,管理员就不必将磁盘的文件移动到新的磁盘上以充分利用新的存储空间,而是直接扩展文件系统跨越磁盘即可,也就是我们常说的动态调整分区的大小. LVM创建 a.添加硬盘或创建分区 在linux系统中所有的设备都会以文件的形式存储.设备一般保存在/dev目录下面,以sda.sda1.

Linux下配置LVM

安装环境:CentOS 6.8 一LVM简介 LVM是逻辑盘卷管理(LogicalVolumeManager)的简称,它是Linux环境下对磁盘分区进行管理的一种机制,LVM是建立在硬盘和 分区之上的一个逻辑层,来提高磁盘分区管理的灵活性.通过LVM系统管理员可以轻松管理磁盘分区,如:将若干个磁盘分区连接为一个整块的卷组 (volumegroup),形成一个存储池.管理员可以在卷组上随意创建逻辑卷组(logicalvolumes),并进一步在逻辑卷组上创建文件系 统.管理员通过LVM可以方便的调

Linux下对lvm逻辑卷分区大小的调整(针对xfs和ext4不同文件系统)

当我们在安装系统的时候,由于没有合理分配分区空间,在后续维护过程中,发现有些分区空间不够使用,而有的分区空间却有很多剩余空间.如果这些分区在装系统的时候使用了lvm(前提是这些分区要是lvm逻辑卷分区),那么就可以轻松进行扩容或缩容!不同文件系统类型所对应的创建.检查.调整命令不同,下面就针对xfs和ext2/3/4文件系统的lvm分区空间的扩容和缩容的操作做一记录:-----------------------------------------------------------------

1.4 Linux下对lvm逻辑卷分区大小的调整(针对xfs和ext4不同文件系统)

当我们在安装系统的时候,由于没有合理分配分区空间,在后续维护过程中,发现有些分区空间不够使用,而有的分区空间却有很多剩余空间.如果这些分区在装系统的时候使用了lvm(前提是这些分区要是lvm逻辑卷分区),那么就可以轻松进行扩容或缩容!不同文件系统类型所对应的创建.检查.调整命令不同,下面就针对xfs和ext2/3/4文件系统的lvm分区空间的扩容和缩容的操作做一记录: ----------------------------------------------------------------

LINUX下为LVM磁盘增加硬盘空间

1,为客户机增加一块新的硬盘 2, 重启客户机 3, 用fdisk -l查看整个磁盘空间 #fdisk -l Disk /dev/sda: 34.4 GB, 34359738368 bytes 255 heads, 63 sectors/track, 4177 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O si

linux下创建LVM

参考文档链接:http://www.chinaunix.net/jh/4/72921.html 名词解释:1.物理卷 Physical Volume (PV):一个物理卷,包含了许多物理分区2.物理分区 Physical Extents (PE) 3.卷组 Volume Group (VG):一个VG是由许多物理分区组成的(可能来自多个物理卷或硬盘). 4.逻辑卷 Logical Volume (LV) 5.文件系统 Filesystem 创建逻辑卷LV,操作步骤如下: 1.对各个磁盘进行分区[