Troubleshoot - by Hostrare
LVM or Logical Volume Management is a tool managed by Unix/Linux directors to manage disk devices. LVM gives a layer of consideration within the underlying physical disk/volume and the host operating policy. LVM partitions can span beyond physical hard runs and can be re-sized.
We can use the following actions to build LVM.
Partitioning
Physical volume(s) creation
Volume group(s) creation
Logical volume(s) creation
Formatting of the file system
Mounting of file system
Updating fstab for automatic volume mounting
Create Partition
Use this LVMconfigurationinLinuxcpanelserver, LVM separations necessity be of type 8e (Linux LVM.) Build a new separation and make sure with ID 8e.
[root@localhost ~]# fdisk -lDisk /dev/sda: 10.7 GB, 10737418240 bytes255 heads, 63 sectors/track, 1305 cylindersUnits = cylinders of 16065 * 512 = 8225280 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk identifier: 0x000d5460Device Boot Start End Blocks Id System/dev/sda1 1 1306 10484736 8e Linux LVM
if not then you can build a separation with the type of the file method to 8e using t option.
[root@localhost ~]# fdisk /dev/sda
the physical area unit of an LVM logical volume is a block tool such as a separation or whole record. To use the device for an LVM logical volume the device must be initialized as a physical volume (PV).
Verify whether any physical volumes (PV’s) already survive on the policy.
[root@localhost ~]# pvdisplay
Use the following command to create Physical Volume
[root@localhost ~]#pvcreate /dev/sda1
Physical volume “/dev/sda1” successfully created
[root@localhost ~]#
Physical volumes are mixed into volume groups (VGs). This generates a pool of disk area out of which logical volumes can be allocated. Within a volume group, the disk space available for allocation is divided into units of an established size called limits.
Verify Volume Groups the are already present on the policy
[root@localhost ~]# vgdisplay
Create Volume Group
[root@localhost ~]# vgcreate VolGroup /dev/sda1
Volume group “VolGroup” successfully created
[root@localhost ~]# vgdisplay--- Volume group ---VG Name VolGroupSystem IDFormat lvm2Metadata Areas 2Metadata Sequence No 3VG Access read/writeVG Status resizableMAX LV 0Cur LV 2Open LV 2Max PV 0Cur PV 2Act PV 2VG Size 10.70 GiBPE Size 4.00 MiBTotal PE 4481Alloc PE / Size 4481 / 10.70 GiBFree PE / Size 0 / 0VG UUID TGFbtz-ysqf-XE8e-fDb0-dRzh-hfzE-Jx484g
we should Volume Group created that has free physical extents, we are now ready to create our new Logical Volume (LV). LV’s can be created using several extents (with the -l command-line switch) or by total size (with the -L command line switch supported by KB, MB, GB, or TB.)
just use this command to create LV with all the area from that VG.
lvcreate
[root@localhost ~]#lvcreate lv_home VolGroup
Logical volume “lv_home” created
[root@localhost ~]# lvdisplay--- Logical volume ---LV Name /dev/VolGroup/lv_homeVG Name VolGroupLV UUID trHeKm-Cxbu-cApC-IaHd-gxRW-RMdC-dw4msVLV Write Access read/writeLV Status available# open 1LV Size 10.54 GiBCurrent LE 4233Segments 2Allocation inheritRead ahead sectors auto- currently set to 256Block device 253:0
If you need 4G of LV then define a new LV that is 4GB in size
[root@localhost ~]#lvcreate -L 4GB -n lv_home VolGroup
Logical volume “lv_home” created
To create LV with full disk space
[root@localhost ~]# lvcreate -n lv_home -l 100%FREE VolGroup
Logical volume “lv-home” created
Linux gives many separate file methods, some numbers of Linux/Unix will tend to suggest EXT3 while others might suggest XFS or ReiserFS.
[root@localhost ~]#mke2fs -j /dev/VolGroup/lv_home
create and mount that drive for your directory.
[root@localhost ~]#mkdir /home
[root@localhost ~]#mount /dev/VolGroup/lv_home /home
Once completed view your mounted device.
[root@localhost ~]# df -hFilesystem Size Used Avail Use% Mounted on/dev/mapper/VolGroup-lv_home10G 789M 8G 7% /home
Thats all!!!
To remove LV, you can use this command.
[root@gopal ~]# lvremove /dev/VolGroup/lv_home
Do you really want to remove active logical volume lv_home? [y/n]: y
Logical volume “lv_home” successfully removed
Modify the size of the relevant volumes Using lvextend Command
We can extend the size of the logical capacities after creating them by using the lvextend utility.
For example, logical volume increase the size of 100M
[root@gopal ~]# umount /dev/VolGroup/lv_home
Volume group free space will add to LV.
[root@gopal ~]#lvextend -L+100 /dev/VolGroup/lv_home
Extending logical volume lv_home to 100.00 MB
Logical volume lv_home successfully resized
[root@gopal ~]# e2fsck -f /dev/VolGroup/lv_home
e2fsck 1.41.12 (17-May-2010)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/VolGroup/lv_home: 12/131072 files (0.0% non-contiguous), 25388/524288 blocks
[root@gopal ~]# resize2fs /dev/VolGroup/lv_home
resize2fs 1.41.12 (17-May-2010)
Resizing the filesystem on /dev/mapper/home2lvm-lv_home2 to 786432 (4k) blocks.
The filesystem on /dev/mapper/home2lvm-lv_home2 is now 786432 blocks long.
Mount that partition now.
[root@gopal ~]# mount /dev/VolGroup/lv_home /home2
/dev/mapper/home2lvm-lv_home2
3.0G 67M 2.8G 3% /home2
That’s All….
It is possible to build a separation safely without unmounting and remounting your volume. These steps assume you have an additional disk possible on your volume which is currently unallocated.
Run pvscan to confirm you have allocatable space in your target Logical Volume:
pvscan
PV /dev/sda2 VG VolGroup00 lvm2 [19.88 GB / 1020.00 MB free]
PV /dev/sdb VG VolGroup01 lvm2 [100.00 GB / 20.00 GB free]
From the output, you can see VolGroup01, which contains the partition want to grow, had some free space.
Run lvresize to add free space to your partition:
VG name : home2lvm
LVname : lv_home2
[root@gopal ~]# lvresize -L+1.9G -n /dev/mapper/home2lvm-lv_home2
Rounding size to boundary between physical extents: 1.90 GiB
Extending logical volume lv_home2 to 4.90 GiB
Logical volume lv_home2 successfully resized
[root@gopal ~]# resize2fs /dev/home2lvm/lv_home2
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/home2lvm/lv_home2 is mounted on /home2; on-line resizing required
old desc_blocks = 1, new_desc_blocks = 1
Performing an on-line resize of /dev/home2lvm/lv_home2 to 1285120 (4k) blocks.
The filesystem on /dev/home2lvm/lv_home2 is now 1285120 blocks long.
Verify the disk space added in your current volume.
df -h
When you add new drive, you can extend Volume Group and resize LV with out unmount.
After new drive attached, create partition with LVM code 8e.
Create PV
[root@gopal ~]# pvcreate /dev/xvdc1
Physical volume “/dev/xvdc1” successfully created
[root@gopal ~]# vgextend home2lvm /dev/xvdc1
Volume group “home2lvm” successfully extended
VGExtend
[root@gopal ~]# vgextend home2lvm /dev/xvdc1
Volume group “home2lvm” successfully extended
LVresize
[root@gopal ~]# lvresize -L+2.05G -n /dev/mapper/home2lvm-lv_home2
Rounding size to boundary between physical extents: 2.05 GiB
Extending logical volume lv_home2 to 6.95 GiB
Logical volume lv_home2 successfully resized
[root@gopal ~]# resize2fs /dev/mapper/home2lvm-lv_home2
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/mapper/home2lvm-lv_home2 is mounted on /home2; on-line resizing required
old desc_blocks = 1, new_desc_blocks = 1
Performing an on-line resize of /dev/mapper/home2lvm-lv_home2 to 1822720 (4k) blocks.
The filesystem on /dev/mapper/home2lvm-lv_home2 is now 1822720 blocks long.
You are Done!!! Check with drive size
df -h
our suuport team here for you 24/7
+8801977507015support@hostrare.comsend a leter Whether you are looking for a personal website hosting plan or a business website hosting plan, We are the perfect solution for you. Our powerful website hosting services will not only help you achieve your overall website goals, but will also provide you with the confidence you need in knowing that you are partnered with a reliable and secure website hosting platform.