Sunday, 22 March 2015

Allocate Unallocated Space to the /root Filesystem

How to Allocate the unallocated space to the /root filesystem


Step 1: we need to check the unallocated disk space using the command, “fdisk -l”


Step 2: Run “df –h” to view the disk information


Step 3: Create a new primary partition to make use of unallocated disk space using “fdisk”. Follow the below screens to create the new primary partition.

Note: In the below example we are going to create primary partition “/dev/sda3”. The starting blocking of /dev/sda3 should start from the next value of /dev/sda2 end cylinder value. Values can be captured by running “fdisk –l”. Note the Start and End cylinder values for /dev/sda1 and /dev/sda2.

Run “fdisk /dev/sda”. Enter n, select option “p” and enter “3” as partition number. Provide the Start Cylinder value. Press Enter and for Last Cyliner value press Enter for default. Enter option “t”, press enter and press enter option “3”, press enter, enter option “8e”, press enter, enter option “w” and press enter to finish the partition. Reboot the server.




Step 4: Run “fdisk –l” to view the new partition


Step 5: Run “pvcreate /dev/sda3” to create a physical volume /dev/sda3


Step 6: Run “vgdisplay” to view the volume group name.


Step 7: Run “vgextend VolGroup /dev/sda3” extend the “VolGroup” volume group by adding in the physical volume /dev/sda3.



Step 8: Run “pvscan”  to scan for all disks in Physical volumes. 


Step 9: Run “lvdisplay” and make a note of the LV Path


Step 10: To increase the logical volume run “lvextend /dev/VolGroup/lv_root /dev/sda3”


Step 11: Run “resize2fs /dev/VolGroup/lv_root” to resize the filesystem


Step 12: Run “df -h” to view the updated disk information