create new tag
view all tags
Pre-Condition: Our new test machines come with 3 hard drivers, each of them has 2TB space. While installing OS, only 1 hard driver was used, and one volume group(vg.01) was created based on 1 partion(/dev/sda4) and several logical volumes(/dev/vg.01/scratch , /dev/vg.01/afscache, /dev/vg.01/wlcghome) were created upon this volume group(vg.01), among all of them , /dev/vg.01/scratch has the biggest capacity(about 1.7TB). And it is already formatted with ext3 file system and has data in it.

Goal 1: I would like to merge all the available space into one file system for storage without losing the original data.

Solution: use physical volume, volume group, logical volume and file system resize

1. making partitions (I only make 1 big partition on each of the 2 extra hard disk)
$fdisk /dev/sdb
$fdisk /dev/sdc
2. create physical volumes
$pvcreate /dev/sdb1 /dev/sdc1
3. extend the existing volume group(vg.01) with the new added physical volumes
$vgdisplay (showing the existing volume group information)
$vgextend vg.01 /dev/sdb1 /dev/sdc1
4. extend the logical volume(/dev/vg.01/scratch) which was created based on the above volume group(vg.01)
$lvextend -l100%FREE /dev/vg.01/scratch

Note: this will give all the free space of the volume group vg.01 to logical volume /dev/vg.01/scratch

5. resize the existing file system(no need to umount it)
$resize2fs /dev/vg.01/scratch &>/dev/null 

after these steps , you should be able to see the available space of /dev/vg.01/scratch increasing while you use "df " to monitor the mounted file system

Goal 2 : I would like to use the 2 new hard drivers to create a new big file system

1. making partitions (I only make 1 big partition on each of the 2 extra hard disk)
$fdisk /dev/sdb
$fdisk /dev/sdc

2. create physical volumes
$pvcreate /dev/sdb1 /dev/sdc1
3. create a new volume group
$vgcreate fs_group /dev/sdb1 /dev/sdc1
4. create a new logical volume
$ lvcreate -l 100%FREE -n fs_logical_volume fs_group

Note: this will give all the space from new volume group fs_group to the logical volume fs_logical_volume

5. make file system over the new logical volume
$mkfs.xfs /dev/fs_group/fs_logical_volume
6. mount the new file system
$mkdir /fs_space 
$mount /dev/fs_group/fs_logical_volume /fs_space/ 

After these steps , the 2 hard drivers should be merged into one file system now.

-- WenjingWu - 2011-08-30

Topic revision: r1 - 2011-08-30 - WenjingWu
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback