System Reboot Engineer System Reboot Engineer
首页
运维
编程

小布江

首页
运维
编程
  • Kubernetes

  • 日常

    • K8s-Minio集群迁移
    • Argocd-ingress 资源状态一直 Progressing
    • Jenkins job卡住导致页面提示Jenkins即将关闭
    • Docker构建多架构镜像
    • Minio备份及恢复
    • Jenkins构建消息webhook发送
    • cert-manager自动签发Lets Encrypt
    • Ansible批量发送密钥
    • ArgoCD 消息通知
    • Containerd配置私有Harbor镜像仓库
    • kvm虚拟机修改密码
    • Nexus
    • Nginx之tcp转发
    • Arthas
    • 开启telnet登录
    • CPU亲和
    • Harbor复制镜像
    • KVM虚拟机根目录扩容
    • Prometheus

    • Ci

    • 运维
    • 日常
    小布江
    2022-04-21
    目录

    KVM虚拟机根目录扩容

    # 1. 虚拟机查看磁盘
    [root@k8s-node02 ~] lsblk
    NAME            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
    sda               8:0    0  200G  0 disk
    ├─sda2            8:2    0  199G  0 part
    │ ├─centos-opt  253:1    0  130G  0 lvm  /opt
    │ └─centos-root 253:0    0   69G  0 lvm  /
    └─sda1            8:1    0    1G  0 part /boot
    
    1
    2
    3
    4
    5
    6
    7
    # 2. 宿主机执行命令
    # 2.1 创建磁盘
    qemu-img create -f qcow2 /vm/expand-disk/k8s-node02-data.img 100G
    
    1
    # 2.2 将磁盘添加到虚拟机
    virsh attach-disk k8s-node02-33.222 --source /vm/expand-disk/k8s-node02-data.img --target sdc --subdriver qcow2 --persistent
    
    1
    # 3. 虚拟机执行命令
    # 3.1 查看磁盘
    [root@k8s-node02 ~] lsblk
    NAME            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
    sdb               8:16   0  100G  0 disk
    sda               8:0    0  200G  0 disk
    ├─sda2            8:2    0  199G  0 part
    │ ├─centos-opt  253:1    0  130G  0 lvm  /opt
    │ └─centos-root 253:0    0   69G  0 lvm  /
    └─sda1            8:1    0    1G  0 part /boot
    
    1
    2
    3
    4
    5
    6
    7
    8
    # 3.2 磁盘进行分区
    fdisk /dev/sdb
    
    1
    # 3.3 分区查看
    [root@k8s-node02 ~] lsblk
    NAME            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
    sdb               8:16   0  100G  0 disk
    └─sdb1            8:17   0  100G  0 part
    sda               8:0    0  200G  0 disk
    ├─sda2            8:2    0  199G  0 part
    │ ├─centos-opt  253:1    0  130G  0 lvm  /opt
    │ └─centos-root 253:0    0   69G  0 lvm  /
    └─sda1            8:1    0    1G  0 part /boot
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    # 3.4 查看物理卷信息
    [root@k8s-node02 ~] pvdisplay
      --- Volume group ---
      VG Name               centos
      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               <199.00 GiB
      PE Size               4.00 MiB
      Total PE              50943
      Alloc PE / Size       50943 / <199.00 GiB
      Free  PE / Size       0 / 0
      VG UUID               wqewxG-dg2m-fV5N-efXg-VlH5-hcoQ-M6yplI
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    # 3.5 扩展卷组
    vgextend centos /dev/sdb1
    
    1
    # 3.6 再次查看卷组信息
    [root@k8s-node02 ~] vgdisplay
      --- Volume group ---
      VG Name               centos
      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               298.99 GiB
      PE Size               4.00 MiB
      Total PE              76542
      Alloc PE / Size       50943 / <199.00 GiB
      Free  PE / Size       25599 / <100.00 GiB
      VG UUID               wqewxG-dg2m-fV5N-efXg-VlH5-hcoQ-M6yplI
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    # 3.7 查看逻辑卷属性
    [root@k8s-node02 ~] lvdisplay
      --- Logical volume ---
      LV Path                /dev/centos/opt
      LV Name                opt
      VG Name                centos
      LV UUID                sVxfDn-pquv-A3Zq-9N6E-HnFa-7upm-0s0s2T
      LV Write Access        read/write
      LV Creation host, time localhost, 2021-03-12 13:10:11 +0800
      LV Status              available
      open                 1
      LV Size                130.00 GiB
      Current LE             33280
      Segments               1
      Allocation             inherit
      Read ahead sectors     auto
      - currently set to     256
      Block device           253:1
    
      --- Logical volume ---
      LV Path                /dev/centos/root
      LV Name                root
      VG Name                centos
      LV UUID                rm4gNM-1W5R-jXnc-QxMk-WB2t-fqMI-svFwlK
      LV Write Access        read/write
      LV Creation host, time localhost, 2021-03-12 13:10:13 +0800
      LV Status              available
      open                 1
      LV Size                <69.00 GiB
      Current LE             17663
      Segments               1
      Allocation             inherit
      Read ahead sectors     auto
      - currently set to     256
      Block device           253:0
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    # 3.8 将目前磁盘未分配的空间全部扩展到 /dev/centos/root 分区下
    lvextend -l +100%FREE /dev/centos/root
    
    1
    # 3.9 查看逻辑卷属性
    [root@k8s-node02 ~] lvdisplay
      --- Logical volume ---
      LV Path                /dev/centos/opt
      LV Name                opt
      VG Name                centos
      LV UUID                sVxfDn-pquv-A3Zq-9N6E-HnFa-7upm-0s0s2T
      LV Write Access        read/write
      LV Creation host, time localhost, 2021-03-12 13:10:11 +0800
      LV Status              available
      open                 1
      LV Size                130.00 GiB
      Current LE             33280
      Segments               1
      Allocation             inherit
      Read ahead sectors     auto
      - currently set to     256
      Block device           253:1
    
      --- Logical volume ---
      LV Path                /dev/centos/root
      LV Name                root
      VG Name                centos
      LV UUID                rm4gNM-1W5R-jXnc-QxMk-WB2t-fqMI-svFwlK
      LV Write Access        read/write
      LV Creation host, time localhost, 2021-03-12 13:10:13 +0800
      LV Status              available
      open                 1
      LV Size                168.99 GiB
      Current LE             43262
      Segments               2
      Allocation             inherit
      Read ahead sectors     auto
      - currently set to     256
      Block device           253:0
    
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    # 3.10 重新识别分区大小
    xfs_growfs /dev/centos/root
    
    1
    #linux
    上次更新: 2025/04/25, 03:40:17
    Harbor复制镜像
    Alertmanager报警历史持久化

    ← Harbor复制镜像 Alertmanager报警历史持久化→

    最近更新
    01
    Harbor复制镜像
    04-15
    02
    CPU亲和
    04-10
    03
    开启telnet登录
    04-09
    更多文章>
    Theme by Vdoing
    • 跟随系统
    • 浅色模式
    • 深色模式
    • 阅读模式