linux 根分区做成lvm,Linux 利用LVM扩展根分区

[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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值