How To Create Linux LVM In 3 Minutes

Posted by scottk on February 23, 2009 in Sysadmin |

diskIn this 3-minutes Linux LVM guide, let’s assume that the LVM is not currently configured or in used. Having say that, this is the LVM tutorial if you’re going to setup LVM from the ground up on a production HP server with a new partition allocated within your raid controller

How to setup Linux LVM in 3 minutes at command line?

  1. Login with root user ID and try to avoid using sudo command for simplicity reason.
  2. Using the whole new partition as a LVM partition: fdisk /dev/cciss/c0d1
  3. At the Linux fdisk command prompt,
    • press n to create a new disk partition,
    • press p to create a primary disk partition,
    • press 1 to denote it as 1st disk partition,
    • press ENTER twice to accept the default of 1st and last cylinder – to convert the whole secondary hard disk to a single disk partition,
    • press t (will automatically select the only partition – partition 1) to change the default Linux partition type (0×83) to LVM partition type (0×8e),
    • press L to list all the currently supported partition type,
    • press 8e (as per the L listing) to change partition 1 to 8e, i.e. Linux LVM partition type,
    • press p to display the secondary hard disk partition setup. Please take note that the first partition is denoted as /dev/hdb1 in Linux,
    • press w to write the partition table and exit fdisk upon completion.
  4. Next, this LVM command will create a LVM physical volume (PV) on a regular hard disk or partition: pvcreate /dev/cciss/c0d1p1
  5. Now, another LVM command to create a LVM volume group (VG) called VolGroup01: vgcreate VolGroup01 /dev/cciss/c0d1p1
  6. Create a 400MB logical volume (LV) called LogVol3 on volume group VolGroup01: lvcreate --size 400M --name LogVol3 VolGroup01

Some of the useful LVM commands reference:

  • vgdisplay vg0 – To check or display volume group setting, such as physical size (PE Size), volume group name (VG name), maximum logical volumes (Max LV), maximum physical volume (Max PV), etc.
  • pvscan – To check or list all physical volumes (PV) created for volume group (VG) in the current system.
  • vgextend – To dynamically adding more physical volume (PV), i.e. through new hard disk or disk partition, to an existing volume group (VG) in online mode. You’ll have to manually execute vgextend after pvcreate command that create LVM physical volume (PV).

Contents mostly from: http://www.walkernews.net/2007/07/02/how-to-create-linux-lvm-in-3-minutes/

Copyright © 2006-2024 SimpIT.com All rights reserved.
This site is using the Desk Mess Mirrored theme, v2.5, from BuyNowShop.com.