免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2481 | 回复: 0
打印 上一主题 下一主题

[新手入门] script recovery lv [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2010-01-21 22:15 |只看该作者 |倒序浏览
#!/usr/bin/ksh
# Note: this is a very minimal example of a scanner / repairer - it has no understanding of
# the user data and only lays down contiguous maps.
# change the folowing variables for bigVG or non-4MB PPSIZE
let offset=4352 # hard coded for a small VG
#let delta=8192 # hard coded for 4MB partitions (2048*4 blocks)
let delta=524288 # hard coded for 256MB partitions (2048*256 blocks)
HDISK=$1
VGID=`getlvodm -j $HDISK`
VG=`getlvodm -t $VGID`
echo $VG
exec 2>/dev/null
while :
do
    MAGIC=`dd if=/dev/$HDISK bs=512 skip=$offset count=1 2>/dev/null| head -c 8 `
    if [ "$MAGIC" = "AIX LVCB" ]
    then
        PP=`echo "( $offset - 4352 ) / 524288 + 1\n"|bc`
        echo "AIX LVCB found at PP$PP (offset $offset)"
        TYPE=`dd if=/dev/$HDISK bs=512 skip=$offset count=1 |\
            dd bs=1 skip=10 count=31`
        LVNAME=`dd if=/dev/$HDISK bs=512 skip=$offset count=1 |\
            dd bs=1 skip=67 count=31`
        set `dd if=/dev/$HDISK bs=512 skip=$offset count=1 |\
            dd bs=2 skip=104 count=2 |od -d`
        let NUMLPS=$2
        echo Type $TYPE
        echo LVname $LVNAME NUMLPS $NUMLPS
        exec 2>/dev/tty
        read decide?"Attempt restore (y to do) ?"
        if [ "$decide" = "y" ]
        then
            echo $HDISK":"$PP"-"`expr $PP + $NUMLPS` > /tmp/map_restore$$
            mklv -y $LVNAME -m /tmp/map_restore$$ $VG $NUMLPS
            rm /tmp/map_restore$$
        fi
        exec 2>/dev/null
    echo
    fi
    let offset=offset+delta
done
#############################
读取创建lv信息(恢复mkvg后的lv信息)
               
               
               

本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/6408/showart_2156627.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP