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


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

您的留言將使用 帳號。 登出 /  變更 )

Google+ photo

您的留言將使用 Google+ 帳號。 登出 /  變更 )

Twitter picture

您的留言將使用 Twitter 帳號。 登出 /  變更 )


您的留言將使用 Facebook 帳號。 登出 /  變更 )


連結到 %s