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
  • 相关阅读:
    Ceph纠删码编码机制
    Vmware error:无法获得 VMCI 驱动程序的版本: 句柄无效。
    Virtual Box 安装过程(卸载Vmware后)
    解决安卓SDK更新dl-ssl.google.com无法连接的方法
    《中文核心期刊要目总览(2014年版)》——计算机、自动化类
    2014中国科技核心期刊(中国科技论文统计源期刊)名录——计算机类
    计算机专业方面的期刊
    Office 中的各种小tips(更新中)
    博客园添加背景音乐
    jmeter定时器
  • 原文地址:https://www.cnblogs.com/lowislucifer/p/15034053.html
Copyright © 2011-2022 走看看