使用LVM进行磁盘扩容

前提,分区使用LVM进行管理,当一个分区因为空间不足时,物理机或虚拟机可以通过添加一个新磁盘,将新的磁盘空间加到原有的LVM分区上。


将/dev/vda磁盘空间加到LogVol00_root分区:

1、创建物理卷

# pvcreate /dev/vda

Physical volume "/dev/vda" successfully created

2、扩容卷组

# vgextend VolGroup00 /dev/vda

  Volume group "VolGroup00" successfully extended

3、查看卷组剩余空间

# vgdisplay

  --- Volume group ---

  VG Name               VolGroup00

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

  PE Size               32.00 MiB

  Total PE              4792

  Alloc PE / Size       1593 / 49.78 GiB

  Free  PE / Size       3199 / 99.97 GiB #剩余99G

  VG UUID               MSnTJu-Rlio-FX1N-vkHX-E6fV-P6N7-LcY33q

4、扩容逻辑分区

# lvextend /dev/mapper/VolGroup00-LogVol00_root -L +99.96G

  Rounding size to boundary between physical extents: 99.97 GiB

  Extending logical volume LogVol00_root to 141.75 GiB

  Logical volume LogVol00_root successfully resized

5、更新分区

# resize2fs /dev/mapper/VolGroup00-LogVol00_root

resize2fs 1.41.12 (17-May-2010)

Filesystem at /dev/mapper/VolGroup00-LogVol00_root is mounted on /; on-line resizing required

old desc_blocks = 3, new_desc_blocks = 9

Performing an on-line resize of /dev/mapper/VolGroup00-LogVol00_root to 37158912 (4k) blocks.

The filesystem on /dev/mapper/VolGroup00-LogVol00_root is now 37158912 blocks long.

6、查看磁盘大小

# df -h

Filesystem            Size  Used Avail Use% Mounted on

/dev/mapper/VolGroup00-LogVol00_root

                      140G  3.3G  130G   3% /

tmpfs                 3.9G     0  3.9G   0% /dev/shm

/dev/sda1             194M   32M  152M  18% /boot


来自为知笔记(Wiz)

你可能感兴趣的:(使用LVM进行磁盘扩容)