peetaur

a script that MIGHT undelete an LVM PV you deleted

Oct 9th, 2013
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. device=/dev/md2
  2.  
  3. bytes="4c 56 4d 32 20 30 30 31"
  4. str=""
  5. for b in $bytes; do
  6. hex=$(echo "$b" | tr "[:lower:]" "[:upper:]")
  7. dec=$(echo "ibase=16; $hex" | bc)
  8.  
  9. ch=$(eval "printf \$'\\x${hex}'")
  10. str="${str}${ch}"
  11. done
  12.  
  13. echo "Data to write:"
  14. echo -n "$str" | hexdump -C
  15. # 00000000 4c 56 4d 32 20 30 30 31 |LVM2 001|
  16. # 00000008
  17.  
  18. echo "Before:"
  19. dd if=$device bs=1 count=8 skip=536 2>/dev/null | hexdump -C
  20. # 00000000 00 00 00 00 00 00 00 00 |........|
  21. # 00000008
  22.  
  23. echo "Writing..."
  24. echo -n "$str" | dd of=$device bs=1 count=8 seek=536
  25.  
  26. echo "After:"
  27. dd if=$device bs=1 count=8 skip=536 2>/dev/null | hexdump -C
  28. # 00000000 4c 56 4d 32 20 30 30 31 |LVM2 001|
  29. # 00000008
Advertisement
Add Comment
Please, Sign In to add comment