centos7磁盘扩容(Vmware)

一、Vmware的centos7系统,在VMWare菜单增加到的磁盘大小,如下图所示:
在这里插入图片描述
查看磁盘信息

fdisk -l

Disk /dev/sda: 214.7 GB, 214748364800 bytes, 419430400 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: 0x000afd39

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     2099199     1048576   83  Linux
/dev/sda2         2099200   167772159    82836480   8e  Linux LVM

Disk /dev/mapper/centos-root: 53.7 GB, 53687091200 bytes, 104857600 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-swap: 4160 MB, 4160749568 bytes, 8126464 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-home: 27.0 GB, 26969374720 bytes, 52674560 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


二、分区

 fdisk /dev/sda

提示:
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): n

Command (m for help): n

输入 n(新增加一个分区)
Partition type:
p primary (2 primary, 0 extended, 2 free)
e extended
Select (default p): p
输入p 分区类型选择为主分区

Select (default p): p

下面 2个步骤 按回车键

回车1 默认(起始扇区) 
回车2 默认(结束扇区) 
Partition number (3,4, default 3): 
First sector (167772160-419430399, default 167772160): 
Using default value 167772160
Last sector, +sectors or +size{K,M,G} (167772160-419430399, default 419430399): 
Using default value 419430399
Partition 3 of type Linux and of size 120 GiB is set

写分区表
Command (m for help): w

Command (m for help): w

q 完成,退出fdisk命令

三、重启系统

reboot

四、格式化分区

mkfs.ext3 /dev/sda3

五、进入lvm管理

lvm

初始分区3

pvcreate /dev/sda3

初始化过的分区加入到虚拟卷组cento

vgextend centos /dev/sda3

查看free PE /Site

vgdisplay -v
lvm> pvcreate /dev/sda3
WARNING: ext3 signature detected on /dev/sda3 at offset 1080. Wipe it? [y/n]: y
  Wiping ext3 signature on /dev/sda3.
  Physical volume "/dev/sda3" successfully created.
lvm> vgextend centos /dev/sda3
  Volume group "centos" successfully extended
lvm> vgdisplay -v
  --- Volume group ---
  VG Name               centos
  System ID             
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  5
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                3
  Open LV               3
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size               198.99 GiB
  PE Size               4.00 MiB
  Total PE              50942
  Alloc PE / Size       20222 / 78.99 GiB
  Free  PE / Size       30720 / 120.00 GiB
  VG UUID               UgrPCL-mZx6-dgAZ-LpK9-ZSnN-VeUK-V6UAjq
   
  --- Logical volume ---
  LV Path                /dev/centos/swap
  LV Name                swap
  VG Name                centos
  LV UUID                xEE16q-ZJSb-cwXX-QOKg-Owh7-kAl1-c0MI8I
  LV Write Access        read/write
  LV Creation host, time localhost, 2021-06-01 20:01:01 -0400
  LV Status              available
  # open                 2
  LV Size                <3.88 GiB
  Current LE             992
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:1
   
  --- Logical volume ---
  LV Path                /dev/centos/home
  LV Name                home
  VG Name                centos
  LV UUID                FWFmkC-CIOW-W0PO-bdaW-GyRH-ygLK-Yw6ppU
  LV Write Access        read/write
  LV Creation host, time localhost, 2021-06-01 20:01:01 -0400
  LV Status              available
  # open                 1
  LV Size                <25.12 GiB
  Current LE             6430
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:2
   
  --- Logical volume ---
  LV Path                /dev/centos/root
  LV Name                root
  VG Name                centos
  LV UUID                ggGKAh-GCOL-bFrp-IZuc-02wr-WLqF-80U5mo
  LV Write Access        read/write
  LV Creation host, time localhost, 2021-06-01 20:01:01 -0400
  LV Status              available
  # open                 1
  LV Size                50.00 GiB
  Current LE             12800
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:0
   
  --- Physical volumes ---
  PV Name               /dev/sda2     
  PV UUID               sKBt1K-e2c6-GihZ-Ed25-6yqi-4iNN-p7aH0D
  PV Status             allocatable
  Total PE / Free PE    20223 / 1
   
  PV Name               /dev/sda3     
  PV UUID               dHNSlf-9zcW-bS7I-lowG-07pO-5XuD-B2eqbF
  PV Status             allocatable
  Total PE / Free PE    30719 / 30719

六、扩展已有卷的容量(Total PE / Free PE 30719 / 30719;vgdisplay -v查看到的free PE /Site)

lvextend -l+30719 /dev/mapper/centos-root

查看卷容量

pvdisplay 
 pvdisplay
  --- Physical volume ---
  PV Name               /dev/sda2
  VG Name               centos
  PV Size               <79.00 GiB / not usable 3.00 MiB
  Allocatable           yes 
  PE Size               4.00 MiB
  Total PE              20223
  Free PE               1
  Allocated PE          20222
  PV UUID               sKBt1K-e2c6-GihZ-Ed25-6yqi-4iNN-p7aH0D
   
  --- Physical volume ---
  PV Name               /dev/sda3
  VG Name               centos
  PV Size               120.00 GiB / not usable 4.00 MiB
  Allocatable           yes 
  PE Size               4.00 MiB
  Total PE              30719
  Free PE               30719
  Allocated PE          0
  PV UUID               dHNSlf-9zcW-bS7I-lowG-07pO-5XuD-B2eqbF

退出lvm

quit

七、文件系统的真正扩容

 xfs_growfs /dev/mapper/centos-root

完成;df -h 查看磁盘情况

df -h
Filesystem               Size  Used Avail Use% Mounted on
devtmpfs                 1.9G     0  1.9G   0% /dev
tmpfs                    1.9G     0  1.9G   0% /dev/shm
tmpfs                    1.9G   12M  1.9G   1% /run
tmpfs                    1.9G     0  1.9G   0% /sys/fs/cgroup
/dev/mapper/centos-root  170G  2.6G  168G   2% /
/dev/sda1               1014M  239M  776M  24% /boot
/dev/mapper/centos-home   26G   33M   26G   1% /home
tmpfs                    378M     0  378M   0% /run/user/0
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值