Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #
- if [ ! -d /var/mnt/usb1 ]; then
- echo "USB disk-on-key is not detected"
- exit 1
- fi
- service pm stop
- # Kill mdt9 garbage collection thread
- killall -9 jffs2_gcd_mtd9
- # Flush file system buffers
- sync
- # Remount USB disk
- umount /var/mnt/usb1
- mkdir -p /tmp/usb1/recoveryfs/mtdblock9
- mount -t vfat -o rw,nosuid,nodev,quiet /dev/sda1 /tmp/usb1/recoveryfs/mtdblock9
- # copy data from parttion to USB disk:
- rsync -aq /var /tmp/usb1/recoveryfs/mtdblock9/mtd9 > /tmp/usb1/recoveryfs/filesystem_recovery.log 2>&1
- # Raw copy of /dev/mtd9 content to USB:
- dd if=/dev/mtd9 of=/tmp/usb1/recoveryfs/mtdblock9/mtd9-raw
- # Erase flash partition
- flash_eraseall /dev/mtd9
- # Copy back from USB to /mtd9
- rsync -aq /tmp/usb1/recoveryfs/mtdblock9/mtd9/var/* /var/ >> /tmp/usb1/recoveryfs/filesystem_recovery.log 2>&1
- umount /tmp/usb1/recoveryfs/mtdblock9
- rm -rf /tmp/usb1
- sync
- # Restore mdt9 garbage collection thread
- mount -o rw,remount /dev/mtdblock9
- echo "Script is completed."
- echo "Check that the next files are located disk-on-key in folder recoveryfs:"
- echo "mtdblock9 - content of /var, copied from NAND to disk-on-key and back to NAND"
- echo "mtd9 - raw copy of /dev/mtd9 - to be used for problem analyzing"
- echo "filesystem_recovery.log - rsync log"
- echo "system should now be rebooted and remanufacture might be in order"
Advertisement
Add Comment
Please, Sign In to add comment