how to find out lvm Invalid snapshot ?

If we use crontab to make snapshot for lvm, we maybe check snapshot ofen. Does snapshot had out of size ? And how to know which snapshot had out of size ?

The next sample code can do it.

# work fine on centos
lvs -o lv_path,snap_percent|awk '{if($2==100.00){print $1;}}'

# work fine on ubuntu
lvs -o vg_name,lv_name,snap_percent|awk '{if($3==100.00){print $1/$2;}}'

use -o option to show column only lv_path and snap_percent then use awk to find snapshot path that had 100.00 percent.  But I can find option lv_path on ubuntu,so I use vg_name,lv_name columns to show path.

We can also autoremove the Invalid snapshots.

# work on centos
lvs -o lv_path,snap_percent|awk '{if($2==100.00){print $1;}}'|xargs -l lvremove -f

#work on ubutnu
lvs -o vg_name,lv_name,snap_percent|awk '{if($3==100.00){print $1/$2;}}'|xargs -l lvremove -f

發表迴響

在下方填入你的資料或按右方圖示以社群網站登入:

WordPress.com Logo

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

Twitter picture

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

Facebook照片

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

Google+ photo

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

連結到 %s