Profile Details

Toggle Sidebar
Recent updates
  • How To: Add a second Hard Disk to Clear OS 6 and extending the LV

    The first step is to convert this disk into a physical volume. This is achieved using the pvcreate command:

    # pvcreate /dev/sdb
    Physical volume "/dev/sdb" successfully created
    With the physical volume created we now need to add it to the volume group (in this case vg_centos6) using the vgextend command:

    # vgextend vg_CentOS6 /dev/sdb
    Volume group "vg_CentOS6" successfully extended
    The new physical volume has now been added to the volume group and is ready to be allocated to a logical volume. To do this we run the lvextend tool providing the size by which we wish to extend the volume. In this case we want to extend the size of lv_root by 30 GB. Note that we need to provide the path to the logical volume which can be obtained from the lvdisplay command (in this case /dev/vg_centos6/lv_root):

    # lvextend -L+30G /dev/vg_centos6/lv_root
    Extending logical volume lv_root to 59.54 GiB
    Logical volume lv_root successfully resized
    The last step in the process is to resize the file system residing on the logical volume so that it uses the additional space. Since we are assuming a default CentOS 6 installation here this can be achieved using the resize2fs command:

    # resize2fs /dev/vg_centos6/lv_root
    resize2fs 1.41.12 (17-May-2010)
    Filesystem at /dev/vg_centos6/lv_root is mounted on /; on-line resizing required
    old desc_blocks = 2, new_desc_blocks = 4
    Performing an on-line resize of /dev/vg_centos6/lv_root to 15607808 (4k) blocks.

    The filesystem on /dev/vg_centos6/lv_root is now 15607808 blocks long. Once the resize completes the file system will have been extended to use the additional space provided by the new disk drive. All this has been achieved without moving a single file or even having to restart the server. As far as any users on the system are concerned nothing has changed (except, of course, that there is now more disk space).