• AWS 磁盘 在线扩容(NVME 磁盘)


    AWS 磁盘 在线扩容(NVME 磁盘)

    • 安装扩容工具
    # growpart 为分区表修改工具
    curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
    curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
    sed -i -e '/mirrors.cloud.aliyuncs.com/d' -e '/mirrors.aliyuncs.com/d' /etc/yum.repos.d/CentOS-Base.repo
    yum search growpart
    yum install cloud-utils-growpart
    

    1.NVME 磁盘扩容

    • 操作步骤
    1.AWS 控制台扩容磁盘卷大小
    2.磁盘卷扩容完成后登录主机查看磁盘卷扩容结果
    3.扩容磁盘卷大小
    4.扩容磁盘分区大小
    
    • 操作命令:
    # 查看磁盘信息
    df -h
    lsblk
    file -s /dev/nvme?n*
    
    -------------------
    # 修改磁盘分区表(根磁盘)
    growpart /dev/nvme1n1 1
    lsblk
    
    ## 扩容分区空间(根磁盘)
    resize2fs  /dev/nvme1n1p1
    df -h
    
    -------------------
    # 修改磁盘分区表(第二磁盘)
    growpart /dev/nvme0n1 1
    lsblk
    
    ## 扩容分区空间(第二磁盘)
    resize2fs /dev/nvme0n1p1
    df -h
    --------------------
    
    • 实例演示:根分区由 20GB 扩容到 100GB
    # 扩容前检查磁盘状态
    --------------------
    root@zuiyoujie:/opt/tools# file -s /dev/nvme?n*
    /dev/nvme0n1:   DOS/MBR boot sector
    /dev/nvme0n1p1: Linux rev 1.0 ext4 filesystem data, UUID=01909065-0362-439c-9af2-29d0fc837f6b, volume name "cloudimg-rootfs"
    (needs journal recovery) (extents)
    (large files) (huge files)
    
    root@zuiyoujie:/opt/tools# lsblk
    NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
    loop0         7:0    0 89.1M  1 loop /snap/core/8213
    loop1         7:1    0 89.1M  1 loop /snap/core/8268
    loop2         7:2    0   18M  1 loop /snap/amazon-ssm-agent/1480
    loop3         7:3    0   18M  1 loop /snap/amazon-ssm-agent/1455
    nvme0n1     259:0    0  100G  0 disk                  # 磁盘大小已经修改为 100GB
    └─nvme0n1p1 259:1    0   20G  0 part /               # 分区大小为 20GB
    
    root@zuiyoujie:/opt/tools# df -h
    Filesystem      Size  Used Avail Use% Mounted on
    udev            3.8G     0  3.8G   0% /dev
    tmpfs           764M   78M  687M  11% /run
    /dev/nvme0n1p1   20G   15G  5.1G  74% /
    tmpfs           3.8G     0  3.8G   0% /dev/shm
    tmpfs           5.0M     0  5.0M   0% /run/lock
    tmpfs           3.8G     0  3.8G   0% /sys/fs/cgroup
    /dev/loop0       90M   90M     0 100% /snap/core/8213
    /dev/loop1       90M   90M     0 100% /snap/core/8268
    /dev/loop2       18M   18M     0 100% /snap/amazon-ssm-agent/1480
    /dev/loop3       18M   18M     0 100% /snap/amazon-ssm-agent/1455
    tmpfs           764M     0  764M   0% /run/user/0
    
    # 修改分区表
    --------------------
    root@zuiyoujie:/opt/tools# growpart /dev/nvme0n1 1
    CHANGED: partition=1 start=2048 old: size=41940959 end=41943007 new: size=209713119,end=209715167
    
    root@zuiyoujie:/opt/tools# lsblk
    NAME        MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
    loop0         7:0    0 89.1M  1 loop /snap/core/8213
    loop1         7:1    0 89.1M  1 loop /snap/core/8268
    loop2         7:2    0   18M  1 loop /snap/amazon-ssm-agent/1480
    loop3         7:3    0   18M  1 loop /snap/amazon-ssm-agent/1455
    nvme0n1     259:0    0  100G  0 disk
    └─nvme0n1p1 259:1    0  100G  0 part /              # 分区表已经扩容(识别)为 100GB
    
    root@zuiyoujie:/opt/tools# df -h
    Filesystem      Size  Used Avail Use% Mounted on
    udev            3.8G     0  3.8G   0% /dev
    tmpfs           764M   78M  687M  11% /run
    /dev/nvme0n1p1   20G   15G  5.1G  74% /               # 未执行 resize2fs 命令,磁盘容量未增加
    tmpfs           3.8G     0  3.8G   0% /dev/shm
    tmpfs           5.0M     0  5.0M   0% /run/lock
    tmpfs           3.8G     0  3.8G   0% /sys/fs/cgroup
    /dev/loop0       90M   90M     0 100% /snap/core/8213
    /dev/loop1       90M   90M     0 100% /snap/core/8268
    /dev/loop2       18M   18M     0 100% /snap/amazon-ssm-agent/1480
    /dev/loop3       18M   18M     0 100% /snap/amazon-ssm-agent/1455
    tmpfs           764M     0  764M   0% /run/user/0
    
    root@zuiyoujie:/opt/tools# resize2fs /dev/nvme0n1p1   # 执行扩容命令,扩容磁盘
    resize2fs 1.42.13 (17-May-2015)
    Filesystem at /dev/nvme0n1p1 is mounted on /; on-line resizing required
    old_desc_blocks = 2, new_desc_blocks = 7
    The filesystem on /dev/nvme0n1p1 is now 26214139 (4k) blocks long.
    
    root@zuiyoujie:/opt/tools# df -h
    Filesystem      Size  Used Avail Use% Mounted on
    udev            3.8G     0  3.8G   0% /dev
    tmpfs           764M   78M  687M  11% /run
    /dev/nvme0n1p1   97G   15G   83G  15% /              # 实际分区大小为 100GB
    tmpfs           3.8G     0  3.8G   0% /dev/shm
    tmpfs           5.0M     0  5.0M   0% /run/lock
    tmpfs           3.8G     0  3.8G   0% /sys/fs/cgroup
    /dev/loop0       90M   90M     0 100% /snap/core/8213
    /dev/loop1       90M   90M     0 100% /snap/core/8268
    /dev/loop2       18M   18M     0 100% /snap/amazon-ssm-agent/1480
    /dev/loop3       18M   18M     0 100% /snap/amazon-ssm-agent/1455
    tmpfs           764M     0  764M   0% /run/user/0
    ------------------------------------------------
    

    2.参考链接

    • 扩展卷之后扩容文件系统(分区)容量

    https://docs.aws.amazon.com/zh_cn/AWSEC2/latest/UserGuide/recognize-expanded-volume-linux.html#extend-linux-volume-partition

  • 相关阅读:
    Importing multi-valued field into Solr from mySQL using Solr Data Import Handler
    VMware Workstation 虚拟机使用无线wifi上网配置
    Linux开发黑客
    GitHub 使用说明
    虹软人脸检测和识别C#
    C#将结构体和指针互转的方法
    笔记本电脑连接wifi,同时提供热点wifi给手机使用
    基于STM32L4的开源NBIOT开发资料
    ESP8266擦除工具完整安装
    开发快平台(M302I小e开发板系列教程)
  • 原文地址:https://www.cnblogs.com/tssc/p/14029522.html
Copyright © 2020-2023  润新知