centos7 xfs磁盘管理(格式化、在线扩容)

环境:

centos 7

原有磁盘sda:100G

新增磁盘sda :200G,总磁盘300G

查看磁盘结构

第一步:新建一个分区

[root@hadoop6 ~]# fdisk /dev/sda

[root@hadoop6 ~]# 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
Partition type:
   p   primary (2 primary, 0 extended, 2 free)
   e   extended
Select (default p): p
Partition number (3,4, default 3): ENTER //默认为下一个分区号,也可以自己指定
First sector (209715200-629145599, default 209715200): NTER //也可以指定大小+5G,如果直接输入回车则使用所有空间
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): t  //修改分区格式,下面选的3是上面的sda3,默认格式是Linux
Partition number (1-3, default 3): 3  
Hex code (type L to list all codes): 8e //(说明:8e为Linux LVM格式的编码)
Changed type of partition 'Linux' to 'Linux LVM'

Command (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.

第二步、创建物理卷pv。

[root@EZSonar ~]# pvcreate /dev/sda3        //   创建pv  

Physical volume "/dev/sda3" successfully created

 如果创建物理卷pv出错则执行 partprobe 刷新分区

[root@EZSonar ~]# pvdisplay /dev/sdb5        //   查看pv 

-- "/dev/sdb5" is a new physical volume of "200.00 GiB"

--- NEW Physical volume ---

PV Name               /dev/sda3

VG Name               

PV Size               200.00 GiB

Allocatable           NO

PE Size               0   

Total PE              0

Free PE               0

Allocated PE          0

PV UUID               Hjoga4-EXmd-G53T-vAvQ-kDtA-60e2-vEHzBY

第三步、查看已有的VG配置详情

[root@EZSonar ~]# vgdisplay 

--- Volume group ---

  VG Name               centos_cos7-root

System ID             

Format                lvm2

Metadata Areas        1

Metadata Sequence No  4

VG Access             read/write

VG Status             resizable

MAX LV                0

Cur LV                3

Open LV               3

Max PV                0

Cur PV                1

Act PV                1

VG Size               291.0 GiB

PE Size               4.00 MiB

Total PE              8141

Alloc PE / Size       8141 / 31.80 GiB

Free  PE / Size       200/ 0   

VG UUID               JXOpXA-jkl5-Jdfp-IHeS-6MpP-8V3q-Vl3lMh

增减逻辑卷

 [root@hadoop6 ~]# vgextend centos_cos7 /dev/sda3      // 扩展vg  将pv加入到vg_ezsonar 

进行扩容

2种方式扩容,第一种如果没扩容满就用vgdisplay看一下空间

[root@hadoop6 ~]# lvextend -l 100%FREE /dev/mapper/centos_cos7-root    
[root@hadoop6 ~]# lvextend -L +91G /dev/mapper/centos_cos7-root   

[root@hadoop6 ~]# vgdisplay
  --- Volume group ---
  VG Name               centos_cos7
  System ID             
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  6
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               2
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size               298.99 GiB
  PE Size               4.00 MiB
  Total PE              76542
  Alloc PE / Size       76542 / 298.99 GiB
  Free  PE / Size       0 / 0   
  VG UUID               E0iH38-Op8E-YI7P-4usw-KhmF-kdo4-4Qf8pA

文件系统扩容

以上只是卷扩容了,还要对文件系统实现真正扩容

Centos7使用XFS

[root@Cloud01 ~]# xfs_growfs /dev/mapper/centos-root

Centos6使用resize2fs

[root@Cloud01 ~]# resize2fs /dev/mapper/centos-root

看扩容结果

[root@hadoop6 ~]# df -h

[root@hadoop6 ~]# df -h
Filesystem                    Size  Used Avail Use% Mounted on
devtmpfs                       24G     0   24G   0% /dev
tmpfs                          24G     0   24G   0% /dev/shm
tmpfs                          24G   53M   24G   1% /run
tmpfs                          24G     0   24G   0% /sys/fs/cgroup
/dev/mapper/centos_cos7-root  291G   62G  230G  22% /
/dev/sda1                    1014M  286M  729M  29% /boot
tmpfs                         4.8G   12K  4.8G   1% /run/user/42
cm_processes                   24G   20M   24G   1% /run/cloudera-scm-agent/process
tmpfs                         4.8G     0  4.8G   0% /run/user/0

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值