In this article, we set up Logical Volume Manager for GNU/Linux. We created a 12 GB device from 3 4 Gig drives, but only assigned 5 GB for our logical volume. Now, we are going to extend that volume. [Note: Before you do anything involving your partitions or volumes, make a complete backup. Make sure to set up a test system with the same kernel and distribution to see how this stuff works. This article was written using our lab box. Read our terms of use. Note that this article was written using a Fedora RC 1 distribution and a generic 2.4.24 kernel.] Here are our current mounted filesystems:
[root@srv-1 root]# df Filesystem 1K-blocks Used Available Use% Mounted on /dev/sda1 3874108 1611660 2065652 44% / none 3874108 1611660 2065652 44% /dev/pts /dev/sdb1 4127076 235028 3682404 6% /opt /dev/sdc1 4127076 278644 3638788 8% /usr/src /dev/sdd1 4127076 32828 3884604 1% /usr/local /dev/volgroup/logicalvol 5160576 32828 4865604 1% /mnt [root@srv-1 root]# |
You can see we have 5 gigs available on our logical volume. Here is the status of our volume group:
[root@srv-1 root]# vgdisplay --- Volume group --- VG Name volgroup VG Access read/write VG Status available/resizable VG # 0 MAX LV 256 Cur LV 1 Open LV 1 MAX LV Size 255.99 GB Max PV 256 Cur PV 3 Act PV 3 VG Size 11.98 GB PE Size 4 MB Total PE 3066 Alloc PE / Size 1280 / 5 GB Free PE / Size 1786 / 6.98 GB VG UUID FHGe16-ATie-2TsY-CkCo-R2PO-0kv2-VpUvUG [root@srv-1 root]# |
You can see we have a volume group size of 11.98 GB. Let’s extend our logical volume:
[root@srv-1 root]# umount /mnt [root@srv-1 root]# lvextend -L+6G /dev/volgroup/logicalvol lvextend -- extending logical volume "/dev/volgroup/logicalvol" to 11 GB lvextend -- doing automatic backup of volume group "volgroup" lvextend -- logical volume "/dev/volgroup/logicalvol" successfully extended [root@srv-1 root]# |
Resize the filesystem:
[root@srv-1 root]# e2fsck -f /dev/volgroup/logicalvol e2fsck 1.34 (25-Jul-2003) Pass 1: Checking inodes, blocks, and sizes Pass 2: Checking directory structure Pass 3: Checking directory connectivity Pass 4: Checking reference counts Pass 5: Checking group summary information /dev/volgroup/logicalvol: 11/655360 files (0.0% non-contiguous), 28783/1310720 blocks [root@srv-1 root]# resize2fs /dev/volgroup/logicalvol resize2fs 1.34 (25-Jul-2003) Resizing the filesystem on /dev/volgroup/logicalvol to 2883584 (4k) blocks. The filesystem on /dev/volgroup/logicalvol is now 2883584 blocks long. [root@srv-1 root]# |
Let’s check it out:
[root@srv-1 root]# mount /dev/volgroup/logicalvol /mnt [root@srv-1 root]# df Filesystem 1K-blocks Used Available Use% Mounted on /dev/sda1 3874108 1611892 2065420 44% / none 3874108 1611892 2065420 44% /dev/pts /dev/sdb1 4127076 235028 3682404 6% /opt /dev/sdc1 4127076 278644 3638788 8% /usr/src /dev/sdd1 4127076 32828 3884604 1% /usr/local /dev/volgroup/logicalvol 11353328 32828 10743784 1% /mnt [root@srv-1 root]# mount /dev/sda1 on / type ext3 (rw) none on /proc type proc (rw) none on /dev/pts type devpts (rw,gid=5,mode=620) /dev/sdb1 on /opt type ext3 (rw) /dev/sdc1 on /usr/src type ext3 (rw) /dev/sdd1 on /usr/local type ext3 (rw) /dev/volgroup/logicalvol on /mnt type ext3 (rw) [root@srv-1 root]# |
Nice!
There are six articles in this series:
Setting Up Logical Volume Manager
Extending a Logical Volume
Shrinking a Logical Volume With LVM
Adding a RAID1 Device to a Volume With LVM
Upgrading LVM To Version 2 and Patching The Linux Kernel
Finish Conversion And Expansion to Two RAID1 Devices With LVM