Showing posts with label vg. Show all posts
Showing posts with label vg. Show all posts

Sunday, July 6, 2008

AIX Unix LVM Destruction Commands. Part Two Of Two

Hey there,

Today, we're finishing up what we started yesterday with our post on using LVM on AIX Linux. Today we're going to move on to Logical Volume, Volume Group and Physical Volume destruction commands. I also opted not to list out the usage commands (since there are quite a few of them, and we haven't covered this subject when looking at Linux LVM yet). It's fairly short and simple, but this is a "Lazy Sunday" :)

If you need help with some of the basic concepts of LVM, please check out our older post on getting started with LVM.

Happy, and hopefully Lazy, Sunday :)

AIX LVM Destruction commands:

Remove a logical volume:


host # rmlv MylogicalVolume

Remove a Volume Group (Note that, again it doesn't agree too much with the Linux or HP versions, we're just turning off the volume group to destroy it):

host # varyoffvg VolumeGroupName

De-Allocate a Physical Volume (Note that Physical Volumes, in AIX, already exist - they just need to be allocated to Volume Groups):

There is no specific pv command for this operation. PV allocation and de-allocation actually, for better or worse, happen as a result of the vg and lv destruction commands. However, you can do the following to "destroy" the device:

host # rmdev DEVICE

, Mike



Chris Gibson wrote in with these additional helpful comments. Thanks, Chris!


With regard to "Removing a volume group", I use this procedure:

# umount //datafs
/# rmfs //datafs/
# varyoffvg /datavg/
# reducevg datavg /hdisk2 hdisk3 hdisk4/

Reducevg will remove the volume group from the ODM.

Then I can remove the hdisk devices:

# rmdev -dl /hdisk2/
# rmdev -dl /hdisk3/
# rmdev -dl /hdisk4/

Also, if you want to move the VG to another system (or just temporarily remove the VG definition from the system), I use:

# varyoffvg /datavg/
# exportvg /datavg/

I can import it again later on the same or different system using:

# importvg -y /datavg hdisk2 hdisk3 hdisk4/

And one last comment, when I remove an LV I usually want the associated FS to be removed also, so I do:

# rmfs/ /datafs/

This will remove the file systems and the underlying logical volume.

Cheers

Chris

Saturday, July 5, 2008

Using LVM on AIX Unix. Part One Of No More Than Two.

Hey there,

As you may recall, we just completed a short series of posts on using LVM on Linux and Unix. At the time that I wrote it, I made mention (probably several times) of the similarities between LVM for Linux and HP-UX's brand. Also at that time, since I had hardly any experience with AIX, I was completely unaware that LVM was being used on that operating system.

If you need help with some of the basic concepts of LVM, please check out our older post on getting started with LVM and then check out the series listed above.

Now, I think I'm not allowed to get "too" excited about this, since this blog is mostly about Linux flavours and Solaris Unix (peppered with a little HP and one old post on AIX commands for the Unix user), but I thought I'd put this little series of posts (possibly not in totally sequential order -- Sometimes things come up that I'm compelled to write about ;) up for the AIX enthuisast who is thinking of using, or just beginning to use, LVM on AIX.

I hope this post is helpful to you. In any event, it should make for a good reference and might possibly be useful "later" :) Today, we'll look at LVM creation and display/monitoring commands for AIX and our next post will be on usage and destruction! Please note that all examples are mocked up and any variable that starts with Optional (such as OptionalVolumeGroupName) is an argument that you don't necessarily need to pass to the command.

Enjoy :)

AIX LVM Creation commands:

Create a Physical Volume (Note that Physical Volumes, in AIX, already exist - they just need to be allocated to Volume Groups):

host # lsvpcfg <-- To show the disks/vpaths and any Volume Groups they may already be associated with.
host # lspv|grep None <-- To show available Physical Volumes
host # cfgmgr <-- Use this interactively to allocate the Physical Volume for use with LVM.

Create a Volume Group:

host # mkvg -y VolumeGroupName HardDiskNumber <-- You can get the hard disk number from the lsdev command
host # varyonvg VolumeGroupName

Create a logical volume within a volume group:

host # mklv -y LogicalVolumeName -t FileSystemType VolumeGroup PhysicalPartion(PP) OptionalSpecificHardDriveDefinition
Ex:
host # mklv -y MylogicalVolume -t jfs MyVolumeGroup 8 <-- Note that the PP size is in MB.
or
host # mklv -y MylogicalVolume -t jfs MyVolumeGroup 8 /dev/DiskName

AIX LVM Display/Monitoring commands:

List out information about physical volumes:

host # lspv OptionalPhysicalVolumeName

List out Physical Volume information by Hard Disk:

host # lspv HardDiskNumber

List out Logical Volumes Within a Physical Volume:

host # lspv -l HardDiskNumber

List out Physical Partitions within a Physical Volume:

host # lspv -p HardDiskNumber

List out information about volume groups:

host # lsvg OptionalVolumeGroupName

List out properties of logical volumes within a volume group:

host # lsvg -l VolumeGroupName

List out properties, including hard drives, within a volume group:

host # lsvg -p VolumeGroupName

List out properties of a logical volume:

host # lslv OptionalLogicalVolumeName

List out Logical Volumes within a Physical Volume:

host # lslv -l OptionalLogicalVolumeName

List out Logical Volumes by Physical Volume:

host # lslv -p OptionalPhysicalVolumeName

List out mirrored Logical Volumes:

host # lslv -m OptionalLogicalVolumeName

List out hard disks in a vpath (Virtual Path). Necessary after Physical Volume Allocation to ensure everything went ok:

host # lsvpcfg

List out Fiber Channel adapters:

host # lsdev -Cc adapter
host # scfg -vl Number of fiber channel card

, Mike

Tuesday, June 10, 2008

How To Get Started With Logical Volume Management In Linux

Hey again,

Today, since past posts regarding disk management software have mostly been limited to Veritas Volume Manager, I thought we'd look at LVM on Linux (In a future post, we'll check out the differences between LVM 1 and 2, but for now I figured we could keep it simple and broad).

If you use any of the "major player" Linux flavours out there, you've probably noticed (over the last year or so) that standard installs show all your disks listed out in df, like:

/dev/mapper/vg01-lvol01 246M 75.2M 158M 32% /dir


rather than the old-style:

/dev/hdd1 246M 75.2M 158M 32% /dir


that you've (if you're anything like me and only have two hard drives on the home PC you're running Linux on ;) grown to love.

And, while I think it's fantastic that Linux has grown into a mostly-user-friendly operating system with GUI's to make all of the extended partitioning and volume management more accessible, I also think there's something to be said for knowing how to be able to set all that stuff up on your own. You never know when your main display (or X-windows session) will die on you and, at some point, you may end up having to do some disk repair on the lonely old command line.

With that in mind, we'll step through the most basic LVM setup: Getting from /dev/hdd to /dev/mapper/vg01-lvol01 from the command prompt.

Our basic (and huge assumption) here is that we've got a primary drive to work from (although we could do this just as easily from a rescue, or live, CD-ROM if we needed to perform this work on our primary disk during the Linux installation process or a freakish-nightmare of a fix)

First, we'll want to use fdisk to create a "new" "primary" partition that consists of the entire disk (512Mb in size). Barring a primer on fdisk, we'll want to set up our disk to have one primary partition that consists of all cylinders (first and last should be the default start and end values) and is set to the "Linux LVM" partition type.

Once we're done with the stuff we'd "normally" do (for the most part) to set up any other type of partition table on our /dev/hdd disk, we can begin to play around with the LVM commands. Note that if you chose any partition type other than LVM when setting up your partition, using the following commands will, at best, result in error messages and accomplish nothing :)

If you've ever used HP-UX before, a lot of these commands will seem familiar. There's a reason, but the legalities of discussing it (and possibly getting bits of it wrong) fall outside the scope of my pocketbook ;)

The first thing we'll do is create a "physical volume," like so:

host # pvcreate /dev/hdd1

Yes, it was a physical volume already. The logical-physical relationship sometimes doesn't hold up to scrutiny outside of the "rules" ;)

Next, well create a "volume group." This is necessary, because "logical volumes" run in packs... pardon my lack of propriety ;) We could use the "-s" option here to define the "physical extent" size, but we'll leave that alone. To say the least, specifying this requires some research and planning. If you get that number wrong, things can go South later, and you'll have to do some ugly backtracking. We just want to define a "volume group" so we have something to work with. We'll call it vg01, for lack of a more original name.

host # vgcreate vg01 /dev/hdd1

Next, we'll create a "logical volume" (we'll name this one "lvol01" to keep things consistent) of 246 Megabytes size. That should fit nicely inside vg01 (which we're basically using to represent the entire partition /dev/hdd1). We could make our "logical volume" as large as the entire partition and/or "volume group", but that would defeat the purpose of this whole exercise. The aim, of course, is to end up with flexible volumes so we can resize them later if we need to.

host # lvcreate -L 246M -n lvol01 vg01

This is where the /dev/mapper stuff comes into play (it never made sense to me the first time I saw it... really. It's because of my past experience with HP-UX ;) The "lvcreate" command creates a symlink between /dev/vg01/lvol01 and the character device /dev/mapper/vg01-lvol01.

And, next, all we have to do is format that bad boy:

host # mkfs -t ext3 /dev/vg01/lvol01

Note that, above, you can set a reserved block count (based on percentage) using the -m flag. I would usually set this to "-m 5" so that 5% of the allocated space would be reserved for root (although you can set it as low as 1). This way, if someone jams your filesystem up to 100% and no one can get any work done, you can still log in as root and fix the issue. -v is another useful flag if you want to see verbose output. You can insert these two flags anywhere in the above command line except at the very end (after the logical device name) or in between the -t flag and its argument. Common sense, I know, but I feel compelled to over-explain ;)

Now, we'll make a mount point, or, really, just make a new directory off of the root filesystem (although you can do overlays if you wanna get creative ;)

host # mkdir /dir

and then we'll mount our logical volume up and check it out with df:

host # mount -t ext3 /dev/vg01/lvol01 /dir

host # df -h /dir
...
/dev/mapper/vg0-lvol0 246M 75.2M 158M 32% /dir


Tomorrow, or maybe the day after that, we'll take a look at some more ways to manipulate your existing volumes, add more volumes, do mirroring and lots of other fun stuff that LVM allows you to do.

For now, we'll just thank our deity-of-choice that this all worked out ;)

Cheers,

, Mike