Write to Byte
Editorial Calendar

Categories
Previous Editions
Columns
Features
Audio



Resources
BYTE Forums
WebTools
Java Resources
Downloads
History Of Byte

BYTE Humor
Ian Shoales' Page

Print Archives
By Issue   By Topic

About Us
Byte Editorial Staff
Sales Staff
Privacy Policy




Search DDJ

DDJ Links

ARTICLES
SOURCE CODE
DEVSEARCHER
TECHNETCAST
BOOK REVIEWS
OP-EDS
COMMUNITY UNIVERSITY
MICROPROCESSOR RESOURCES
HISTORY OF COMPUTING
MAILINGLISTS




Serving With Linux

BYTE Magazine > Serving With Linux > 2000 > July

Some Command Examples

(A Logical Volume Manager For Linux, Finally!:  Page 3 of 3 )

In This Article
A Logical Volume Manager For Linux, Finally!

Inside LVM

Some Command Examples
Assuming you have kernel 2.3.49+ or patched your existing kernel with the LVM drivers, you can run the following command examples to do some of the things mentioned above.

1. After installing LVM do an "insmod lvm" or setup kerneld/kmod to load it automatic (see INSTALL).

2. Set up partitions (#1) on both disks with partition type 0x8e.

3. Do a "pvcreate /dev/sd[ce]1" (For testing purposes, you can use more than one primary and/or extended partition on a disk. Don't do that for normal LVM operation for performance reasons. If you have to, don't stripe logical volumes over physical volumes associated to partitions on the same disk.

4. Do a "vgcreate volg02 /dev/sd[ce]1" (vgcreate activates the volume group too).

5. Do a "lvcreate -lvoldbf-_lv tvolg02" to get a 100-MB linear lvol or a "lvcreate -i2 -I4 -l1000 -nlvoldbf volg02" to get a 1,000-MB large lvol with two stripes and stripesize 4 KBs.

6. Use created LVs as needed. For example, generate a file system in one with "mke2fs /dev/volg02/lvoldbf" and mount it.

Because the Linux LVM follows closely the HP-UX concept, the commands are almost identical in name and behavior. So, the commands for physical volume handling all start with pv, those for volume group handling start with vg, and those for logical volumes start with lv.

TABLE 1 - LVM commands

  Command     What It Does  
 e2fsadm  resizing for lvextend, lvreduce, e2fsck and resize2fs administration wrapper for logical volume including file system
 lvchange  change attributes of a logical volume
 lvcreate  create a logical volume
 lvdisplay  display logical volume config data
 lvextend  extend a logical volume in size
 lvreduce  reduce a logical volume in size
 lvremove  remove a logical volume
 lvrename  renames an inactive logical volume
 lvscan  find all existing logical volumes
   
  lvmchange   emergency program to change attributes of the LVM
  Lvmdiskscan   scan all disks / partitions and multiple devices and list them
  lvmsadc   statistic data collector
  lvmsar   statistic data reporter
   
  pvchange   change attributes of physical volumes
  pvcreate   create a physical volume
  pvdata   debug list physical volume group descriptor area
  pvdisplay   display physical volume config information
  pvmove   move logical extents to a different physical volume
  pvscan   find all existing physical volumes
   
  vgcfgbackup   backup all volume group descriptor areas
  vgcfgrestore   restore volume group descriptor area(s) to disk(s)
  vgchange   activate/deactivate volumr group(s)
  vgck   check volume group descriptor area for consistency
  vgcreate   create a volume group from physical volume(s)
  vgdisplay   display volume group config information
  vgexport   export volume group (make it unknown to the system)
  vgextend   extend a volume group by one or more physical volumes
  vgimport   import a volume group (make it known to the/another system)
  vgmerge   merge two volume groups into one
  Vgmknodes   creates volume group directory with all logical volume specials
  vgreduce   reduce a volume group by one or more empty physical volume(s)
  vgremove   remove an empty volume group
  vgrename   renames an inactive volume group
  vgscan   scan for volume groups
  vgsplit   split one volume group into two

As you can see from the above list, the features of LVM are quite sophisticated. You can split volume groups in two, you can merge them into one, etc. In your daily job as a sysadmin of a large server with many disks, LVM is a blessing. It is easy, however, to loose sight of what you did and why you did. That's why I keep a paper log of all changes I made to servers, along with a short explanation of why. Then I leave a copy of it to the sysadmin of the machine. If, God forbid, something should happen to me, the sysadmin can always reconstruct the situation from the logs I provided.

Have fun with LVM!

(Many thanks to the LVM team for this wonderful software and for their documentation, upon which I based this article.)


Moshe Bar is an Israeli system administrator and OS researcher, who started learning Unix on a PDP-11 with AT&T Unix Release 6 back in 1981. He holds an M.Sc in computer science. Visit his website at http://www.moelabs.com/

For more of Moshe's columns, visit the Serving With LinuxIndex Page.

 Page 3 of 3 


BYTE Forums
Want to talk about this article?

 Serving With Linux
 


CMPnet


 

 

www4