How to configure LVM ?

What is LVM in Unix flavors ,resize LVM partition in Redhat / Centos /Fedora and configuring of LVM in Centos / Redhat & Fedora ?.

Resize of LVM partition is very easy in Unix , resize of LVM partition without un mounting file system can be done.

let’s assume that you have an ext3 partition LogVol00 which is mounted on / and a swap partition LogVol01 in a logical volume group VolGroup00, now you are running out of space in /, there’s no space left in the above volume group but you have a brand new disk drive with lots of free space. How to add some space to the / partition?

WARNING: If you have important data in any directory under / then backup before attempting this.

Steps to increase or re-size the existing Linux partition using LVM ?

I’ll assume the spare disk is called /dev/sdb, make sure to switch to administrator (root)

1. Create a new partition of appropriate size using fdisk and also change partition id.

# fdisk /dev/sdb

 n (create new partition, select start and end cylinders, all free space is selected by default)
t change a partition’s system id (8e Linux LVM)
w (save partition table and exit)

At this point you may be told that a reboot is necessary, I found it was unnecessary, but for safety you should probably reboot. Type fdisk -l again to check the new partition, I’ll assume /dev/sdb1 was created ~10G in size

2. Create an ext3 file system in the partition this is required to make file system usable .

#mkfs.ext3 /dev/sdb1

3. Initialize the partition for use as a physical volume in lvm and add it to VolGroup00

#pvcreate /dev/sdb1
#vgextend VolGroup00 /dev/sdb1

4. Extend LogVol00 (use ‘df /’ to check that / is mounted on LogVol00) as required (by 10G here)

# lvextend -L +10G /dev/VolGroup00/LogVol00
If you receive errors about not enough physical extents, then reduce the size of the extension a little until it fits.

5. Finally, resize the filesystem (this part normally would require unmounting /, but for ext3 and 2.6 Kernels it works while the partition is mounted)

# resize2fs /dev/VolGroup00/LogVol00

Type ‘df -h /’, to check it worked, there should be an extra 10G available
(you can use vgdisplay, pvdisplay and lvdisplay (as root) to see detailed info, pvscan for a summary)

Note.
I’ve seen horror stories with lvm manipulation whereby an ‘unknown uuid’ error occurs for a partition, and the VolGroup can no longer be found, which prevents booting. This can be due to using e2label, mkfs etc on the partition after it has been initialised as a pv and added to the group. The error is fixable if you haven’t rebooted: you need to edit /etc/lvm/backup/VolGroup00 and delete the lines referring to the unrecognized partition (they’ll be a few between braces {}, the unknown uuid will be at the beginning, something like:
Code:
pv1 {
id = “gAMCGW-jdaH-VXse-HR2j-PA24-AIbb-aHMjKl”
device = “/dev/sdb1″ # Hint only

status = ["ALLOCATABLE"]
dev_size = 20482812 # 9.76697 Gigabytes
pe_start = 384
pe_count = 312 # 9.75 Gigabytes
}
Remove all these lines, save the file, then run
Code:
vgcfgrestore -f /etc/lvm/backup/VolGroup00 VolGroup00
vgscan

 

 

 

Both comments and pings are currently closed.

Comments are closed.

Copyright ©Solutions@Experts.com
Copyright © NewWpThemes Techmark Solutions - www.techmarksolutions.co.uk