• 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
  • 相关阅读:
    Spring MVC 程序首页的设置
    绿色版Tomcat 启动 + 停止 + 随系统自动启动
    Lazy Load, 延迟加载图片的 jQuery 插件
    ibatis参数传递小技巧
    SpringMVC接收页面表单参数-java-电脑编程网
    用 JS 点击左右按钮 使图片切换
    JS数组方法汇总 array数组元素的添加和删除
    关于jQuery UI 使用心得及技巧
    MySQL查询in操作 查询结果按in集合顺序显示_Mysql_脚本之家
    JSTL c标签,fn标签,fmt标签
  • 原文地址:https://www.cnblogs.com/lowislucifer/p/15034053.html
Copyright © 2020-2023  润新知