Linux | Centos7扩展磁盘空间(LVM管理)




Xshell连接

  • 查看磁盘

    • fdisk -l /dev/sda
  • 查看磁盘占用情况

    • df -h
  • 创建新分区
    fdisk /dev/sda

    • 命令行操作 (输入m查看帮助 输入n开始创建分区)
Command action
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   g   create a new empty GPT partition table
   G   create an IRIX (SGI) partition table
   l   list known partition types
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   s   create a new empty Sun disklabel
   t   change a partition's system id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit
   x   extra functionality (experts only)
  • 输入 n 新建分区
  • 输入 p 设置分区为主分区
  • 设置分区数量 (默认多少输入多少)

按照默认值来就好 恩两次回车

  • 输入 t 修改分区编号 (我的默认4 按回车)
  • 输入 L 查看所有格式
  • 选择分区格式,选择LVM,(输入8e)
  • 输入 w 保存分区并退出
  • 重启系统
    reboot
  • 查看卷组(查找 vg name)
    vgdisplay
  • 本机卷组为centos
  • 使用新的物理卷来扩展 LVM 的 VolGroup
    vgextend centos/dev/sda3
  • 扩展 LVM 的逻辑卷 lvextend -l +100%FREE /dev/centos/root lvextend参数-L是指定大小 如果不输入-L +10G 则默认使用全部
  • 同步到文件系统,实现对根目录的扩容
    xfs_growfs /dev/centos/root
  • 检查
    df -h

注:流程和命令没有错,中途意外断了一次,又重新弄了一遍,重启系统之前的是上一次的图,后面是新图 新的是根目录 20G->50G

posted @ 2021-10-21 17:46  —清风碎心—  阅读(146)  评论(0编辑  收藏  举报