-
-
Save 1stcall/2cf8aec0c8d42dc4c1bf9369b5556ced to your computer and use it in GitHub Desktop.
raspi-reset
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| BS=64M | |
| DISK_ID=0x7788c428 | |
| ROOT_DEV=/dev/mmcblk0 | |
| BOOTFS_BACKUP=${ROOT_DEV}p3 | |
| BOOTFS_TARGET=${ROOT_DEV}p1 | |
| ROOTFS_BACKUP=${ROOT_DEV}p2 | |
| ROOTFS_TARGET=${ROOT_DEV}p4 | |
| if [ $EUID -ne 0 ]; then | |
| echo Must be run as root 1>&2 | |
| exit 1 | |
| fi | |
| echo Remounting disks read-only... | |
| echo 1 > /proc/sys/kernel/sysrq | |
| echo u > /proc/sysrq-trigger | |
| echo Overwritting bootfs... | |
| dd if=$BOOTFS_BACKUP of=$BOOTFS_TARGET bs=$BS status=progress | |
| echo Overwritting rootfs... | |
| dd if=$ROOTFS_BACKUP of=$ROOTFS_TARGET bs=$BS status=progress | |
| echo Restoring original disk id... | |
| sfdisk --disk-id $ROOT_DEV $DISK_ID | |
| # echo Checking and resizing filesystem... | |
| # e2fsck -f $ROOTFS_TARGET | |
| # resize2fs $ROOTFS_TARGET | |
| echo Done! Rebooting | |
| sleep 1 | |
| echo b > /proc/sysrq-trigger |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment