CloneNum3

filesystem_recovery.sh

Apr 16th, 2020
962
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.45 KB | None | 0 0
  1. #!/bin/bash
  2. #
  3.     if [ ! -d /var/mnt/usb1  ]; then
  4.         echo "USB disk-on-key is not detected"
  5.         exit 1
  6.     fi
  7.     service pm stop
  8.     # Kill mdt9 garbage collection thread
  9.     killall -9 jffs2_gcd_mtd9
  10.     # Flush file system buffers
  11.     sync
  12.     # Remount USB disk
  13.     umount /var/mnt/usb1
  14.     mkdir -p /tmp/usb1/recoveryfs/mtdblock9
  15.     mount -t vfat -o rw,nosuid,nodev,quiet /dev/sda1 /tmp/usb1/recoveryfs/mtdblock9
  16.     # copy data from parttion to USB disk:
  17.     rsync -aq /var /tmp/usb1/recoveryfs/mtdblock9/mtd9 > /tmp/usb1/recoveryfs/filesystem_recovery.log 2>&1
  18.     # Raw copy of /dev/mtd9 content to USB:
  19.     dd if=/dev/mtd9 of=/tmp/usb1/recoveryfs/mtdblock9/mtd9-raw
  20.     # Erase flash partition
  21.     flash_eraseall /dev/mtd9
  22.     # Copy back from USB to /mtd9
  23.     rsync -aq /tmp/usb1/recoveryfs/mtdblock9/mtd9/var/* /var/ >> /tmp/usb1/recoveryfs/filesystem_recovery.log 2>&1
  24.     umount /tmp/usb1/recoveryfs/mtdblock9
  25.     rm -rf /tmp/usb1
  26.     sync
  27.     # Restore mdt9 garbage collection thread
  28.     mount -o rw,remount /dev/mtdblock9
  29.     echo "Script is completed."
  30.     echo "Check that the next files are located disk-on-key in folder recoveryfs:"
  31.     echo "mtdblock9 - content of /var, copied from NAND to disk-on-key and back to NAND"
  32.     echo "mtd9 - raw copy of /dev/mtd9 - to be used for problem analyzing"
  33.     echo "filesystem_recovery.log - rsync log"
  34.     echo "system should now be rebooted and remanufacture might be in order"
Advertisement
Add Comment
Please, Sign In to add comment