Expand volume in Linux

Example:

[root@test home]# lsblk
NAME            MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
fd0               2:0    1     4K  0 disk
sda               8:0    0   700G  0 disk
├─sda1            8:1    0     1G  0 part /boot
└─sda2            8:2    0   199G  0 part
  ├─centos-root 253:0    0    50G  0 lvm  /
  ├─centos-swap 253:1    0   7.9G  0 lvm  [SWAP]
  └─centos-home 253:2    0 141.1G  0 lvm  /home
sr0              11:0    1  1024M  0 rom

[root@test home]# lsblk -fp
NAME                        FSTYPE      LABEL UUID                                   MOUNTPOINT
/dev/fd0
/dev/sda
├─/dev/sda1                 xfs               5ea8ba5d-9e1f-44f2-83d5-82556769772f   /boot
└─/dev/sda2                 LVM2_member       LFSN0Q-qzcc-4hEo-yDkf-RkHH-zQ61-lXdeOk
  ├─/dev/mapper/centos-root xfs               bc7e9c4b-a595-4740-9e77-039c16c2484c   /
  ├─/dev/mapper/centos-swap swap              7e03f9e4-44c7-459f-a59b-b7d9b172d483   [SWAP]
  └─/dev/mapper/centos-home xfs               6fd28bf0-88d7-4a0e-9a95-2eaec09524d3   /home
/dev/sr0

# Extend Partition of /dev/sda2
[root@test home]# growpart /dev/sda 2
CHANGED: partition=2 start=2099200 old: size=417331200 end=419430400 new: size=1465907167 end=1468006367

[root@test home]# lsblk
NAME            MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
fd0               2:0    1     4K  0 disk
sda               8:0    0   700G  0 disk
├─sda1            8:1    0     1G  0 part /boot
└─sda2            8:2    0   699G  0 part
  ├─centos-root 253:0    0    50G  0 lvm  /
  ├─centos-swap 253:1    0   7.9G  0 lvm  [SWAP]
  └─centos-home 253:2    0 141.1G  0 lvm  /home
sr0              11:0    1  1024M  0 rom

# show physical volume information
[root@test home]# pvs
  PV         VG     Fmt  Attr PSize    PFree
  /dev/sda2  centos lvm2 a--  <199.00g 4.00m

# show volume group information
[root@test home]# vgs
  VG     #PV #LV #SN Attr   VSize    VFree
  centos   1   3   0 wz--n- <199.00g 4.00m

# Expand the Physical Volume on /dev/sda2 after enlarging the partition
[root@test home]# pvresize /dev/sda2
  Physical volume "/dev/sda2" changed
  1 physical volume(s) resized or updated / 0 physical volume(s) not resized

# show physical volume information
[root@test home]# pvs
  PV         VG     Fmt  Attr PSize    PFree
  /dev/sda2  centos lvm2 a--  <699.00g 500.00g

# show volume group information
[root@test home]# vgs
  VG     #PV #LV #SN Attr   VSize    VFree
  centos   1   3   0 wz--n- <699.00g 500.00g

# extend the size of the Logical Volume from the Volume Group
[root@test home]# lvextend -r -l +100%FREE /dev/mapper/centos-root
  Size of logical volume centos/root changed from 50.00 GiB (12800 extents) to 550.00 GiB (140801 extents).
  Logical volume centos/root successfully resized.
meta-data=/dev/mapper/centos-root isize=512    agcount=4, agsize=3276800 blks
         =                       sectsz=4096  attr=2, projid32bit=1
         =                       crc=1        finobt=0 spinodes=0
data     =                       bsize=4096   blocks=13107200, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0 ftype=1
log      =internal               bsize=4096   blocks=6400, version=2
         =                       sectsz=4096  sunit=1 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0
data blocks changed from 13107200 to 144180224

[root@test home]# lsblk
NAME            MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
fd0               2:0    1     4K  0 disk
sda               8:0    0   700G  0 disk
├─sda1            8:1    0     1G  0 part /boot
└─sda2            8:2    0   699G  0 part
  ├─centos-root 253:0    0   550G  0 lvm  /
  ├─centos-swap 253:1    0   7.9G  0 lvm  [SWAP]
  └─centos-home 253:2    0 141.1G  0 lvm  /home
sr0              11:0    1  1024M  0 rom

growpart – extend a partition in a partition table to fill available space

パーティションサイズの拡張

How to resize a logical volume with 5 simple LVM commands

留下评论

通过 WordPress.com 设计一个这样的站点
从这里开始