zoukankan      html  css  js  c++  java
  • lvm的vg扩容

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

    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查看磁盘容量就会发现增大了很多。

  • 相关阅读:
    Linux查看内容命令[持续添加]
    android4.0 x86下载编译简介
    android4.0 x86 裁剪与定制
    Android4.0 x86源码结构,生成目录结构
    android4.0 x86编译生成文件系统镜像system.img结构简介
    [翻译]Mootools 1.2新特性(一):元素存储(Element Storage)
    ASP.NET MVC Preview 3 STEP BY STEP 文章管理实例(一)
    Microsoft Speech API SDK
    PB串口编程资料MSCOMM32参数基本介绍
    Microsoft Speech API Overview(SAPI 5.4)
  • 原文地址:https://www.cnblogs.com/sfnz/p/5445315.html
Copyright © 2011-2022 走看看