Posted in RHCE

Managing LVM on Redhat-based systems

March 26, 2007 - 3 comments

Steps :
1. Creation of Physical Volumes (container of volume groups)
2. Creation of Volume Groups (container of logical volumes)
3. Creation of Logical Volumes (“partitions”)
4. Formatting the Logical Volumes
5. (optional) Resizing Logical Volumes

1. Creation of Physical Volumes (PV)

pvcreate /dev/hda4
pvdisplay

It is good practice to always use “(pv|vg|lv)display” after creating a volume.

/dev/hda4 is an empty partition.. see fdisk manpages for help.

2. Creation of Volume Groups (VG)

vgcreate VolGroup00 /dev/hda4
vgdisplay

We are naming the volume group “VolGroup00″, call it whatever you like.
The VG will take the whole partition space here. You can specify the size by using the “-s” option.

3. Creation of Logical Volumes (LV)

lvcreate --size 500M --name LogVol00 VolGroup00
lvdisplay

A 500M Logical Volume has been creating inside “VolGroup00″.

4. Formatting the newly created Logical Volume

mkfs.ext3 /dev/VolGroup00/LogVol00
mount /dev/VolGroup00/LogVol00 /somedir

5. (optional) Resizing a Logical Volume

umount /somedir
lvextend -v -L +100M /dev/VolGroup00/LogVol00
e2fsck -f /dev/VolGroup00/LogVol00
resize2fs /dev/VolGroup00/LogVol00
mount /dev/VolGroup00/LogVol00 /somedir

We made the Logical Volume 100M bigger.
Then, you need to resize the ext3 partition inside the Logical Volume.

Comments

Brad Smith

June 7, 2007 - 21:58

Thanks for all the tutorilas. I am taking my RHCE Jun 22. I have found them very helpful. I hope you plan to do more. If you have any words of encouragement please drop me a line.
Brad

Sébastien Wains

June 7, 2007 - 22:52

Hi Brad,

Glad you find my RHCE notes useful, while they were not intended to be comprehensive or anything.

A good preparation and experience in Linux is the key to success !

Good luck, keep me updated..

Seb

Kiran

October 26, 2007 - 20:50

Your RHCE-Prep posts assisted me greatly in upgrading from RHEL3 to RHEL5. Keep up the great work :)

Leave Comment

Please consider visiting the partners below if you enjoyed this article :

If this post saved you time and money, please consider checking my Amazon wishlist.

Before submitting, some rules :
- Is your comment related to the article ?
- You're having a problem ? Have you checked Google, other howtos, docs, manpages ?
- You're still having the problem ? Have you raised log verbosity, checked traces, ran tcpdump ?
- Have you checked your configuratoin for typo ?
Unless your comment is providing additional info or respect the rules above, DON'T comment.
If you don't understand what you are doing, I urge you to read the documentation, I'm not your free Level 1 helpdesk guy.