1. 程式人生 > >LVM擴容根分割槽

LVM擴容根分割槽

LVM的工作方式      

 

 

 

 

LVM管理工具集

 

 

[root@wendang ~]# lsblk

NAME            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT

sda               8:0    0   50G  0 disk

├─sda1            8:1    0    1G  0 part /boot

├─sda2            8:2    0   15G  0 part

│ ├─centos-root 253:0    0 13.4G  0 lvm  /

│ └─centos-swap 253:1    0  1.6G  0 lvm  [SWAP]

└─sda3            8:3    0   10G  0 part

sr0              11:0    1 1024M  0 rom 

[root@wendang ~]#  pvcreate /dev/sda3

  Physical volume "/dev/sda3" successfully created.

[root@wendang ~]# vgs

  VG     #PV #LV #SN Attr   VSize   VFree

  centos   1   2   0 wz--n- <15.00g    0

[root@wendang ~]# vgextend centos /dev/sda3

  Volume group "centos" successfully extended

[root@wendang ~]#  vgs

  VG     #PV #LV #SN Attr   VSize  VFree 

  centos   2   2   0 wz--n- 24.99g <10.00g

[root@wendang ~]# lvs

  LV   VG     Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert

  root centos -wi-ao---- 13.39g                                                   

  swap centos -wi-ao----  1.60g                                                   

[root@wendang ~]# df -h

檔案系統                 容量  已用  可用 已用% 掛載點

/dev/mapper/centos-root   14G  1.1G   13G    8% /

devtmpfs                 908M     0  908M    0% /dev

tmpfs                    920M     0  920M    0% /dev/shm

tmpfs                    920M  8.8M  911M    1% /run

tmpfs                    920M     0  920M    0% /sys/fs/cgroup

/dev/sda1               1014M  145M  870M   15% /boot

tmpfs                    184M     0  184M    0% /run/user/0

".

[root@wendang ~]# df -h

檔案系統                 容量  已用  可用 已用% 掛載點

/dev/mapper/centos-root   14G  1.1G   13G    8% /

devtmpfs                 908M     0  908M    0% /dev

tmpfs                    920M     0  920M    0% /dev/shm

tmpfs                    920M  8.8M  911M    1% /run

tmpfs                    920M     0  920M    0% /sys/fs/cgroup

/dev/sda1               1014M  145M  870M   15% /boot

tmpfs                    184M     0  184M    0% /run/user/0

[root@wendang ~]#

[root@wendang ~]# lsblk

NAME            MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT

sda               8:0    0   50G  0 disk

├─sda1            8:1    0    1G  0 part /boot

├─sda2            8:2    0   15G  0 part

│ ├─centos-root 253:0    0 13.4G  0 lvm  /

│ └─centos-swap 253:1    0  1.6G  0 lvm  [SWAP]

└─sda3            8:3    0   10G  0 part

sr0              11:0    1 1024M  0 rom 

[root@wendang ~]# pvdisplay

  --- Physical volume ---

  PV Name               /dev/sda2

  VG Name               centos

  PV Size               <15.00 GiB / not usable 3.00 MiB

  Allocatable           yes (but full)

  PE Size               4.00 MiB

  Total PE              3839

  Free PE               0

  Allocated PE          3839

  PV UUID               mh1zwp-wM9K-iSCl-5fgJ-evDG-d3zZ-AozMWl

  

  --- Physical volume ---

  PV Name               /dev/sda3

  VG Name               centos

  PV Size               10.00 GiB / not usable 4.00 MiB

  Allocatable           yes

  PE Size               4.00 MiB

  Total PE              2559

  Free PE               2559

  Allocated PE          0

  PV UUID               IZJrH3-UswX-QXNe-Twih-oAR5-6cL3-l0LKGI

  

[root@wendang ~]# vgdisplay

  --- Volume group ---

  VG Name               centos

  System ID            

  Format                lvm2

  Metadata Areas        2

  Metadata Sequence No  4

  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               24.99 GiB

  PE Size               4.00 MiB

  Total PE              6398

  Alloc PE / Size       3839 / <15.00 GiB

  Free  PE / Size       2559 / <10.00 GiB

  VG UUID               ZJCdml-lltw-AUau-NBJL-1QH1-2SAn-S5gbUB

  

[root@wendang ~]# lvdisplay

  --- Logical volume ---

  LV Path                /dev/centos/swap

  LV Name                swap

  VG Name                centos

  LV UUID                hp3gdC-nima-jxLh-Be3r-c0dW-6n5S-Whnjfh

  LV Write Access        read/write

  LV Creation host, time wendang, 2019-09-17 00:12:50 +0800

  LV Status              available

  # open                 2

  LV Size                1.60 GiB

  Current LE             410

  Segments               1

  Allocation             inherit

  Read ahead sectors     auto

  - currently set to     8192

  Block device           253:1

  

  --- Logical volume ---

  LV Path                /dev/centos/root

  LV Name                root

  VG Name                centos

  LV UUID                ZbNoyJ-6c9y-APnh-oxYl-clan-KbQN-qAwqo2

  LV Write Access        read/write

  LV Creation host, time wendang, 2019-09-17 00:12:50 +0800

  LV Status              available

  # open                 1

  LV Size                13.39 GiB

  Current LE             3429

  Segments               1

  Allocation             inherit

  Read ahead sectors     auto

  - currently set to     8192

  Block device           253:0

  

 

 [root@wendang ~]# lvextend -L +9G /dev/mapper/centos-root

  Size of logical volume centos/root changed from 13.39 GiB (3429 extents) to 22.39 GiB (5733 extents).

  Logical volume centos/root successfully resized.

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

meta-data=/dev/mapper/centos-root isize=512    agcount=4, agsize=877824 blks

         =                       sectsz=512   attr=2, projid32bit=1

         =                       crc=1        finobt=0 spinodes=0

data     =                       bsize=4096   blocks=3511296, imaxpct=25

         =                       sunit=0      swidth=0 blks

naming   =version 2              bsize=4096   ascii-ci=0 ftype=1

log      =internal               bsize=4096   blocks=2560, version=2

         =                       sectsz=512   sunit=0 blks, lazy-count=1

realtime =none                   extsz=4096   blocks=0, rtextents=0

data blocks changed from 3511296 to 5870592

[root@wendang ~]# df -h

檔案系統                 容量  已用  可用 已用% 掛載點

/dev/mapper/centos-root   23G  1.1G   22G    5% /

devtmpfs                 908M     0  908M    0% /dev

tmpfs                    920M     0  920M    0% /dev/shm

tmpfs                    920M  8.8M  911M    1% /run

tmpfs                    920M     0  920M    0% /sys/fs/cgroup

/dev/sda1               1014M  145M  870M   15% /boot

tmpfs    

               184M     0  184M    0% /run/user/0

 

以下為純命令

  1. fdisk /dev/sda 分割槽
  2. lsblk                    列出分割槽
  3. partprobe     重新整理分割槽
  4. lsblk
  5. pvcreate /dev/sda3          建立物理卷
  6. vgs                                        檢視卷組
  7. vgextend centos /dev/sda3     擴展卷組
  8. lvs              檢視邏輯卷
  9. df –h    檢視掛載
  10. pvdisplay           顯示物理卷    
  11. vgdisplay        顯示卷組
  12. lvdisplay          顯示邏輯卷
  13. lvextend -L +9G /dev/mapper/centos-root            擴充套件邏輯卷
  14. xfs_growfs /dev/mapper/centos-root              重新整理檔案系統容量
  15. df –h                   確認已經擴容
  16. ls
  17. pwd