• 16_用LVM扩展xfs文件系统(当分区空间不够时)


    1. 查看当前卷组空间(volume group)使用情况

    [root@localhost ~]# vgdisplay

    从下面的代码中发现剩余空间为0

      --- Volume group ---
      VG Name               rhel
      System ID             
      Format                lvm2
      Metadata Areas        2
      Metadata Sequence No  7
      VG Access             read/write
      VG Status             resizable
      MAX LV                0
      Cur LV                4
      Open LV               4
      Max PV                0
      Cur PV                2
      Act PV                2
      VG Size               25.00 GiB
      PE Size               4.00 MiB
      Total PE              6400
      Alloc PE / Size       6400 / 25.00 GiB
      Free  PE / Size       0 / 0    
      VG UUID               PQijQV-gDsG-wnQT-rIGE-3rGa-hwpl-oYJ3E9

    当卷组中没有足够的空间用于扩展逻辑卷的大小时,就需要增加卷组的容量,而增加卷组容量的唯一办法就是向卷组中添加新的物理卷

    2. 向当前组添加新的物理卷(PV(physical voluem))

       2.1添加物理分区(Physical Partions)

    首先,查看挂载的硬盘

    [root@localhost ~]# fdisk -l

    从下面的代码知道,当前挂载了一个硬盘,名词为“/dev/sda”

    Disk /dev/sda: 500.1 GB, 500107862016 bytes, 976773168 sectors

      2.2通过fdisk的n指令增加一个分区

    [root@localhost ~]# fdisk /dev/sda
    Welcome to fdisk (util-linux 2.23.2).
    
    Changes will remain in memory only, until you decide to write them.
    Be careful before using the write command.
    
    
    Command (m for help): n
    Partition type:
       p   primary (2 primary, 1 extended, 1 free)
       l   logical (numbered from 5)
    Select (default p): l
    Adding logical partition 14
    First sector (694638592-976769071, default 694638592): 
    Using default value 694638592
    Last sector, +sectors or +size{K,M,G} (694638592-743761304, default 743761304): +3G
    Last sector, +sectors or +size{K,M,G} (694638592-743761304, default 743761304): +3G
    Partition 14 of type Linux and of size 3 GiB is set

    Command (m for help): w

    参考网址:http://blog.chinaunix.net/uid-23929712-id-2650378.html

      2.3 立即生效

    [root@localhost ~]# partprobe^C

      2.4创建物理卷PV(Physical Volumes)

    首先用fdisk -l 可以知道新创建的分区名称为:/dev/sda13

    之后用pvcreate命令创建物理卷

    [root@localhost ~]# pvcreate /dev/sda13
    

     3.利用vgextend命令将新的物理卷(/dev/sda13)加入到卷组(rhel)中

    [root@localhost ~]# vgextend rhel /dev/sda13

    4.为空间不够的逻辑卷(root)扩容

    首先用vgdisplay命令检查当前卷组空间使用情况

      Free  PE / Size    768/ 3GB   

    确定当前卷组剩余空间3GB,剩余PE数量为768个。在这里将所有的剩余空间全部增加给逻辑卷rhel

    root@localhost ~]# lvextend -l+768 /dev/rhel/root

    5.通过xfs_growfs命令修改xfs文件系统的大小

    [root@localhost ~]# xfs_growfs /dev/rhel/root

    参考网址:http://www.jb51.net/LINUXjishu/242689.html

    6.最后查看一下文件系统的当前状态

    [root@localhost ~]# df -lh

    Filesystem Size Used Avail Use% Mounted on /dev/mapper/rhel-root 11G 7.0G 4.1G 64% / devtmpfs 1.9G 0 1.9G 0% /dev tmpfs 1.9G 140K 1.9G 1% /dev/shm tmpfs 1.9G 9.0M 1.9G 1% /run tmpfs 1.9G 0 1.9G 0% /sys/fs/cgroup /dev/mapper/rhel-home 6.0G 2.1G 4.0G 35% /home /dev/mapper/rhel-var 6.0G 825M 5.2G 14% /var /dev/sda11 197M 92M 106M 47% /boot

    关于LVM可以参考:http://baike.baidu.com/view/361916.htm

  • 相关阅读:
    如何参与linux 内核开发
    绘制dot 图
    GITHUB 提交错误 Error: Permission denied (publickey) 解决
    atomic_read
    linux 获取cpu 个数
    【转】 管理CPU 亲和性
    【转】 申请对齐某种结构体大小的buffer
    WePY框架开发的小程序中使用 echarts折线图
    vue + css3 实现主题色切换
    vue 中 const { x } = this 的用法
  • 原文地址:https://www.cnblogs.com/haoyufeng/p/4439192.html
Copyright © 2020-2023  润新知