=======
概念:据说默认centos都是基于LVM的
LVM:LVM是逻辑盘卷管理(Logical Volume Manager)的简称,它是Linux环境下对磁盘分区进行管理的一种机制.
LVM 更加详细的说明可点这里:http://www.cnblogs.com/mchina/p/linux-centos-logical-volume-manager-lvm.html
fdisk 命令用法http://blog.sina.com.cn/s/blog_66b448620100ibay.html
查看磁盘空间,根目录太小了,希望增加磁盘
在vsphere上修改磁盘的大小,重启进来。
[root@ucx-auto ~]# df -lh
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/centos-root   30G   23G  7.1G  76% /
devtmpfs                 5.8G     0  5.8G   0% /dev
tmpfs                    5.8G     0  5.8G   0% /dev/shm
tmpfs                    5.8G  8.9M  5.8G   1% /run
tmpfs                    5.8G     0  5.8G   0% /sys/fs/cgroup
/dev/sda1                497M  155M  343M  32% /boot
tmpfs                    1.2G     0  1.2G   0% /run/user/0
一。查看下LV
[root@ucx-auto ~]# lvdisplay
  --- Logical volume ---
  LV Path                /dev/centos/swap
  LV Name                swap
  VG Name                centos
  LV UUID                trGefC-4mxg-BkS6-sywT-ie3O-deA3-WC0EDQ
  LV Write Access        read/write
  LV Creation host, time localhost, 2016-07-26 17:38:31 +0800
  LV Status              available
  # open                 2
  LV Size                2.02 GiB
  Current LE             516
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:0
  --- Logical volume ---
  LV Path                /dev/centos/root
  LV Name                root
  VG Name                centos
  LV UUID                MRmrQV-MDKZ-ZJbQ-cvDP-nMEY-hWJk-xFCceo
  LV Write Access        read/write
  LV Creation host, time localhost, 2016-07-26 17:38:31 +0800
  LV Status              available
  # open                 1
  LV Size                66.49 GiB
  Current LE             17022
  Segments               2
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:1
二:查看机器所挂硬盘个数及分区情况
[root@ucx-auto ~]# fdisk -l
Disk /dev/sda: 75.2 GB, 75161927680 bytes, 146800640 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x000cfb48
   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     1026047      512000   83  Linux
/dev/sda2         1026048    67108863    33041408   8e  Linux LVM
Disk /dev/mapper/centos-swap: 2164 MB, 2164260864 bytes, 4227072 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk /dev/mapper/centos-root: 31.7 GB, 31666995200 bytes, 61849600 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
如上 有一块磁盘/dev/sda 有两个分区。就用了33G,说明还有未分区的
三:/dev/sda进行分区,做这个时候忘记截图了 ,大概是下面这样,如果让你输入分区号,顺延下去即可。
3.换个姿势再来一次
[root@ucx-auto dev]# xfs_growfs /dev/mapper/centos-root
meta-data=/dev/mapper/centos-root isize=256    agcount=4, agsize=1932800 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=0        finobt=0
data     =                       bsize=4096   blocks=7731200, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=0
log      =internal               bsize=4096   blocks=3775, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 7731200 to 17430528
4.看到根目录已经扩大了
[root@ucx-auto dev]# df -lh
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/centos-root   67G   23G   45G  34% /
devtmpfs                 5.8G     0  5.8G   0% /dev
tmpfs                    5.8G     0  5.8G   0% /dev/shm
tmpfs                    5.8G  8.9M  5.8G   1% /run
tmpfs                    5.8G     0  5.8G   0% /sys/fs/cgroup
/dev/sda1                497M  155M  343M  32% /boot
tmpfs                    1.2G     0  1.2G   0% /run/user/0
Linux札记2-esxi上为基于基于LVM的centos7的根目录扩容
原文:http://www.cnblogs.com/junelan/p/5763082.html