Archive for the ‘Various HOWTOs’ Category

How to create a mksysb of your AIX 5.3/6.1 server

Tuesday, June 24th, 2008


mksysb’s can come in handy for various situations. Whether you’re doing an upgrade, or just wanting a backup of a system, I definitely recommend using the mksysb command.
Creating a mksysb is a very simple process. First you need to make sure you have enough space free to dump it to, then just kick it off.

I generally run something like:

"mksysb -iep /mksysb_dump.mksysb


I generally create an NFS share from the NIM server, and mount it up on each AIX client in order to dump a weekly mksysb. The overall process actually ssh’s to the remote AIX client, mounts the NFS share, dumps a mksysb, compresses, umount, done.

With having issues in the past using the software compression within the mksysb process, I generally use the -p flag to disable software compression, and gzip at a later time. With a very busy rootvg, you will probably most likely have to disable compression, as you will likely run into issues restoring it.
Have fun.

How to apply patches for AIX 5.3, TL8 / Technology Level 8

Friday, June 20th, 2008

Just a very brief how to on the patching.
You can download the TL8 patch set from the following URL: http://www-933.ibm.com/eserver/support/fixes/fixcentral/pfixpacks/53

First you’ll generally want to commit all existing filesets in cases there are any issues with TL8, so you can back out more easily.
The following will commit all previously applied filesets:
/usr/lib/instl/sm_inst installp_cmd -c -f'all' '-g' '-X' '-V2'

Transfer the patch cluster to your server and decompress. Once that’s complete, run the following to preview the process:

/usr/sbin/install_all_updates -d -p -V -Y

Verify that everything looks good, then continue with:
/usr/sbin/install_all_updates -d -V -Y
Sit back and wait… Once complete, it would generally be a good idea to run through errpt, as well as a reboot then check it out again. Watch the console on boot for any odd boot messages or errors starting any services.

Verify the patching by checking the oslevel:
oslevel -s

How to apply AIX 6.1 SP2, level 6100-00-02-0750

Thursday, January 10th, 2008


This is just a brief example of how to install AIX 6.1 SP2. For a more thorough install, you should always follow IBMs installation documentation.

That being said, you will first have to grab the SP2 filesets at http://www-912.ibm.com/eserver/support/fixes/fixcentral/pfixpacks/61

Go through the menus and grab the fileset for level 6100-00-02-0750 from December 2007. This is what you want.

First verify that you are at SP1 or lower by running the following:

bash-3.00# oslevel -s
6100-00-01-0748

At this point, you would have probably already created a backup, just in case things go south. If not, you should probably create a mksysb of the system now.

You’ll most likely want to commit all existing filesets too by running:

bash-3.00# installp -c all
+—————————————————————————–+
Pre-commit Verification…
+—————————————————————————–+
Verifying selections…done
Verifying requisites…done
Results…

WARNINGS
——–
Problems described in this section are not likely to be the source of any
immediate or serious failures, but further actions may be necessary or
desired.

Nothing to Commit
—————–
There is nothing in the APPLIED state that needs to be committed.

<< End of Warning Section >>

+—————————————————————————–+
BUILDDATE Verification …
+—————————————————————————–+
Verifying build dates…done

You’ll want to create a table of contents by running:

bash-3.00# inutoc ./
bash-3.00# ls -lart .toc
-rw-r–r– 1 root system 40540 Jan 09 21:24 .toc

Next you’re all ready to install SP2. Pretty simple huh?

I generally use the following flags with installp, or you can even do this through ’smit install’

bash-3.00# installp -a -d ./ -Y -p all

The ‘-a’ will apply packages only, ‘-d ./’ will specify the current directory for the filesets to install, -Y will say ‘Yes’ to all licenses, -p will preview, and of course ‘all’ will apply all filesets within the ‘-d’ location. Once you preview the install, you can remove -p and do the actual installation.

bash-3.00# installp -a -d ./ -Y -p all
*******************************************************************************
installp PREVIEW: installation will not actually occur.
*******************************************************************************

+—————————————————————————–+
Pre-installation Verification…
+—————————————————————————–+
Verifying selections…done
Verifying requisites…done
Results…

WARNINGS
——–
Problems described in this section are not likely to be the source of any
immediate or serious failures, but further actions may be necessary or
desired.

Already Installed
—————–
The following filesets which you selected are either already installed
or effectively installed through superseding filesets.

invscout.rte 2.2.0.12 # Inventory Scout Runtime
bos.alt_disk_install.boot_images 6.1.0.1 # Alternate Disk Installation …
devices.pci.02105e51.diag 6.1.0.1 # Native Display Graphics Adap…
bos.rte.boot 6.1.0.1 # Boot Commands
devices.common.rspcbase.rte 6.1.0.1 # RISC PC Common Base System D…
devices.pci.02105e51.rte 6.1.0.1 # Native Display Adapter Software
X11.base.lib 6.1.0.1 # AIXwindows Runtime Libraries
X11.apps.xdm 6.1.0.1 # AIXwindows xdm Application
sysmgt.websm.apps 6.1.0.1 # Web-based System Manager App…
X11.base.rte 6.1.0.1 # AIXwindows Runtime Environment
X11.base.smt 6.1.0.1 # AIXwindows Runtime Shared Me…
bos.rte.bosinst 6.1.0.1 # Base OS Install Commands
devices.scsi.tape.diag 6.1.0.1 # SCSI Tape Device Diagnostics
devices.chrp.base.diag 6.1.0.1 # RISC CHRP Base System Device…
devices.pci.77102224.com 6.1.0.1 # PCI-X FC Adapter (77102224) …
devices.pci.14106902.rte 6.1.0.1 # 10/100/1000 Base-TX PCI-X Ad…
devices.pci.df1000f7.com 6.1.0.1 # Common PCI FC Adapter Device…

NOTE: Base level filesets may be reinstalled using the “Force”
option (-F flag), or they may be removed, using the deinstall or
“Remove Software Products” facility (-u flag), and then reinstalled.

<< End of Warning Section >>

SUCCESSES
———
Filesets listed in this section passed pre-installation verification
and will be installed.

Mandatory Fileset Updates
————————-
(being installed automatically due to their importance)
bos.rte.install 6.1.0.2 # LPP Install Commands

<< End of Success Section >>

FILESET STATISTICS
——————
75 Selected to be installed, of which:
1 Passed pre-installation verification
17 Already installed (directly or via superseding filesets)
57 Deferred (see *NOTE below)
—-
1 Total to be installed

*NOTE The deferred filesets mentioned above will be processed after the
installp update and its requisites are successfully installed.

RESOURCES
———
Estimated system resource requirements for filesets being installed:
(All sizes are in 512-byte blocks)
Filesystem Needed Space Free Space
/usr 4200 168040
/tmp 424 129760
—– ——– ——
TOTAL: 4624 297800

NOTE: “Needed Space” values are calculated from data available prior
to installation. These are the estimated resources required for the
entire operation. Further resource checks will be made during
installation to verify that these initial estimates are sufficient.
Use the option to extend filesystems (-X flag) to ensure that any
additional resources which may be needed are automatically allocated.

******************************************************************************
End of installp PREVIEW. No apply operation has actually occurred.
******************************************************************************

bash-3.00# installp -a -d ./ -Y all

Once the installation is complete, you will see something similar to the following:

0503-409 installp: bosboot verification starting…
installp: bosboot verification completed.
0503-408 installp: bosboot process starting…

bosboot: Boot image is 36418 512 byte blocks.
0503-292 This update will not fully take effect until after a
system reboot.

* * * A T T E N T I O N * * *
System boot image has been updated. You should reboot the
system as soon as possible to properly integrate the changes
and to avoid disruption of current functionality.

installp: bosboot process completed.
+—————————————————————————–+
Summaries:
+—————————————————————————–+

Pre-installation Failure/Warning Summary
—————————————-
Name Level Pre-installation Failure/Warning
——————————————————————————-
ndaf.base.server 6.1.0.1 Requisite failure
ndaf.base.client 6.1.0.1 Requisite failure
ndaf.base.admin 6.1.0.1 Requisite failure
bos.net.nfs.cachefs 6.1.0.2 Requisite failure
bos.net.nfs.adt 6.1.0.1 Requisite failure
bos.mls.cfg 6.1.0.1 Requisite failure
bos.adt.prof 6.1.0.2 Requisite failure
bos.adt.debug 6.1.0.1 Requisite failure
X11.fnt.fontServer 6.1.0.1 Requisite failure
X11.Dt.lib 6.1.0.1 Requisite failure
bos.rte.install 6.1.0.2 Already installed

Installation Summary
——————–
Name Level Part Event Result
——————————————————————————-
bos.rte.mlslib 6.1.0.1 USR APPLY SUCCESS
bos.suma 6.1.0.1 USR APPLY SUCCESS
bos.suma 6.1.0.1 ROOT APPLY SUCCESS
ICU4C.rte 6.1.0.1 USR APPLY SUCCESS
bos.net.tcp.server 6.1.0.1 USR APPLY SUCCESS
bos.net.tcp.server 6.1.0.1 ROOT APPLY SUCCESS
invscout.rte 2.2.0.12 USR APPLY SUCCESS
invscout.rte 2.2.0.12 ROOT APPLY SUCCESS
bos.rte.boot 6.1.0.1 USR APPLY SUCCESS
bos.rte.boot 6.1.0.1 ROOT APPLY SUCCESS
devices.common.rspcbase.rte 6.1.0.1 USR APPLY SUCCESS
devices.pci.02105e51.diag 6.1.0.1 USR APPLY SUCCESS
devices.pci.02105e51.rte 6.1.0.1 USR APPLY SUCCESS
X11.apps.xdm 6.1.0.1 USR APPLY SUCCESS
bos.64bit 6.1.0.2 USR APPLY SUCCESS
devices.pci.1410ec02.rte 6.1.0.1 USR APPLY SUCCESS
bos.sysmgt.sysbr 6.1.0.2 USR APPLY SUCCESS
bos.sysmgt.sysbr 6.1.0.2 ROOT APPLY SUCCESS
bos.aixpert.cmds 6.1.0.2 USR APPLY SUCCESS
bos.aixpert.cmds 6.1.0.2 ROOT APPLY SUCCESS
bos.perf.libperfstat 6.1.0.1 USR APPLY SUCCESS
devices.chrp.IBM.lhea.rte 6.1.0.1 USR APPLY SUCCESS
devices.common.IBM.mpio.rte 6.1.0.2 USR APPLY SUCCESS
devices.fcp.disk.rte 6.1.0.2 USR APPLY SUCCESS
bos.perf.perfstat 6.1.0.1 USR APPLY SUCCESS
bos.rte.libc 6.1.0.2 USR APPLY SUCCESS
bos.rte.tty 6.1.0.2 USR APPLY SUCCESS
bos.pmapi.events 6.1.0.1 USR APPLY SUCCESS
bos.pmapi.lib 6.1.0.1 USR APPLY SUCCESS
bos.pmapi.pmsvcs 6.1.0.1 USR APPLY SUCCESS
bos.pmapi.tools 6.1.0.1 USR APPLY SUCCESS
bos.pmapi.tools 6.1.0.1 ROOT APPLY SUCCESS
bos.rte.shell 6.1.0.2 USR APPLY SUCCESS
bos.rte.shell 6.1.0.2 ROOT APPLY SUCCESS
bos.rte.date 6.1.0.1 USR APPLY SUCCESS
bos.rte.date 6.1.0.1 ROOT APPLY SUCCESS
bos.perf.tune 6.1.0.1 USR APPLY SUCCESS
bos.perf.tune 6.1.0.1 ROOT APPLY SUCCESS
bos.rte.security 6.1.0.2 USR APPLY SUCCESS
bos.rte.security 6.1.0.2 ROOT APPLY SUCCESS
bos.rte.control 6.1.0.2 USR APPLY SUCCESS
bos.rte.control 6.1.0.2 ROOT APPLY SUCCESS
devices.chrp.IBM.lhca.rte 6.1.0.2 USR APPLY SUCCESS
devices.pci.df1000f7.diag 6.1.0.1 USR APPLY SUCCESS
bos.perf.tools 6.1.0.2 USR APPLY SUCCESS
bos.perf.tools 6.1.0.2 ROOT APPLY SUCCESS
bos.adt.include 6.1.0.2 USR APPLY SUCCESS
bos.rte.serv_aid 6.1.0.2 USR APPLY SUCCESS
bos.rte.serv_aid 6.1.0.2 ROOT APPLY SUCCESS
bos.mp64 6.1.0.3 USR APPLY SUCCESS
bos.mp64 6.1.0.3 ROOT APPLY SUCCESS
bos.wpars 6.1.0.2 USR APPLY SUCCESS
bos.wpars 6.1.0.2 ROOT APPLY SUCCESS
bos.acct 6.1.0.2 USR APPLY SUCCESS
bos.acct 6.1.0.2 ROOT APPLY SUCCESS
bos.rte.filesystem 6.1.0.1 USR APPLY SUCCESS
bos.rte.filesystem 6.1.0.1 ROOT APPLY SUCCESS
bos.rte.SRC 6.1.0.1 USR APPLY SUCCESS
bos.rte.SRC 6.1.0.1 ROOT APPLY SUCCESS
bos.rte.archive 6.1.0.2 USR APPLY SUCCESS
bos.rte.archive 6.1.0.2 ROOT APPLY SUCCESS
bos.sysmgt.serv_aid 6.1.0.2 USR APPLY SUCCESS
bos.sysmgt.serv_aid 6.1.0.2 ROOT APPLY SUCCESS
bos.rte.commands 6.1.0.1 USR APPLY SUCCESS
bos.rte.lvm 6.1.0.2 USR APPLY SUCCESS
bos.rte.lvm 6.1.0.2 ROOT APPLY SUCCESS
bos.sysmgt.trace 6.1.0.2 USR APPLY SUCCESS
bos.sysmgt.trace 6.1.0.2 ROOT APPLY SUCCESS
sysmgt.pconsole.rte 6.1.0.1 USR APPLY SUCCESS
devices.common.IBM.ib.rte 6.1.0.2 USR APPLY SUCCESS
devices.usbif.08025002.rte 6.1.0.1 USR APPLY SUCCESS
devices.vdevice.IBM.v-scsi. 6.1.0.2 USR APPLY SUCCESS
devices.pci.00105000.com 6.1.0.1 USR APPLY SUCCESS
devices.chrp.base.rte 6.1.0.2 USR APPLY SUCCESS
devices.common.IBM.sissas.r 6.1.0.1 USR APPLY SUCCESS
bos.net.tcp.client 6.1.0.2 USR APPLY SUCCESS
bos.net.tcp.client 6.1.0.2 ROOT APPLY SUCCESS
bos.net.nfs.client 6.1.0.2 USR APPLY SUCCESS
bos.net.nfs.client 6.1.0.2 ROOT APPLY SUCCESS
X11.base.lib 6.1.0.1 USR APPLY SUCCESS
sysmgt.websm.apps 6.1.0.1 USR APPLY SUCCESS
X11.base.rte 6.1.0.1 USR APPLY SUCCESS
X11.base.smt 6.1.0.1 USR APPLY SUCCESS
bos.rte.bosinst 6.1.0.1 USR APPLY SUCCESS
devices.scsi.tape.diag 6.1.0.1 USR APPLY SUCCESS
bos.alt_disk_install.boot_i 6.1.0.1 USR APPLY SUCCESS
devices.chrp.base.diag 6.1.0.1 USR APPLY SUCCESS
devices.pci.df1000f7.com 6.1.0.1 USR APPLY SUCCESS
devices.pci.77102224.com 6.1.0.1 USR APPLY SUCCESS
devices.pci.14106902.rte 6.1.0.1 USR APPLY SUCCESS

installp: * * * A T T E N T I O N ! ! !
Software changes processed during this session require this system
and any of its diskless/dataless clients to be rebooted in order
for the changes to be made effective.

You now have SP2 applied.

bash-3.00# oslevel -s
6100-00-02-0750

How to Disable JFS2 Logging in AIX 6.1

Wednesday, December 26th, 2007


AIX 6.1 allows you to mount a JFS2 filesystem without logging. This can increase performance by not requiring the FS to write metadata or log details. You could probably benefit by using this feature on temporary non-critical filesystems such as frequently used tmp space or a backup/restore tmp type of filesystem. With using this feature, you should assume that if the machine were to crash or you have other system related issues, you could potentially lose the entire non-logging filesystem.

If you still feel you can use this feature, you can mount by using the following:

To mount on the fly:

mount -o log=NULL /testfs

You will need to modify /etc/filesystems in order to make this change persistent across boots.

How to create a basic WPAR(Workload Partition) in AIX 6.1

Wednesday, December 26th, 2007


To demonstrate the simplicity of creating a Workload Partition within AIX 6.1 via CLI, here’s a quick example. The WPAR commands in AIX are pretty easy to figure out. You can even guess what they are, using the standard AIX file naming convention; mkwpar, lswpar, startwpar, stopwpar, chwpar, etc. If you prefer the GUI type of configuration, there is also a web based Workload Partition Manager tool that IBM introduced. Please see the AIX Version 6.1 IBM Workload Partitions Manager for AIX Redbook for more information.

Start out by creating the WPAR using the mkwpar command.

bash-3.00# mkwpar
mkwpar: 0960-046 Workload partition name is required.
Usage: mkwpar [-a] [-A] [-b devexportsFile] [-B wparBackupDevice] [-c]
[-d directory] [-D attr=value ...] … [-F] [-g vg ]
[-h hostName] [-l] [-L attr=value ...] [-M attr=value ...] …
[-N attr=value ...] … [-P] [-r] [-R attr=value ...]
[-S attr[+|-]=value …] [-s] [-u /path/to/script] [-v]
{ -n wparName [-p [name]] [-e existing_wpar | -f inFile] [-o outFile [-w]]
| -p name [-n wparName] [-e existing_wpar | -f inFile] [-o outFile [-w]]
| -f inFile [-n wparName] [-p [name]] [-o outFile [-w]]
| -w -o outFile [-n wparName] [-p [name]] [-f inFile | -e existing_wpar] }

Flags:
-a = Automatically resolve erroneous/conflicting settings.
-A = Start automatically on system boot.
-b = Path to permitted device exports file.
-B = Device or Pathname of savewpar backup image.
-c = Flag as checkpointable.
-d = Base directory.
-D = Override default device exports (devname, devtype, export).
-e = Get specification data from existing workload partition.
-f = Path to input specification file.
-F = Force - ignore certain errors.
-g = Default volume group for local file systems.
-h = Hostname.
-l = Create private, writeable versions of /usr and /opt.
-L = Logical volume management policy (image_data, shrink, ignore_maps).
-M = Mount settings (dev, directory, vfs, size, crfsopts, mode,
vg, logname, host, mountopts).
-n = Workload partition name.
-N = Network settings (interface, address, netmask, broadcast).
-o = Path to output specification file.
-p = Preserve file system data from the named mount group.
-P = Set workload partition root password interactively.
-r = Copy global network name resolution configuration into the workload
partition.
-R = Resource control settings (active, rset, CPU, memory, procVirtMem,
shares_CPU, shares_memory, totalProcesses, totalThreads).
-S = Configures the security settings of a workload partition (secfile, privs[+|-]).
-s = Start after creation.
-u = User script to execute on start & stop.
-v = Verbose mode.
-w = Only write specification file (do not create).

I am just creating a basic WPAR with a writable /usr and /opt. If -l is not specified, this WPAR will contain a loop back mounted fs for /usr and /opt using the global WPARs filesystem. You will obviously not be able to install any WPAR specific software that requires writing to /usr or /opt, unless your in the global WPAR. -a tells the WPAR to boot upon system boot, or global WPAR boot. -n will define the WPAR name, which shows up in the global WPAR. -h will define the hostname of the WPAR, and will grab its ethernet address from /etc/hosts.

bash-3.00# mkwpar -a -h wpar1 -l -n wpar1 -v
mkwpar: Creating file systems…
/
/home
/opt
/proc
/tmp
/usr
/var
Mounting all workload partition file systems.
mkwpar: Copying base files…

syncroot: Installing RPM file: /var/ssl/openssl.cnf
syncroot: RPM root packages are currently synchronized.
syncroot: Root part is currently synchronized.
syncroot: Returns Status = SUCCESS
Workload partition wpar1 created successfully.
mkwpar: 0960-390 To start the workload partition, execute the following as root: startwpar [-v] wpar1

mkwpar will create new logical volumes for the WPAR to live on. It will then make a copy of the running AIX instance and prepare the WPAR for boot.

’startwpar’ is the command you will boot the WPAR with.

bash-3.00# startwpar -v wpar1
Starting workload partition wpar1.
Mounting all workload partition file systems.
Mounting /wpars/wpar1
Mounting /wpars/wpar1/home
Mounting /wpars/wpar1/opt
Mounting /wpars/wpar1/proc
Mounting /wpars/wpar1/tmp
Mounting /wpars/wpar1/usr
Mounting /wpars/wpar1/var
Loading workload partition.

Exporting workload partition devices.
Starting workload partition subsystem cor_wpar1.
0513-059 The cor_wpar1 Subsystem has been started. Subsystem PID is 876724.
Verifying workload partition startup.
Return Status = SUCCESS.

Once the WPAR is booted, you can check the status by using ‘lswpar’

bash-3.00# lswpar
Name State Type Hostname Directory
—————————————————————-
wpar1 A S wpar1 /wpars/wpar1

Now that the WPAR is online, you can telnet to it, ssh to it, or use the ‘clogin’ tool for console login. You can also use clogin with a command as a parameter as well, then it will execute the command within the WPAR as shown.

bash-3.00# clogin wpar1
*******************************************************************************
* *
* *
* Welcome to AIX Version 6.1! *
* *
* *
* Please see the README file in /usr/lpp/bos for information pertinent to *
* this release of the AIX Operating System. *
* *
* *
*******************************************************************************

# hostname
wpar1
#

bash-3.00# clogin wpar1 hostname
wpar1

Tired of playing with it? ’stopwpar’ will kill it.

bash-3.00# stopwpar
Usage: stopwpar [-F|-h] [-N|-t ] [-r] [-v] wparName

Flags:
-F = Forced stop.
-h = Hard stop.
-N = No timeout for halt.
-t = User specified halt timeout in seconds.
-r = Reboot after halt is completed.
-v = Verbose mode.
bash-3.00# stopwpar wpar1
Stopping workload partition wpar1.
Stopping workload partition subsystem cor_wpar1.
0513-044 The cor_wpar1 Subsystem was requested to stop.
stopwpar: 0960-261 Waiting up to 600 seconds for workload partition to halt.
Shutting down all workload partition processes.
Unmounting all workload partition file systems.
bash-3.00#

Also you might want to check out ‘chwpar’ for changing WPAR configurations.

bash-3.00# chwpar
Usage:
To change a setting:

chwpar [-a] [-A] [-c] [-d directory] [-D attr=value ...] …
[-F] [-h hostName] [-n newName] [-N attr=value ...] …
[-P] [-R attr=value ...] [-S attr[+|-]=value …] [-u userScript] [-v]
wparName

To delete a setting:

chwpar -K [-A] [-c] [-D devname=value] … [-F] [-N address=value] …
[-R [attr ...] ] [-S] [-u] [-v]
wparName

Flags:
-a = Automatically resolve erroneous/conflicting settings.
-A = Start automatically on system boot.
-c = Flag as checkpointable.
-d = Base directory.
-D = Device exports (devname, devtype, export).
-F = Force - ignore certain errors.
-h = Hostname.
-n = New workload partition name.
-N = Network settings (interface, address, netmask, broadcast).
-P = Set workload partition root password interactively.
-R = Resource control settings (active, rset, CPU, memory, procVirtMem,
shares_CPU, shares_memory, totalProcesses, totalThreads).
-S = Configures the security settings of a workload partition (secfile, privs[+|-]).
-u = User script to execute on start & stop.
-v = Verbose mode.

That’s a basic overview of creating a WPAR. Consult the man page for more complex configurations. This just demonstrates basic functionality.

A quick HOWTO for LVM2 and Linux

Wednesday, December 26th, 2007


This is just a quick overview of LVM2 and how to use it. LVM in general makes managing servers much easier due to being more flexible with storage devices. Disk management is much simpler. No longer do you have to use an entire disk partition for a file system, you can just create a new logival volume and go on.

You can see the partition layout of this box. I’ll be playing around with /dev/hda6 which is a single partition labeled as Linux/LVM.

Device Boot Start End Blocks Id System
/dev/hda1 1 609 4891761 83 Linux
/dev/hda2 610 734 1004062+ 82 Linux swap / Solaris
/dev/hda3 735 1951 9775552+ 83 Linux
/dev/hda4 3168 19457 130849425 5 Extended
/dev/hda5 8034 19457 91763248+ 7 HPFS/NTFS
/dev/hda6 3168 4384 9775521 8e Linux LVM

The first step to using LVM is assigning an unused partition or physical disk to LVM. You do this by running the ‘pvcreate’ command. The device can be a disk partition, entire whole disk, meta device, or a loop back file.

firmo log # pvcreate /dev/hda6
Physical volume “/dev/hda6″ successfully created

firmo log # pvs
PV VG Fmt Attr PSize PFree
/dev/hda6 lvm2 — 9.32G 9.32G

Once the physical volume is initialized, you will have to create a volume group using the ‘vgcreate’ command. The volume group is a collection of physical volumes as created above. Your logical volumes will live within this volume group. It’s generally best to make a volume group for a certain group of storage since it will be somewhat sharing the same backend devices, such as rootvg in the AIX world. If you were to eventually create another volume group for a groupd of database filesystems, you would probably name it accordingly. One of the reasons I generally keep storage groups separate is for data migrations. If you have SAN storage going to host1, and have a single volume group with 10 different applications running in it, it’ll make migration of one or two applications very difficult when moving to a new host. If you have a volume group for each different application, you can easily manipulate that individual volume group to export it to a new host.

Here is an example of creating volume group test_vg using physical volume /dev/hda6

firmo ~ # vgcreate test_vg /dev/hda6
Volume group “test_vg” successfully created

The ‘vgs’ command will show you detected volume groups.

firmo ~ # vgs
VG #PV #LV #SN Attr VSize VFree
test_vg 1 0 0 wz–n- 9.32G 9.32G

Now that you have a usable volume group, you will need to create a logical volume to actually write the data to. This is done using the ‘lvcreate’ command as shown below.

This command is creating a 2GB logical volume that is read/write using test_vg to grab its storage from.

firmo linux # lvcreate -L 2G -p rw test_vg
Logical volume “lvol0″ created

Notice I didn’t specify a name, so the logical volume is named lvol0 by default. If you were to do this again, you could have lvol1, etc.

firmo linux # lvs
LV VG Attr LSize Origin Snap% Move Log Copy%
lvol0 test_vg -wi-a- 2.00G

Here I specify name for the LV.

firmo linux # lvcreate -L 2G -p rw -n test_lv test_vg
Logical volume “test_lv” created

firmo linux # lvs
LV VG Attr LSize Origin Snap% Move Log Copy%
lvol0 test_vg -wi-a- 2.00G
test_lv test_vg -wi-a- 2.00G

Now the device is ready for use. I will format it with reiserfs.

firmo linux # mkreiserfs /dev/test_vg/test_lv

Once the file system is created, you are free to mount the volume. Notice the mount device, it will be /dev/volume_group/logical_volume.

firmo linux # mount /dev/test_vg/test_lv /test
firmo linux # df -h /test
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/test_vg-test_lv
2.0G 33M 2.0G 2% /test

Once you’re done playing around, you can go ahead and delete the logical volume and volume group. You can even remove the physical volume definition for that matter.

The volume must be unmounted before removing the device as shown.

firmo linux # lvremove /dev/test_vg/test_lv
Can’t remove open logical volume “test_lv”
firmo linux # umount /test
firmo linux # lvremove /dev/test_vg/test_lv
Do you really want to remove active logical volume “test_lv”? [y/n]: y
Logical volume “test_lv” successfully removed

firmo linux # lvremove -f /dev/test_vg/lvol0
Logical volume “lvol0″ successfully removed

Now I remove the test_vg volume group

firmo linux # vgremove test_vg
Volume group “test_vg” successfully removed

And remove the physical volume

firmo linux # pvremove /dev/hda6
Labels on physical volume “/dev/hda6″ successfully wiped