wmware exsi的centos7的系统磁盘扩容

[root@node4 opt]# df -h
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/centos-root   50G   34G   17G  68% /
devtmpfs                 5.8G     0  5.8G   0% /dev
tmpfs                    5.8G     0  5.8G   0% /dev/shm
tmpfs                    5.8G  497M  5.4G   9% /run
tmpfs                    5.8G     0  5.8G   0% /sys/fs/cgroup
/dev/sda1               1014M  145M  870M  15% /boot
/dev/mapper/centos-home   46G  2.3G   43G   6% /home
tmpfs                    1.2G     0  1.2G   0% /run/user/0

需要对 /dev/mapper/centos-root , /dev/mapper/centos-home 进行扩容
/dev/mapper/centos-root 增加200G
/dev/mapper/centos-home 增加100G

[root@node4 opt]# fdisk -l

Disk /dev/sda: 107.4 GB, 107374182400 bytes, 209715200 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: 0x00007ee7

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     2099199     1048576   83  Linux
/dev/sda2         2099200   209715199   103808000   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: 48.4 GB, 48444211200 bytes, 94617600 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是磁盘设备,属于物理卷,使用pvdisplay可以查看
/dev/mapper/centos-root这是逻辑卷,使用lvdisplay可以查看

扩展磁盘

将硬盘从100GB扩大为300GB, 然后重启。

再次使用fdisk -l

[root@node4 home]# fdisk -l

Disk /dev/sda: 322.1 GB, 322122547200 bytes, 629145600 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: 0x00007ee7

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     2099199     1048576   83  Linux
/dev/sda2         2099200   209715199   103808000   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: 48.4 GB, 48444211200 bytes, 94617600 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

新建sda3分区
2.1 【fdisk -l】 最大分区为/dev/sda2,说明新创建的分区将会是sda3(在后面的步骤会进行选择)
2.2 输入【fdisk /dev/sda】
2.2.1命令行提示下输入【m】
2.2.2输入命令【n】添加新分区。
2.2.3输入命令【p】创建主分区。
2.2.4输入【回车】,选择默认
2.2.5输入【回车】,选择默认
2.2.6输入【w】,保持修改
2.3 输入【reboot】 重启linux,必须reboot,否则/dev/sda3无法格式化。
2.4 这时在/dev/目录下,才能看到了新的分区比如/dev/sda3

具体操作如下

[root@node4 home]# 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): m
Command action
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   g   create a new empty GPT partition table
   G   create an IRIX (SGI) partition table
   l   list known partition types
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   s   create a new empty Sun disklabel
   t   change a partition's system id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit
   x   extra functionality (experts only)

Command (m for help): n
Partition type:
   p   primary (2 primary, 0 extended, 2 free)
   e   extended
Select (default p): p
Partition number (3,4, default 3): 
First sector (209715200-629145599, default 209715200): 
Using default value 209715200
Last sector, +sectors or +size{K,M,G} (209715200-629145599, default 629145599): 
Using default value 629145599
Partition 3 of type Linux and of size 200 GiB is set

Command (m for help): w
The partition table has been altered!

fdisk -l

[root@node4 home]# fdisk -l

Disk /dev/sda: 322.1 GB, 322122547200 bytes, 629145600 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: 0x00007ee7

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     2099199     1048576   83  Linux
/dev/sda2         2099200   209715199   103808000   8e  Linux LVM
/dev/sda3       209715200   629145599   209715200   83  Linux

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: 48.4 GB, 48444211200 bytes, 94617600 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

重启下Linux reboot

给刚新建的分区 /dev/sda3 创建pv

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

把pv加入到vg中,相当于扩充vg的大小

先使用vgs查看vg组

[root@node4 ~]# vgs
  VG     #PV #LV #SN Attr   VSize   VFree
  centos   1   3   0 wz--n- <99.00g 4.00m

扩展vg,使用vgextend命令

[root@node4 ~]# vgextend centos /dev/sda3
  Volume group "centos" successfully extended
[root@node4 ~]# vgs
  VG     #PV #LV #SN Attr   VSize   VFree  
  centos   2   3   0 wz--n- 298.99g 200.00g
[root@node4 ~]# lvs
  LV   VG     Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  home centos -wi-ao---- <45.12g                                                    
  root centos -wi-ao----  50.00g                                                    
  swap centos -wi-ao----  <3.88g         

虽然我们把vg扩展了,但是lv还没有扩展

扩展lv,使用extend命令

[root@node4 ~]# lvextend -L +200G /dev/mapper/centos-root
  Size of logical volume centos/root changed from 50.00 GiB (12800 extents) to 250.00 GiB (64000 extents).
  Logical volume centos/root successfully resized.
[root@node4 ~]# lvs
  LV   VG     Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  home centos -wi-ao---- <45.12g                                                    
  root centos -wi-ao---- 250.00g                                                    
  swap centos -wi-ao----  <3.88g

使用df -h

[root@node4 ~]# df -h
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/centos-root   50G   34G   17G  68% /
devtmpfs                 5.8G     0  5.8G   0% /dev
tmpfs                    5.8G     0  5.8G   0% /dev/shm
tmpfs                    5.8G  8.8M  5.8G   1% /run
tmpfs                    5.8G     0  5.8G   0% /sys/fs/cgroup
/dev/sda1               1014M  145M  870M  15% /boot
/dev/mapper/centos-home   46G  2.3G   43G   6% /home
tmpfs                    1.2G     0  1.2G   0% /run/user/0

xfs_growfs /dev/mapper/centos-root 命令使系统重新读取大小

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值