Tuesday, December 3, 2019

Mount logical Partition in Linux VM

 

Expand Linux VM Logical Volume Partition or Mount Logical Volume


    In a virtualized environment when a LINUX OS created. There are min three partitions created 
  •     ROOT 
  •     HOME 
  •     SWAP

    But here if you think that just expanding partition will solve your purpose then you are wrong. Because expanded partition gets appended after swap memory. So, we need to mount the expanded partition and merge it with the partition that requires expansion.

So let go step by step.
  • Power off the virtual machine.
  • Edit the virtual machine settings and extend the virtual disk size.
  • Power on the virtual machine.
  • Identify the device name, which is by default /dev/sda, and confirm the new size by running the command
        fdisk -l


  • Now execute this below command to initialize the expanded space and mount it.
        fdisk /dev/sda
  • Press p to print the partition table to identify the number of partitions.
  • Press n to create a new primary partition.
  • Press p for primary.
  • Press 3 for the partition number, depending on the output of the partition table print.
  • Press Enter two times.
  • Press 3 to select the newly creation partition.
  • Type 8e to change the Hex Code of the partition for Linux LVM.
  • Press w to write the changes to the partition table. 

  • Reboot the virtual machine.
  • Now we need to create physical & logical volumes execute below command to create physical volume.

         pvcreate /dev/sda3

  • Execute below command to get the name of current Volume Group

        vgdisplay

         Note Down the VG Name from output of command for further commands.

  • Execute below command to extend the Volume Group with /dev/sda3. replace VG Name with the VG name displayed by above command.

        vgextend <VG Name> /dev/sda3


  • Execute below command to get Logical Volume path.

        lvdisplay

        This command will give you LV Path & will be used in next command.

        

  • Execute below command to extend the Logical Volume with /dev/sda3. replace <LV Path> with the output value of above command.

        lvextend <LV Path> /dev/sda3 


  • Execute below command to update the Logical Volume

        xfs_growfs /dev/VolGroup/lv_root

  •  Check for the new disk space.

        df -h

     Here you are done with expanding & mounting partition.


No comments:

Post a Comment

Home

Mastering Java Interview Questions: Your Comprehensive Guide         If you're preparing for a Java interview or just lookin...