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

Inside LVM

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

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

Inside LVM

Some Command Examples
When creating physical volumes or volume groups (from now on referred to as volg) and logical volumes (from now on referred to as lvol), the configuration information for each of these logical entities is stored on the corresponding physical volume, and backup of this information is automatically put under the /etc/lvmtab.d directory.

Starting from kernel 2.3.49, there is now an LVM driver built-in. This driver maintains mapping tables between the volgs (volume groups) and logical volumes (lvols) and their corresponding physical partitions and drives. These tables are created and maintained LVM commands that only the root may run.

Whenever access to one block in a file system on an LVM-managed lvol is requested, the driver uses these tables to map the block to its real address on the disk. That's it.

Hot To Use It
Let's assume you have a system with four disks. One is for the operating system and three are for data. LVM knows there are four disks because the kernel sees them at boot time and maintains a table with a list of them. All you do is create, say, one volg for each disk. And then for each file system you need, you continue by creating a separate lvol. You could end up having something like this:

  
/dev/volg01/lvolroot  /		800MB 
# this is one of the two lvols for the 2GB disk used for the OS

/dev/volg01/lvolusr /usr 1200MB # and this is the second, for /usr

/dev/volg02/lvolhome /home 9000MB # since this machine acts as login server a lot of space for /home is needed (disk 2)

/dev/volg03/lvoldbf /ora_data 9000MB # Datafile for Oracle's tablespaces are placed here, this might actually be a RAID device

/dev/volg04//lvolidx /ora_idx 90000MB # Ever searching for more performance, we separate indices and data in Oracle ;-)

Now, assume you are running out of space on, say, the /home directories, and your users just can't delete any of those huge MP3 directories or MPEG movies. What do you do? Since we can't produce disk space magically with Linux yet, you still need to buy another disk. Nowadays, they mostly come in 18 GB sizes. So you assign one 4-GB partition of said new disk to the /dev/volg02 volume group. Then, using LVM you go to expand the lvolhome logical volume to the maximum of 13 GBs (unless you give volg03 more). Presto! If your server supports hot-swap disk addition, you don't even need to reboot, and your /home just got bigger. There are, of course, some caveats.

First, you have to momentarily disconnect the users from the /home directory. The kernel will surely not allow unmounting the /home file system if there are still open files in it. To momentarily stop all networking (and therefore login) activity on the server, you typically put the machine into single-user mode and then go back to your favorite runlevel (runlevel 3 in my case; I don't have much use for X).

Second, it is easy to just add space with LVM whenever needed.


 Page 2 of 3 

BYTE Forums
Want to talk about this article?

 Serving With Linux
 


CMPnet


 

 

www4