zoukankan      html  css  js  c++  java
  • centos7虚拟机扩容

     

    将虚拟机设置为更大硬盘空间之后,内部还需要再设置一下

    1、首先确认当前各文件系统大小,可以看到根目录对应文件系统大小是10GB,/boot对应文件系统大小是0.4GB。

    df -h
    vgdisplay
    vgdisplay -v centos

    2、确认当前磁盘容量信息,/dev/sda大小为53.7GB,划分了2个分区,已划分的总容量不到20GB。还有将近30GB可用空间

    fdisk -l

    3、在未用空间创建新的分区sda3。(很重要)

    主要输入:n   p   w,其他的就默认就好

    [root@backup03 ~]# fdisk /dev/sdaCommand (m for help): n
    ​
    Select (default p): p
    ​
    Partition number (3,4, default 3): 
    ​
    First sector (25593856-104857599, default 25593856): 
    ​
    Using default value 25593856
    ​
    Last sector, +sectors or +size{K,M,G} (25593856-104857599, default 104857599): 
    ​
    Using default value 104857599
    ​
    Partition 3 of type Linux and of size 37.8 GiB is setCommand (m for help): w
    ​
    The partition table has been altered!
    ​
    Calling ioctl() to re-read partition table.
    ​
    WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
    ​
    The kernel still uses the old table. The new table will be used at
    ​
    the next reboot or after you run partprobe(8) or kpartx(8
    ​
    Syncing disks.

    4、根据上面步骤的提示,需要重启或者运行命令partprobe重新同步磁盘分区信息,分区重新识别后可以看到新分区sda3。

    [root@backup03 ~]# partprobe
    Warning: Unable to open /dev/sr0 read-write (Read-only file system).  /dev/sr0 has been opened read-only.

    5、使用lvm命令pvcreate格式化sda3分区。

    [root@backup03 ~]# pvcreate /dev/sda3
      Physical volume "/dev/sda3" successfully created.
    [root@backup03 ~]# pvdisplay

    6、将分区sda3加入root所在的vg(centos)里 。

    [root@backup03 ~]# vgextend centos /dev/sda3
      Volume group "centos" successfully extended
    [root@backup03 ~]# vgdisplay -v centos

    7、扩展root根分区所在的逻辑卷大小,vgdisplay可以看到root所在lv大小已经发生变化。

    这里37G要按照实际情况来。当然也可以不挂在/dev/centos/root,有些是挂在/dev/centos/home里面的。

    lvextend -L +37G /dev/centos/root
    vgdisplay -v

    8、根目录大小依然没变化

    df -h 

    9,确认root文件系统的类型是xfs后,使用xfs_growfs命令扩展根目录大小。

    mount

    10,使用xfs_growfs命令扩展根目录大小

    xfs_growfs /dev/centos/root

    11,最后使用df命令,确认根目录大小已经从原来的10GB扩展为40GB。

    df -h
  • 相关阅读:
    封装一个通用递归算法,使用TreeIterator和TreeMap来简化你的开发工作。
    优化特性(Attribute)性能
    不需要了解任何底层知识,就可以汉化!Let`s go!!!
    颠覆你对方法调用的看法!
    实际项目中面向对象的最佳实践
    递归使用触发器
    关于稀疏数组
    121-django中的Http404处理
    120-在前端使用django-ckeditor,很简单,很方便
    119-用django实现评论功能
  • 原文地址:https://www.cnblogs.com/lowislucifer/p/15034053.html
Copyright © 2011-2022 走看看