bzip2recover 修复tar.bz2大文件

66 篇文章 0 订阅
 
bzip2recover archive.tar.bz2
bzip2 -tv rec*.bz2 > testoutput.log 2>&1
# split into folders at each broken bit
bzip2 -dc rec*.bz2 > recovery1.tar
bzip2 -dc rec*.bz2 > recovery2_failing.tar
./findtarheader.pl recovery2_failing.tar | head -n 1   # first number from this into tail
tail -c +17185 recovery2_failing.tar > recovery2_working.tar

 

 

 

### Example 

 


[lake@localhost recory]$ tar  jxf  HiSTBLinuxV100R004C00SPC024_Loader.tar.bz2

bzip2: Data integrity error when decompressing.
        Input file = (stdin), output file = (stdout)

It is possible that the compressed file(s) have become corrupted.
You can use the -tvv option to test integrity of such files.

You can use the `bzip2recover' program to attempt to recover
data from undamaged sections of corrupted files.

tar: Unexpected EOF in archive
tar: Unexpected EOF in archive
tar: Error is not recoverable: exiting now
[lake@localhost recory]$ ls
HiSTBLinuxV100R004C00SPC024_Loader          
HiSTBLinuxV100R004C00SPC024_Loader.tar.bz2  

[lake@localhost recory]$ ls -l HiSTBLinuxV100R004C00SPC024_Loader
total 44
-rw-r--r-- 1 lhu3 Porcelain 11839 May 12  2015 cfg.mak
-rwxr--r-- 1 lhu3 Porcelain 12252 May 11  2015 cfg-spi-burn.mak
-rw-r--r-- 1 lhu3 Porcelain 12258 May 11  2015 cfg-spi-mcgui.mak
-rwxr--r-- 1 lhu3 Porcelain   813 May 11  2015 server_install
drwxr-xr-x 4 lhu3 Porcelain  4096 May 11  2015 tools
[lake@localhost recory]$ ls -l HiSTBLinuxV100R004C00SPC024_Loader/tools/
linux/   windows/
[lake@localhost recory]$ ls -l HiSTBLinuxV100R004C00SPC024_Loader/tools/linux/
kconfig/    Makefile    toolchains/ utils/
[lake@localhost recory]$ ls -l HiSTBLinuxV100R004C00SPC024_Loader/tools/linux/toolchains/arm-histbv300-linux/
arm-histbv300-linux.tar.bz2  cross.install
[lhu3@zch127bld08 HiSTBLinuxV100R004C00SPC024_Loader]$ du -hs tools/
499M    tools/  ===========>  只能tar 解开第一部分  

[lake@localhost recory]$ bzip2recover   HiSTBLinuxV100R004C00SPC024_Loader.tar.bz2
bzip2recover 1.0.6: extracts blocks from damaged .bz2 files.
bzip2recover: searching for block boundaries ...
   block 1 runs from 80 to 3978055
   block 2 runs from 3978104 to 11031396
.............
   block 3539 runs from 16735951242 to 16739653768
   block 3540 runs from 16739653817 to 16739653856 (incomplete)
bzip2recover: splitting into blocks
   writing block 1 to `rec00001HiSTBLinuxV100R004C00SPC024_Loader.tar.bz2' ...
   writing block 2 to `rec00002HiSTBLinuxV100R004C00SPC024_Loader.tar.bz2' ...
................
   writing block 3538 to `rec03538HiSTBLinuxV100R004C00SPC024_Loader.tar.bz2' ...
   writing block 3539 to `rec03539HiSTBLinuxV100R004C00SPC024_Loader.tar.bz2' ...
bzip2recover: finished
[lake@localhost recory]$ ls  -l 
rec00000HiSTBLinuxV100R004C00SPC024_Loader.tar.bz2  
...................
rec03539HiSTBLinuxV100R004C00SPC024_Loader.tar.bz2

[lhu3@zch127bld08 recover]$ bzip2 -tv rec*.bz2 > testoutput.log 2>&1
[lhu3@zch127bld08 recover]$ grep [^ok]$ testoutput.log
  rec00537HiSTBLinuxV100R004C00SPC024_Loader.tar.bz2: data integrity (CRC) error in data
  rec02619HiSTBLinuxV100R004C00SPC024_Loader.tar.bz2: data integrity (CRC) error in data
You can use the `bzip2recover' program to attempt to recover
data from undamaged sections of corrupted files.


#########################  Map !!!!  实际分3个部分, 有2段corrupt了 

rec00001HiSTBLinuxV100R004C00SPC024_Loader   =====>   Good
..........
rec00536HiSTBLinuxV100R004C00SPC024_Loader   ======>  Good 
rec00537HiSTBLinuxV100R004C00SPC024_Loader   ======>  corrupt /tar end here 
rec00538HiSTBLinuxV100R004C00SPC024_Loader   ======>  Good
........
rec02618HiSTBLinuxV100R004C00SPC024_Loader   ======>  Good
rec02619HiSTBLinuxV100R004C00SPC024_Loader   ======>  corrupt
rec02620HiSTBLinuxV100R004C00SPC024_Loader   ======>  Good
.............
rec03539HiSTBLinuxV100R004C00SPC024_Loader   ======>  Good


mkdir  r1  r2  r3   

### 排除corrupt部分 

r1:  rec00001~rec00536
r2:  rec00538~rec02618
r3:  rec02620~rec03539

[lhu3@zch127bld08 r1]$ cd 
[lhu3@zch127bld08 r1]$ bzip2 -dc rec*.bz2 > recovery1.tar
[lhu3@zch127bld08 r1]$ tar  tf recovery1.tar
HiSTBLinuxV100R004C00SPC024_Loader/
HiSTBLinuxV100R004C00SPC024_Loader/cfg.mak
.........
HiSTBLinuxV100R004C00SPC024_Loader/tools/linux/Makefile
HiSTBLinuxV100R004C00SPC024_Loader/tools/linux/toolchains/
HiSTBLinuxV100R004C00SPC024_Loader/tools/linux/toolchains/arm-histbv300-linux/
HiSTBLinuxV100R004C00SPC024_Loader/tools/linux/toolchains/arm-histbv300-linux/cross.install
HiSTBLinuxV100R004C00SPC024_Loader/tools/linux/toolchains/arm-histbv300-linux/arm-histbv300-linux.tar.bz2
tar: Skipping to next header
tar: Exiting with failure status due to previous errors

[lhu3@zch127bld08 r1]$ cd  ../r2

[lhu3@zch127bld08 r2]$ bzip2 -dc rec*.bz2 > recovery2_failing.tar

bzip2: Data integrity error when decompressing.
        Input file = rec00537HiSTBLinuxV100R004C00SPC024_Loader.tar.bz2, output file = (stdout)

It is possible that the compressed file(s) have become corrupted.
You can use the -tvv option to test integrity of such files.

You can use the `bzip2recover' program to attempt to recover
data from undamaged sections of corrupted files.

bzip2: WARNING: some files have not been processed:
bzip2:    2 specified on command line, 1 not processed yet.

### tool  to find tar header

https://download.csdn.net/download/hushui/12707778

##

 


[lhu3@zch127bld08 r2]$ ./findtarheader.pl recovery2_failing.tar                                            recovery2_failing.tar:533175871:././@LongLink:155
recovery2_failing.tar:533176895:HiSTBLinuxV100R004C00SPC024_Loader/tools/linux/toolchains/arm-histbv300-linux/arm-histbv300-linux_sr:1603535640
recovery2_failing.tar:769024063:HiSTBLinuxV100R004C00SPC024_Loader/tools/linux/toolchains/arm-histbv300-linux/ReadMe.txt:1035
recovery2_failing.tar:769025599:HiSTBLinuxV100R004C00SPC024_Loader/tools/linux/toolchains/arm-hisiv110-linux/:0
recovery2_failing.tar:769026111:HiSTBLinuxV100R004C00SPC024_Loader/tools/linux/toolchains/arm-hisiv110-linux/cross.install:3521
recovery2_failing.tar:769028671:././@LongLink:150
recovery2_failing.tar:769029695:HiSTBLinuxV100R004C00SPC024_Loader/tools/linux/toolchains/arm-hisiv110-linux/arm-hisiv110-linux.tar.:470734117
recovery2_failing.tar:851063359:HiSTBLinuxV100R004C00SPC024_Loader/tools/linux/toolchains/Makefile:1010
recovery2_failing.tar:851064895:HiSTBLinuxV100R004C00SPC024_Loader/tools/linux/toolchains/arm-hisiv200-linux/:0
recovery2_failing.tar:851065407:HiSTBLinuxV100R004C00SPC024_Loader/tools/linux/toolchains/arm-hisiv200-linux/cross.install:3530
recovery2_failing.tar:851067967:././@LongLink:150
recovery2_failing.tar:851068991:HiSTBLinuxV100R004C00SPC024_Loader/tools/linux/toolchains/arm-hisiv200-linux/arm-hisiv200-linux.tar.:2146223742
^C
[lhu3@zch127bld08 r2]$ tail -c +533175871  recovery2_failing.tar > recovery2_working.tar
[lhu3@zch127bld08 r2]$ tar tf recovery2_working.tar
HiSTBLinuxV100R004C00SPC024_Loader/tools/linux/toolchains/arm-histbv300-linux/arm-histbv300-linux_src.tar.gz
HiSTBLinuxV100R004C00SPC024_Loader/tools/linux/toolchains/arm-histbv300-linux/ReadMe.txt
HiSTBLinuxV100R004C00SPC024_Loader/tools/linux/toolchains/arm-hisiv110-linux/
......................
HiSTBLinuxV100R004C00SPC024_Loader/source/kernel/linux-3.10.y/arch/arm/mach-pxa/include/mach/regs-ost.h
HiSTBLinuxV100R004C00SPC024_Loader/source/kernel/linux-3.10.y/arch/arm/mach-pxa/include/mach/lpd270.h
HiSTBLinuxV100R004C00SPC024_Loader/source/kernel/linux-3.10.y/arch/arm/mach-pxa/include/mach/sharpsl_pm.h
tar: Unexpected EOF in archive
tar: Error is not recoverable: exiting now
[lhu3@zch127bld08 r2]$


cd  r3


[lhu3@zch127bld08 r2]$  cd  ../r3/
[lhu3@zch127bld08 r3]$ bzip2 -dc rec*.bz2 > recovery3_failing.tar


[lhu3@zch127bld08 r3]$ ./findtarheader.pl recovery3_failing.tar
recovery3_failing.tar:1646:HiSTBLinuxV100R004C00SPC024_Loader/source/kernel/linux-3.10.y/arch/arm/mach-mmp/mmp2.c:10603
recovery3_failing.tar:6766:HiSTBLinuxV100R004C00SPC024_Loader/source/kernel/linux-3.10.y/arch/arm/mach-mmp/sram.c:6763
recovery3_failing.tar:10862:HiSTBLinuxV100R004C00SPC024_Loader/source/kernel/linux-3.10.y/arch/arm/mach-mmp/gplugd.c:10260
.................
lhu3@zch127bld08 r3]$ ./findtarheader.pl recovery3_failing.tar  |head  -n 1
recovery3_failing.tar:1646:HiSTBLinuxV100R004C00SPC024_Loader/source/kernel/linux-3.10.y/arch/arm/mach-mmp/mmp2.c:10603
[lhu3@zch127bld08 r3]$ tail -c +1646    recovery3_failing.tar > recovery3_working.tar
[lhu3@zch127bld08 r3]$ tail -c +1646    recovery3_failing.tar > recovery3_working.tar^C
[lhu3@zch127bld08 r3]$ tar tf recovery3_working.tar
HiSTBLinuxV100R004C00SPC024_Loader/source/kernel/linux-3.10.y/arch/arm/mach-mmp/mmp2.c
HiSTBLinuxV100R004C00SPC024_Loader/source/kernel/linux-3.10.y/arch/arm/mach-mmp/sram.c
HiSTBLinuxV100R004C00SPC024_Loader/source/kernel/linux-3.10.y/arch/arm/mach-mmp/gplugd.c
HiSTBLinuxV100R004C00SPC024_Loader/source/kernel/linux-3.10.y/arch/arm/mach-w90x900/
.................
.......
HiSTBLinuxV100R004C00SPC024_Loader/sample/cipher/sample_anticopy.c
HiSTBLinuxV100R004C00SPC024_Loader/sample/cipher/sample_hash.c
HiSTBLinuxV100R004C00SPC024_Loader/sample/cipher/sample_cipher.c
HiSTBLinuxV100R004C00SPC024_Loader/install_notes(chs).txt
HiSTBLinuxV100R004C00SPC024_Loader/install_notes(eng).txt
HiSTBLinuxV100R004C00SPC024_Loader/cfg-spi-dbg.mak
[lhu3@zch127bld08 r3]$ cd  ..
[lhu3@zch127bld08 recover]$ ls
corrupted  HiSTBLinuxV100R004C00SPC024_Loader  r1  r2  r3  testoutput.log

####  Merge  
[lhu3@zch127bld08 recover]$ cp -ar -p r2/HiSTBLinuxV100R004C00SPC024_Loader/*  HiSTBLinuxV100R004C00SPC024_Loader/
[lhu3@zch127bld08 recover]$ cp -ar -p r3/HiSTBLinuxV100R004C00SPC024_Loader/*  HiSTBLinuxV100R004C00SPC024_Loader/
[lhu3@zch127bld08 recover]$ rm  -Rf  ../HiSTBLinuxV100R004C00SPC024_Loader
[lhu3@zch127bld08 recover]$ du -hs HiSTBLinuxV100R004C00SPC024_Loader/
3.3G    HiSTBLinuxV100R004C00SPC024_Loader/

 

救回3.3G数据  比最开始400M大了很多

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值