Soft ICP: PC & Linux Hardware

The Future Has Always Been Linux.

The Logical Volume Manager With Unix Hard Drives

When I first started managing UNIX systems, I underestimated the amount of time I would spend managing disk space. Traditional UNIX operating systems let you divide disks into 8 or 16 partitions (also called slices). When a slice becomes full, you must either move data to another slice or repartition the disk to make that slice larger. Repartitioning is time-consuming because you must back up the disk, repartition it by modifying the disk label, and restore data as necessary.

A typical UNIX disk analyzer.

Logical-volume technology provides the ability to reserve disk space that can be added to slices as needed. You can increase the size of a slice on the fly without losing data or experiencing significant downtime.

Overview Of Logical Volumes

The examples shown are for an HP-UX 10.20 system. The concepts also apply to other systems, such as AIX, that support logical volumes.

A disk can be divided into logical volumes (analogous to physical partitions). However, a logical volume can span more than one physical disk. Logical volumes are grouped into logical volume groups. Logical volumes cannot span more than one logical volume group.

The first step to using logical volumes is to create a volume group. Next, disks are added to the logical volume group and the logical volumes are created. It is important to leave some disk space unallocated so it can be added to logical volumes if they became full.

Unallocated space cannot be allocated across volume groups.

Using The Logical Volume Manager

On HP-UX, the set of commands used to manage logical volumes and volume groups is referred to as the Logical Volume Manager (LVM). The first step to using LVM is creating a volume group. Traditionally, volume-group names on HP-UX 10.20 are/dev/vg00,/dev/vg01, and the like. You can use any name you wish–more meaningful names (/der/development,/dev/data, and so forth) might make it simpler to administer. The steps to create the volume group are

1. Create the physical volume with pvcreate. If the disk has previously been configured for LVM, the -f option is needed to overwrite the old LVM configuration.

# pvcreate -f /dev/rdsk/c0t4d0

Physical volume “/dev/rdsk/c0t4d0” has been successfully created.

This example uses the disk installed with SCSI target ID 4. If you are not sure of the SCSI ID of your device, use the ioscan command to display the devices installed on your HP-UX system.

2. Create the volume-group directory and group file:

# mkdir /dev/data

# mknod /dev/data/group c 64 0xNN0000

where N N is a hexadecimal number unique to this volume group. I suggest starting with 00 and working up.

3. Create the volume group:

# vgcreate /dev/data /dev/dsk/c0t4d0

Volume group “/dev/data” has been successfully created. Volume Group configuration for /dev/data has been saved in /etc/lvmconf/data.conf

4. Create the logical volume:

# l vcreate /dev/data

Logical volume “/dev/data/lvoll” has been successfully created with character device “/dev/data/rlvoll”. Volume Group configuration for /dev/data has been saved in /etc/lvmconf/data.conf.

Each time you execute lvcreate, it creates a new logical volume named/dev/data/lvolN and automatically increments N. A specific name can be specified with the -n option and the size in megabytes can be specified using the -L option:

# lvcreate -n stocks -L 200 /dev/data

Logical volume “/dev/data/stocks” has been successfully created with character device “/der/data/rstocks”, Logical volume “/dev/data/stocks” has been successfully extended. Volume Group configuration for /dev/data has been saved in /etc/lvmconf/data.conf

The default size of a logical volume is 0. You can increase the size of a logical volume with the lvextend command:

lvextend -L 300 /dev/data/stocks

This command increases the size of the logical volume to 300MB. When a volume group is created, a physical extent size is specified. The default value is 4MB. All logical volumes must be specified in whole physical extents. The LVM commands will round up to the nearest physical extend, so you normally do not need to worry about this.

Now you are ready to use the logical volumes for file-system space, swap space, or as raw disk space for a database. The device names you use for commands like newfs are/dev/data/raccounting,/dev/data/rlvoll, and so forth:

newfs -F hfs /dev/data/rstocks

mount -F hfs /dev/data/stocks /mnt

hfs stands for high-performance file system and is the standard UNIX file system on HP-UX systems.

Increasing File-System Size

On HP-UX 10.20, you increase the size of a file system residing on a logical volume by first unmounting the file system:

umount /dev/data/stocks

If the file system is busy, you may need to bring the system to single-user mode with init S before you can unmount it. Alternatively, use the fuser command to display which processes have open files on the file system and kill those processes. Some file systems (such as/opt and/usr) will always have open files if you are running VUE or CDE. To extend these file systems, you must be in single-user mode.

Increase the size of the logical volume:

lvextend -L 500 /dev/data/stocks

Remember that 500 represents the new size of the logical volume in megabytes.

Increase the file-system capacity to match that of the logical volume:

extendfs /dev/data/stocks

Remount the file system using the mount command.

Using SAM

The HP-UX System Administration Manager (SAM) can perform most LVM tasks. However, it cannot

* extend a logical volume to a specific disk (this is useful for controlling the performance of your disks and ensuring the fastest disks are being used appropriately)

* create a root volume group and a root logical volume (for hosting the root file system)

* perform recovery of a raid disk. Instead, you must typically take your server to a professional raid recovery company.

* back up and restore volume-group configuration

* move and reconfigure disks

* reduce the size of a logical volume

* set up alternate cables to a physical volume

* increase the size of active file systems (you may have to bring the system to single-user mode and use the HP-UX commands)

There are HP-UX commands to perform these tasks. Please refer to your LaserROM documentation for more details.

The Journaled File System

Many vendors support both LVM and a journaled file system (JFS). A journaled file system provides faster system recovery and improves data reliability. It is important not to confuse LVM and JFS because they can be used together or separately. JFS is an alternative to a high-performance file system on HP-UX.


Categorised as: Unix


Leave a Reply

Your email address will not be published. Required fields are marked *