• CentOS服务器的扩容(VMware)


    注意:不能用快照

    扩容前先关机

    名词解释:

      1. 物理卷Physical volume (PV):可以在上面建立卷组的媒介,可以是硬盘分区,也可以是硬盘本身或者回环文件(loopback file)。物理卷包括一个特殊的header,其余部分被切割为一块块物理区域(physical extents)。 Think of physical volumes as big building blocks which can be used to build your hard drive.

        2. 卷组Volume group (VG):将一组物理卷收集为一个管理单元。Group of physical volumes that are used as storage volume (as one disk). They contain logical volumes. Think of volume groups as hard drives.

        3. 逻辑卷Logical volume (LV):虚拟分区,由物理区域(physical extents)组成。A "virtual/logical partition" that resides in a volume group and is composed of physical extents. Think of logical volumes as normal partitions.

        4. 物理区域Physical extent (PE):硬盘可供指派给逻辑卷的最小单位(通常为4MB)。A small part of a disk (usually 4MB) that can be assigned to a logical Volume. Think of physical extents as parts of disks that can be allocated to any partition.

     

    1.关机调整大小

    调整虚拟机大小 为 50G

     

    登录后df -h查看磁盘空间的总和依然为20GB

    df -h

     

    2.列出磁盘分区表

    fdisk -l命令列出磁盘分区表,发现只存在三个分区,总大小是20.9G,磁盘总大小为53.7 GB,还有30G未分配空间

    fdisk -l

     

    使用fdisk命令创建一个新的分区,根据提示输入相应的命令,m获取帮助。

    输入n创建分区,然后根据下一步的提示输入p或者e,p代表主分区,e代表扩展分区,这里我选择了p,默认回车,将剩余所有空间都用于该分区,最后输入w写入磁盘。

    由于之前已经有三个分区,所以分区号默认为3,路径/dev/sda3。写入磁盘完毕后,切记一定要执行reboot,重启系统,否则新磁盘无法找到。

    3. fdisk创建新的分区

    fdisk /dev/sda

     

    4. 重启

    重启系统,否则新磁盘无法找到

    reboot

    fdisk -l 查看

     

    5.创建PV

    pvcreate /dev/sda3

     

    6.查看VG name

    vgdisplay

    Pvdisplay

    Lvdisplay

     

    7.扩容VG(pv 加入vg)

    VG Name来定义用vgextends谁,这里是centos那么我就用centos执行下面命令

    vgextend centos /dev/sda3

     

    查看修改成功没有 (可以不看)

    vgextend  VolGroup /dev/sda3

     

    8.扩展lv

    lvextend -L +30G /dev/mapper/centos-root 进行扩容,内存大小,自己根据情况定义,选最大可以会执行失败如下

     

    需要缩小空间,或者使用下面的命令100%free

     lvextend -l +100%free /dev/mapper/centos-root

     

    9.查看并调整

    查看lv大小

    lvs

    大小没有变

    LV执行调整 xfs_growfs /dev/centos/root ,使系统重新读取大小

    df -h 查看

     

    备注:我们可以自行生产vg组以及在新的vg中生成lv

    vgcreate       创建新的vg组

    lvcreate        在新的vg中创建新的lv,但是要指定对vg名字

    vgreduce      把pv从vg中移除,若vg中只有一个pv则直接使用vgremove

  • 相关阅读:
    Linux安全加固--精简启动项
    Linux安全加固--系统相关
    Nginx多域名负载均衡配置
    linux系统安全加固--账号相关
    ssh免密登录linux服务器
    Java入门【02】基本程序设计结构01
    Java入门【01】运行Java程序
    新的开始
    九宫重排
    格子刷油漆
  • 原文地址:https://www.cnblogs.com/hanby/p/15958729.html
Copyright © 2020-2023  润新知