rageek

A place for Unix Thoughts and Ideas

Displaying Progress of LVM sync / resync / resliver on HP-UX

When replacing disks (or sync’n mirrors for the first time) in LVM on HP-UX, there is no clear way of determining how far along in the process the system is.

In came up with a quick trick for calculating what percent of Logical extents are sync’d

Here is a nice one liner to display this. Just change the LV variable to point to the device file for the logical volume

LV=/dev/vg00/lvol5 ; echo `lvdisplay -v $LV | grep current | wc -l` `lvdisplay -v $LV | grep stale | wc -l` | awk ‘{printf ( “%3d percent Complete \n”, 100-$2/$1*100) }’

Alternatively, here is a for loop which will show the percent complete for any stale logical volume in the system.

for i in `vgdisplay -v 2>&1 | sed ‘/LV Name/N;s/\n/ /’ | grep “LV Name” | grep stale | awk ‘{print $3}’`;do
        printf “${i}:”; echo `lvdisplay -v $i | grep current | wc -l` `lvdisplay -v $i | grep stale | wc -l` | awk ‘{printf ( “%3d percent complete\n”, 100-$2/$1*100) }’
done

The output will look like:

/dev/vg00/lvol5: 70 percent complete

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: