centos7 磁盘目录扩容

1.使用 fdisk -l 查看到这块新盘为/dev/sde:
Disk /dev/sde: 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

2.对新盘分区
[root@hxlhost ~]# fdisk /dev/sde
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 (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
Partition number (1-4, default 1):
First sector (2048-104857599, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-104857599, default 104857599):
Using default value 104857599
Partition 1 of type Linux and of size 50 GiB is set

Command (m for help): t
Selected partition 1
Hex code (type L to list all codes): 8e
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.
Syncing disks.
[root@hxlhost ~]# partprobe

使用 fdisk 命令对新盘进行分区,这里建立了一个主分区/dev/sde,大小50GB,最后使用 partprobe 命令重新读取分区表:
在分区的过程中,注意设置格式为8e,这是LVM的分区格式。


3、创建物理卷(PV)
使用 pvcreate 命令创建物理卷,pvdisplay 查看物理卷信息:
[root@hxlhost ~]# pvcreate /dev/sde1
  Physical volume "/dev/sde1" successfully created.
[root@hxlhost ~]# pvscan
  PV /dev/sda3   VG vgroot          lvm2 [32.80 GiB / 0    free]
  PV /dev/sde1                      lvm2 [<50.00 GiB]
  Total: 2 [<82.80 GiB] / in use: 1 [32.80 GiB] / in no VG: 1 [<50.00 GiB]
 
4、将PV加入卷组(VG)

使用 vgdisplay 查看卷组信息
[root@hxlhost ~]# vgdisplay
  --- Volume group ---
  VG Name               vgroot
  System ID             
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  2
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                1
  Open LV               1
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               32.80 GiB
  PE Size               4.00 MiB
  Total PE              8397
  Alloc PE / Size       8397 / 32.80 GiB
  Free  PE / Size       0 / 0   
  VG UUID               hDjETu-sNQM-ZpM1-YcPJ-NC6H-8bCS-PedQmr
 
使用 vgextend 命令把/dev/vdb1加入到centos:
[root@hxlhost ~]# vgextend vgroot /dev/sde1
  Volume group "vgroot" successfully extended
 
[root@hxlhost ~]# vgdisplay
  --- Volume group ---
  VG Name               vgroot
  System ID             
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  3
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                1
  Open LV               1
  Max PV                0
  Cur PV                2
  Act PV                2
  VG Size               <82.80 GiB
  PE Size               4.00 MiB
  Total PE              21196
  Alloc PE / Size       8397 / 32.80 GiB
  Free  PE / Size       12799 / <50.00 GiB
  VG UUID               hDjETu-sNQM-ZpM1-YcPJ-NC6H-8bCS-PedQmr
 
5.创建逻辑卷(LV)&扩容
查看lv
[root@hxlhost ~]# lvdisplay
  --- Logical volume ---
  LV Path                /dev/vgroot/lvroot
  LV Name                lvroot
  VG Name                vgroot
  LV UUID                wHodVu-dCCm-vndQ-S6IH-jWRY-hNJP-RWBDPH
  LV Write Access        read/write
  LV Creation host, time localhost, 2020-11-06 01:25:50 -0500
  LV Status              available
  # open                 1
  LV Size                32.80 GiB
  Current LE             8397
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:0

扩容:
[root@hxlhost ~]# lvextend -l +12799 /dev/vgroot/lvroot
  Size of logical volume vgroot/lvroot changed from 32.80 GiB (8397 extents) to <82.80 GiB (21196 extents).
  Logical volume vgroot/lvroot successfully resized.

6.使用 xfs_growfs 命令在线调整xfs格式文件系统大小(CentOS6使用resize2fs):
[root@hxlhost ~]# df -h
Filesystem                 Size  Used Avail Use% Mounted on
devtmpfs                   2.9G     0  2.9G   0% /dev
tmpfs                      2.9G     0  2.9G   0% /dev/shm
tmpfs                      2.9G  9.1M  2.9G   1% /run
tmpfs                      2.9G     0  2.9G   0% /sys/fs/cgroup
/dev/mapper/vgroot-lvroot   33G   22G   12G  66% /
/dev/sda1                  197M  144M   54M  73% /boot
tmpfs                      581M     0  581M   0% /run/user/0

[root@hxlhost ~]# xfs_growfs /dev/mapper/vgroot-lvroot
meta-data=/dev/mapper/vgroot-lvroot isize=512    agcount=4, agsize=2149632 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=0 spinodes=0
data     =                       bsize=4096   blocks=8598528, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal               bsize=4096   blocks=4198, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 8598528 to 21704704


[root@hxlhost ~]# df -h
Filesystem                 Size  Used Avail Use% Mounted on
devtmpfs                   2.9G     0  2.9G   0% /dev
tmpfs                      2.9G     0  2.9G   0% /dev/shm
tmpfs                      2.9G  9.1M  2.9G   1% /run
tmpfs                      2.9G     0  2.9G   0% /sys/fs/cgroup
/dev/mapper/vgroot-lvroot   83G   22G   62G  27% /
/dev/sda1                  197M  144M   54M  73% /boot
tmpfs                      581M     0  581M   0% /run/user/0

 

--The End --

上一篇:如何动态修改SAP CRM WebClient UI表格栏的宽度


下一篇:SAP WebClient UI One Hit Navigation的实现方法