So, there's no space left on your LVM system and you need to add some more. Assuming that you've correctly attached a new drive to your system, the following allows you to add it to the existing logical volume described above. In this case the entire drive will be dedicated to the existing logical volume, although it is possible to add just a single partition from a physical volume. The new drive has been located at /dev/sdc in this example.
Run pvcreate on the new physical volume:
holly:~# pvcreate /dev/sdc No physical volume label read from /dev/sdc Physical volume "/dev/sdc" successfully created
Extend the existing volume group to use the new physical volume using the vgextend command, specifying the name of the volume group:
holly:~# vgextend vol_grp1 /dev/sdc Volume group "vol_grp1" successfully extended
You can see the new physical volume included in the output of the pvscan command.
Extend the existing logical volume to use the new physical volume, using the lvextend command:
holly:~# lvextend -L +68.5G /dev/vol_grp1/log_vol1 /dev/sdc Extending logical volume log_vol1 to 137.00 GB Logical volume log_vol1 successfully resized
Unmount the filesystem that uses the volume group. (It is possible to resize some filesystems without unmounting them, but the coward's way is taken here. Indeed with XFS its compulsory to do so. See the /ResizeXFS page.) The rest of this example uses the ext3 filesystem.
Check the filesystem for errors to ensure that it's clean before resizing it using the e2fsck command:
holly:~# e2fsck -f /dev/vol_grp1/log_vol1 e2fsck 1.35 (28-Feb-2004) 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/vol_grp1/log_vol1: 87230/8978432 files (1.3% non-contiguous), 15782437/17956864 blocks
Extend the filesystem to use the new space on the logical volume. This can be done with a number of tools, like parted for example. This example uses resize2fs. resize2fs can accept an argument of the number of blocks to use, but by default will expand to use all the available blocks.
holly:~# resize2fs -p /dev/vol_grp1/log_vol1 resize2fs 1.35 (28-Feb-2004) Resizing the filesystem on /dev/vol_grp1/log_vol1 to 35913728 (4k) blocks. Begin pass 1 (max = 548) Extending the inode table XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX Begin pass 2 (max = 52) Relocating blocks XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX Begin pass 3 (max = 548) Scanning inode table XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX Begin pass 5 (max = 13) Moving inode table XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX The filesystem on /dev/vol_grp1/log_vol1 is now 35913728 blocks long.
Mount the filesystem and check it's new size using mount and df:
holly:~# mount /home holly:~# df -h Filesystem Size Used Avail Use% Mounted on /dev/hda1 2.0G 1.5G 471M 76% / /dev/vol_grp1/log_vol1 135G 60G 71G 46% /home
Excellent! 70GB more disk space to play with in the /home partition!