LINUX下为LVM磁盘增加硬盘空间

时间:2023-03-08 17:39:14
LINUX下为LVM磁盘增加硬盘空间

总结:

~~~~~~~~~~~~~~~~~~~~

fdisk -l
pvcreate /dev/sdb
vgextend VolGroup /dev/sdb
lvextend -L +180G /dev/mapper/VolGroup-lv_root
resize2fs /dev/VolGroup/lv_root

~~~~~~~~~~~~~~~~~~~

1,  在VM WARE ESXI里为客户机增加一块新的硬盘

2,  重启客户机

3,  用FDISK –L查看整个磁盘空间

#fdisk -l

Disk /dev/sda:  bytes

 heads,  sectors/track,  cylinders

Units = cylinders of  *  =  bytes

Sector size (logical/physical):  bytes /  bytes

I/O size (minimum/optimal):  bytes /  bytes

Disk identifier: 0x000b2d34

   Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *                                Linux

Partition  does not end on cylinder boundary.

/dev/sda2                             8e  Linux LVM

Disk /dev/sdb:  bytes

 heads,  sectors/track,  cylinders

Units = cylinders of  *  =  bytes

Sector size (logical/physical):  bytes /  bytes

I/O size (minimum/optimal):  bytes /  bytes

Disk identifier: 0x00000000

Disk /dev/mapper/VolGroup-lv_root:  bytes

 heads,  sectors/track,  cylinders

Units = cylinders of  *  =  bytes

Sector size (logical/physical):  bytes /  bytes

I/O size (minimum/optimal):  bytes /  bytes

Disk identifier: 0x00000000

Disk /dev/mapper/VolGroup-lv_swap:  MB,  bytes

 heads,  sectors/track,  cylinders

Units = cylinders of  *  =  bytes

Sector size (logical/physical):  bytes /  bytes

I/O size (minimum/optimal):  bytes /  bytes

Disk identifier: 0x00000000

4,  用pvcreate /dev/sdb将新的硬盘加入物理卷

pvcreate /dev/sdb

 Physical volume "/dev/sdb" successfully created

5,  用vgextend VolGroup /dev/sdb将新硬盘加入卷组

vgextend VolGroup /dev/sdb

 Volume group "VolGroup" successfully extended

6,  为根分区扩散空间lvextend -L +200G /dev/mapper/VolGroup-lv_root

lvextend -L +180G /dev/mapper/VolGroup-lv_root

Extending logical volume lv_root to 208.31 GiB

Logical volume lv_root successfully resized

7,  将之应用resize2fs /dev/VolGroup/lv_root

resize2fs /dev/VolGroup/lv_root

resize2fs  (-May-)

Filesystem at /dev/VolGroup/lv_root is mounted on /; on-line resizing required

old desc_blocks = , new_desc_blocks =
Performing an on-line resize of /dev/VolGroup/lv_root to  (4k) blocks.

The filesystem on /dev/VolGroup/lv_root is now  blocks long.

8,  再用DF –H查看空间,已加入

df -h

Filesystem                    Size  Used Avail Use% Mounted on

/dev/mapper/VolGroup-lv_root  206G  .7G  189G   % /

tmpfs                         .9G       .9G   % /dev/shm

/dev/sda1                     485M   32M  428M   % /boot

9,  其它细节