天天看点

Centos 7 扩容根分区 带多路径

 原有环境。,加了一块盘

Disk /dev/sdd: 53.7 GB, 53687091200 bytes, 104857600 sectors
[[email protected] bin]# df -h
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/centos-root   39G   27G   12G  70% /
devtmpfs                 3.8G     0  3.8G   0% /dev
tmpfs                    3.8G  637M  3.2G  17% /dev/shm
tmpfs                    3.8G  9.5M  3.8G   1% /run
tmpfs                    3.8G     0  3.8G   0% /sys/fs/cgroup
/dev/sda2               1014M  162M  853M  16% /boot
/dev/sda1                200M   12M  189M   6% /boot/efi
/dev/mapper/centos-home   19G  121M   19G   1% /home
tmpfs                    764M     0  764M   0% /run/user/0
tmpfs                    764M  4.0K  764M   1% /run/user/11012
/dev/sr0                  27M   27M     0 100% /run/media/grid/VMGUEST
tmpfs                    764M  4.0K  764M   1% /run/user/42
tmpfs                    764M   60K  764M   1% /run/user/11011


[[email protected] ~]# fdisk -l
WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.

Disk /dev/sda: 64.4 GB, 64424509440 bytes, 125829120 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk label type: gpt
Disk identifier: CD00EADA-F74F-4D55-AD41-D70B1DEDA13F


#         Start          End    Size  Type            Name
 1         2048       411647    200M  EFI System      EFI System Partition
 2       411648      2508799      1G  Microsoft basic 
 3      2508800    125827071   58.8G  Linux LVM       

Disk /dev/sdb: 53.7 GB, 53687091200 bytes, 104857600 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk label type: dos
Disk identifier: 0xd0ef036e

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048   104857599    52427776   8e  Linux LVM

Disk /dev/mapper/centos-root: 41.0 GB, 40978350080 bytes, 80035840 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes


Disk /dev/mapper/centos-swap: 2147 MB, 2147483648 bytes, 4194304 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes


Disk /dev/mapper/360022480b4f3c0d3febb0fcdcc29ae9f: 53.7 GB, 53687091200 bytes, 104857600 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk label type: dos
Disk identifier: 0xd0ef036e

                                        Device Boot      Start         End      Blocks   Id  System
/dev/mapper/360022480b4f3c0d3febb0fcdcc29ae9f1            2048   104857599    52427776   8e  Linux LVM

Disk /dev/mapper/centos-home: 20.0 GB, 20006830080 bytes, 39075840 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes


Disk /dev/sdc: 32.2 GB, 32212254720 bytes, 62914560 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes


Disk /dev/sdd: 26.8 GB, 26843545600 bytes, 52428800 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes


Disk /dev/mapper/data1: 26.8 GB, 26843545600 bytes, 52428800 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes


Disk /dev/mapper/crs1: 32.2 GB, 32212254720 bytes, 62914560 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes

[[email protected] ~]# 
           

 如果使用了多路径,则使用多路径磁盘

[[email protected] ~]# /usr/lib/udev/scsi_id -g -u -d /dev/sdb
360022480b4f3c0d3febb0fcdcc29ae9f

[[email protected] ~]# vi /etc/multipath.conf
multipaths {
        multipath {
                wwid 360003ff44dc75adca587c5166da5669d
                alias crs1
        }
        multipath {
                wwid 360003ff44dc75adcb9b3aee4e15aca4e
                alias data1
         }
      multipath {
                wwid 360022480b4f3c0d3febb0fcdcc29ae9f
                alias gdisk3
         }
}

[[email protected] ~]# multipath -F
Mar 30 23:36:40 | crs1: map in use
Mar 30 23:36:40 | failed to remove multipath map crs1
Mar 30 23:36:40 | data1: map in use
Mar 30 23:36:40 | failed to remove multipath map data1
[[email protected] ~]# multipath -v2
Mar 30 23:36:42 | 3600224806537865b71d71153cc88e3b2: ignoring map
create: gdisk3 (360022480b4f3c0d3febb0fcdcc29ae9f) undef Msft    ,Virtual Disk    
size=50G features='0' hwhandler='0' wp=undef
`-+- policy='service-time 0' prio=1 status=undef
  `- 0:0:0:2 sdb 8:16 undef ready running
[[email protected] ~]# 

[[email protected] ~]# fdisk -l |grep /dev/map
WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.
Disk /dev/mapper/centos-root: 41.0 GB, 40978350080 bytes, 80035840 sectors
Disk /dev/mapper/centos-swap: 2147 MB, 2147483648 bytes, 4194304 sectors
Disk /dev/mapper/centos-home: 20.0 GB, 20006830080 bytes, 39075840 sectors
Disk /dev/mapper/data1: 26.8 GB, 26843545600 bytes, 52428800 sectors
Disk /dev/mapper/crs1: 32.2 GB, 32212254720 bytes, 62914560 sectors
Disk /dev/mapper/gdisk3: 53.7 GB, 53687091200 bytes, 104857600 sectors
[[email protected] ~]# 


[[email protected] ~]# fdisk /dev/mapper/gdisk3

The device presents a logical sector size that is smaller than
the physical sector size. Aligning to a physical sector (or optimal
I/O) size boundary is recommended, or performance may be impacted.
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.

WARNING: Re-reading the partition table failed with error 22: Invalid argument.
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.
[[email protected] ~]# 

[[email protected] ~]# fdisk -l |grep /dev/map
WARNING: fdisk GPT support is currently new, and therefore in an experimental phase. Use at your own discretion.
Disk /dev/mapper/centos-root: 41.0 GB, 40978350080 bytes, 80035840 sectors
Disk /dev/mapper/centos-swap: 2147 MB, 2147483648 bytes, 4194304 sectors
Disk /dev/mapper/centos-home: 20.0 GB, 20006830080 bytes, 39075840 sectors
Disk /dev/mapper/data1: 26.8 GB, 26843545600 bytes, 52428800 sectors
Disk /dev/mapper/crs1: 32.2 GB, 32212254720 bytes, 62914560 sectors
Disk /dev/mapper/gdisk3: 53.7 GB, 53687091200 bytes, 104857600 sectors
/dev/mapper/gdisk3p1            2048   104857599    52427776   8e  Linux LVM
           

创建pv

[[email protected] mapper]# pvcreate  /dev/mapper/gdisk3p1
  Physical volume "/dev/mapper/gdisk3p1" successfully created.
           

加入到VG 

[[email protected] bin]# vgdisplay
  --- Volume group ---
  VG Name               centos
  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               58.80 GiB
  PE Size               4.00 MiB
  Total PE              15053
  Alloc PE / Size       15052 / <58.80 GiB
  Free  PE / Size       1 / 4.00 MiB
  VG UUID               JLElo1-EgAg-T3VS-FdRC-axXQ-dxy3-uvcZUB
   
[[email protected] bin]# 

[[email protected] mapper]# vgextend centos /dev/mapper/gdisk3p1
  Volume group "centos" successfully extended

[[email protected] mapper]# vgdisplay
  --- 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               <108.80 GiB
  PE Size               4.00 MiB
  Total PE              27852
  Alloc PE / Size       15052 / <58.80 GiB
  Free  PE / Size       12800 / 50.00 GiB
  VG UUID               JLElo1-EgAg-T3VS-FdRC-axXQ-dxy3-uvcZUB
   
           
[[email protected] mapper]# df -h
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/centos-root   39G   27G   12G  70% /
devtmpfs                 3.8G     0  3.8G   0% /dev
tmpfs                    3.8G  637M  3.2G  17% /dev/shm
tmpfs                    3.8G  9.1M  3.8G   1% /run
tmpfs                    3.8G     0  3.8G   0% /sys/fs/cgroup
/dev/sda2               1014M  162M  853M  16% /boot
/dev/sda1                200M   12M  189M   6% /boot/efi
/dev/mapper/centos-home   19G  121M   19G   1% /home
tmpfs                    764M   20K  764M   1% /run/user/42
tmpfs                    764M     0  764M   0% /run/user/11012
tmpfs                    764M     0  764M   0% /run/user/0

扩容所有空间至根分区

[[email protected] mapper]# lvextend -l +100%FREE /dev/mapper/centos-root
  Size of logical volume centos/root changed from 38.16 GiB (9770 extents) to 88.16 GiB (22570 extents).
  Logical volume centos/root successfully resized.
[[email protected] mapper]# 


   
[[email protected] mapper]# vgdisplay 
  --- Volume group ---
  VG Name               centos
  System ID             
  Format                lvm2
  Metadata Areas        2
  Metadata Sequence No  6
  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               <108.80 GiB
  PE Size               4.00 MiB
  Total PE              27852
  Alloc PE / Size       27852 / <108.80 GiB
  Free  PE / Size       0 / 0   
  VG UUID               JLElo1-EgAg-T3VS-FdRC-axXQ-dxy3-uvcZUB
   
使用xfs_growf 显示在线增加空间

[[email protected] mapper]# xfs_growfs /dev/mapper/centos-root
meta-data=/dev/mapper/centos-root isize=512    agcount=4, agsize=2501120 blks
         =                       sectsz=4096  attr=2, projid32bit=1
         =                       crc=1        finobt=0 spinodes=0
data     =                       bsize=4096   blocks=10004480, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal               bsize=4096   blocks=4885, version=2
         =                       sectsz=4096  sunit=1 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 10004480 to 23111680
[[email protected] mapper]# 
           

继续阅读