• Linux给根目录扩容


    需求:Linux系统挂载到根目录的磁盘空间满了,如何扩容?
    一、添加磁盘并分区

    [root@cdn ~]# fdisk /dev/sdb
    
    Welcome to fdisk (util-linux 2.37.2).
    Changes will remain in memory only, until you decide to write them.
    Be careful before using the write command.
    
    Device does not contain a recognized partition table.
    Created a new DOS disklabel with disk identifier 0xf1212eee.
    
    Command (m for help): n
    Partition type
       p   primary (0 primary, 0 extended, 4 free)
       e   extended (container for logical partitions)
    Select (default p):
    
    Using default response p.
    Partition number (1-4, default 1):
    First sector (2048-41943039, default 2048):
    Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-41943039, default 41943039): +10G
    
    Created a new partition 1 of type 'Linux' and of size 10 GiB.
    
    Command (m for help): w
    The partition table has been altered.
    Calling ioctl() to re-read partition table.
    Syncing disks.
    
    • 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

    二、创建pv

    [root@cdn ~]# pvcreate /dev/sdb1
      Physical volume "/dev/sdb1" successfully created.
    
    • 1
    • 2

    三、将原vg扩容

    [root@localhost ~]# vgextend bigcloud-enterprise-linux-for-euler /dev/sda4
      Volume group "bigcloud-enterprise-linux-for-euler" successfully extended
    
    • 1
    • 2

    四、扩容pv

    [root@localhost ~]# lvextend -L 60G /dev/bigcloud-enterprise-linux-for-euler/root
      Size of logical volume bigcloud-enterprise-linux-for-euler/root changed from 20.91 GiB (5353 extents) to 60.00 GiB (15360 
    
    extents).
      Logical volume bigcloud-enterprise-linux-for-euler/root successfully resized.
    
    • 1
    • 2
    • 3
    • 4
    • 5

    五、格式化

    [root@localhost ~]# resize2fs /dev/mapper/bigcloud--enterprise--linux--for--euler-root
    resize2fs 1.45.6 (20-Mar-2020)
    Filesystem at /dev/mapper/openeuler-root is mounted on /; on-line resizing required
    old_desc_blocks = 3, new_desc_blocks = 8
    The filesystem on /dev/mapper/bigcloud--enterprise--linux--for--euler-root is now 15728640 (4k) blocks long.
    #使用xfs_growfs命令扩展xfs文件系统,如果是ext4文件系统,则使用resize2fs  /dev/mysql/lv_data 
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6

    六、检查

    [root@localhost ~]# lsblk
    
    • 1
  • 相关阅读:
    Kubernetes学习笔记-StatefulSet:部署有状态的多副本应用(2)20220625
    Effective Modern C++[实践]->只要函数不会发射异常,就为其加上noexcept
    React源码解读之更新的创建
    【毕业设计】基于 stm32 的病房呼叫系统 - 物联网 嵌入式 单片机
    用CI/CD工具Vela部署Elasticsearch + C# 如何使用
    高手过招不用鼠标,一款超好用的跨平台命令行界面库
    postcss-pxtorem
    SpringCloud笔记之入门
    【docker】docker的基础命令
    MySQL 常见存储引擎详解(一)
  • 原文地址:https://blog.csdn.net/weixin_45432833/article/details/134482954