-->

Saturday, February 6, 2016

Creating Logical Volume Manager Partition

!! Steps to create Logical Volume Manager Partition.
1. Check Partition on system using below command
  • #fdisk -l

2. Create Partition
  • #fdisk /dev/sda

a. n Option for create new Partition
b. p Option for preview new Partition
c. w Save Partition
d. q Quit
3. Use the below command to update the kernel
  • #partprobe


4. Change LVM code for this newly created partition.
  • #fdisk /dev/sda

a. t Change code 8e
b. p Preview changes
c. w Save changes
d. q Quit
5. Create physical volume using the below command
  • #pvcreate /dev/sda

6. Create volume group using the below command
  • #vgcreate volume_group_name /dev/sda

7. Create logical volume using the below command
  • #lvcreate -L +2G -n logical_volume_name volume_group_name

8. Now Format this partition using the below command
  • #mkfs.ext3 /dev/volume_group_name/logical_volume _name

9. Mount this partition(Temperary)
  • #mount /dev/volume_group_name/logical_volume_name /Dir_Name

10. Permanent mount
  • #vim /etc/fstab

write the below entry
/dev/volume_group_name/logical_volume_name /Dir_Name ext3 defaults 0 0

Note: Temporary mount will be unmounted after reboot the system.

Creating new LVM on existing VG
Step 1: Stop Apache on the server
  • /usr/local/apache2/bin/apachectl stop

Step 2: To create LV
  • lvcreate -L {space-required}G -n {LVNAME} {VGNAME-from-where-to-create}
  • lvcreate -L +30G -n /dev/AppVG/HtdocsVol /dev/AppVG/

Step 3: To format the created LV
  • mke2fs -j /dev/AppVG/{LVNAME}
  • mke2fs -j /dev/AppVG/HtdocsVol

Step 4: Directory creation for LV mounting
  • mkdir /usr/local/apache2/htdocs_new

Step 5: Mounting LV
  • mount /dev/AppVG/{LVNAME} /usr/local/apache2/htdocs_new
  • mount /dev/AppVG/HtdocsVol /usr/local/apache2/htdocs_new

Step 6: Moving Data from htdocs to htdocs_new directory
  • Then move data from /usr/local/apache2/htdocs to /usr/local/apache2/htdocs_new
rsync -av /usr/local/apache2/htdocs/* /usr/local/apache2/htdocs_new
Step 7: Unmount LV from htdocs_new
  • umount /usr/local/apache2/htdocs_new

Step 8: Renaming the htdoc folder (old and new)
  • mv /usr/local/apache2/htdocs /usr/local/apache2/htdocs_old
  • mv /usr/local/apache2/htdocs_new /usr/local/apache2/htdocs

Step 9: Making entry in etc/fstab for permanent mounting on htdocs directory
  • cat >> /etc/fstab

  • /dev/AppVG/{LVNAME} /usr/local/apache2/htdocs ext3 defaults 0 0

  • press Control+D to save and exit

Step 10 : Refresh Mount
  • mount –a

Step 11 : Refresh Mount
  • /usr/local/apache2/bin/apachectl start/restart

0 comments:

Post a Comment