How to extend the root partition in LVM

https://rbgeek.wordpress.com/2013/01/27/how-to-extend-the-root-partition-in-lvm/

 

In this tutorial, I am using the CentOS6(but also applicable on other Linux distro) that has ext4 partition lv_root mounted as / and lv_swap as swap from the volume group vg_centos6 (which is default), we pretend that we are running out of space in lv_root(/) and volume group (vg_centos6) doesn’t have any free space. We added a brand new drive with 20 GB space. Now, we need to assign this 20 GB space to volume group and then extend lv_root(/).

WARNING: Backup your data before attempting this.

First, we’ll check the file system disk space usage and logical volume information:

sudo df -h
sudo lvs

1

Get the information about newly added hard disk using the following command:

sudo fdisk -l

2Note: /dev/sdb is the newly added hard disk!

To create the partition on the second Hard disk, use the following command and follow the “on screen” instructions and change the partition type from Linux to LVM (8e):

sudo fdisk /dev/sdb

3

Identify the already mounted lvm file system type:

df -T

4

Format the newly created partition using the following command:

sudo mkfs.ext4 /dev/sdb1

5

Initialize the newly created partition as a physical volume:

sudo pvcreate /dev/sdb1

6

Check the volume groups using the following command:

sudo vgs

7

Note: vg_centos6 is the volume group that I want to extend, you can change according to your volume group.

Extend the VG (vg_centos6) with new PV (/dev/sdb1):

sudo vgextend vg_centos6 /dev/sdb1

8

Extend the logical volume (lv_root) with all the free space of the VG(vg_centos6):

sudo lvextend -l +100%FREE /dev/vg_centos6/lv_root

9

Finally, resize the file-system:

sudo resize2fs /dev/vg_centos6/lv_root

10

Verify the file-system is larger using the following commands:

sudo df -h
sudo lvs
sudo vgs

11

Hope this will help you!

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值