Linux 利用LVM扩展根分区

2017-05-29 17:11 阅读 1,418 次 评论 0 条

[root@localhost ~]# fdisk -l 查看分区

[root@localhost ~]# mkfs.ext4 /dev/sdb 格式化分区

[root@localhost ~]# pvcreate /dev/sdb 格式后的sdb分区添加为物理卷

[root@localhost ~]# pvs 查看PV分区

[root@localhost ~]# vgdisplay 显示LVM卷组的信息

[root@localhost ~]# pvdisplay 显示物理卷的属性

[root@localhost ~]# vgextend VolGroup /dev/sdb 将分区sdb转换为扩展分区

[root@localhost ~]# lvdisplay 查看当前的逻辑卷,目的是查看/根分区的路径,即:/dev/VolGroup/LogVol00

[root@localhost ~]# lvextend -L +9.99G /dev/VolGroup/LogVol00 将新增的逻辑卷全部扩展到"/"分区中

[root@localhost ~]#resize2fs /dev/VolGroup/LogVol00 刷新根分区"/dev/VolGroup/lv_root"的容量

[root@localhost ~]# df -HT 查看刷新后根分区的大小

示例:

[root@localhost ~]# fdisk -l

Disk /dev/sda: 21.5 GB, 21474836480 bytes

255 heads, 63 sectors/track, 2610 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

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

Disk identifier: 0x00028846

Device Boot Start End Blocks Id System

/dev/sda1 * 1 26 204800 83 Linux

Partition 1 does not end on cylinder boundary.

/dev/sda2 26 2611 20765696 8e Linux LVM

Disk /dev/sdc: 10.7 GB, 10737418240 bytes

255 heads, 63 sectors/track, 1305 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

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

Disk identifier: 0x00000000

Disk /dev/sdb: 10.7 GB, 10737418240 bytes

255 heads, 63 sectors/track, 1305 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

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

Disk identifier: 0x00000000

Disk /dev/mapper/VolGroup-LogVol00: 42.7 GB, 42718986240 bytes

255 heads, 63 sectors/track, 5193 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

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

Disk identifier: 0x00000000

Disk /dev/sdd: 10.7 GB, 10737418240 bytes

255 heads, 63 sectors/track, 1305 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

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

Disk identifier: 0x00000000

[root@localhost ~]# mkfs.ext4 -y /dev/sdd

mkfs.ext4: invalid option -- 'y'

Usage: mkfs.ext4 [-c|-l filename] [-b block-size] [-f fragment-size]

[-i bytes-per-inode] [-I inode-size] [-J journal-options]

[-G meta group size] [-N number-of-inodes]

[-m reserved-blocks-percentage] [-o creator-os]

[-g blocks-per-group] [-L volume-label] [-M last-mounted-directory]

[-O feature[,...]] [-r fs-revision] [-E extended-option[,...]]

[-T fs-type] [-U UUID] [-jnqvFKSV] device [blocks-count]

[root@localhost ~]# vgextend VolGroup /dev/sdd

Physical volume "/dev/sdd" successfully created

Volume group "VolGroup" successfully extended

[root@localhost ~]# lvextend -L +9.99G /dev/VolGroup/LogVol00

Rounding size to boundary between physical extents: 9.99 GiB.

Size of logical volume VolGroup/LogVol00 changed from 39.79 GiB (10185 extents ) to 49.78 GiB (12743 extents).

Logical volume LogVol00 successfully resized.

[root@localhost ~]# resize2fs /dev/VolGroup/LogVol00

resize2fs 1.41.12 (17-May-2010)

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

old desc_blocks = 3, new_desc_blocks = 4

Performing an on-line resize of /dev/VolGroup/LogVol00 to 13048832 (4k) blocks.

The filesystem on /dev/VolGroup/LogVol00 is now 13048832 blocks long.

[root@localhost ~]# df -HT

Filesystem Type Size Used Avail Use% Mounted on

/dev/mapper/VolGroup-LogVol00

ext4 53G 791M 50G 2% /

tmpfs tmpfs 977M 0 977M 0% /dev/shm

/dev/sda1 ext4 199M 40M 150M 21% /boot

[root@localhost ~]#

概括:

1格式化分区.

mkfs.ext4 -y /dev/sdd

2.转换位扩展分区

vgextend VolGroup /dev/sdd

3.根分区扩展容量

lvextend -L +9.99G /dev/VolGroup/LogVol00

4.刷新根分区容量

resize2fs /dev/VolGroup/LogVol00

5.查看是否成功

df –HT

版权声明:本文著作权归原作者所有,欢迎分享,谢谢支持!
转载请保留注明:Linux 利用LVM扩展根分区 | DXL学习
分类:Centos, Deepin, Fedora, Ubuntu 标签:

发表评论

您必须 登录 才能发表留言!